bugGNU Octave - Bugs: bug #47506, rgb2ind creates colormap...

 
 

bug #47506: rgb2ind creates colormap incompartible to ind2rgb

Submitter:  Daniel Roeske <dmjr>
Submitted:  Wed 23 Mar 2016 08:33:45 AM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 23 Mar 2016 05:06:56 PM UTC, comment #2: 

Thanks for the quick response, problem solved.

Daniel Roeske <dmjr>
Wed 23 Mar 2016 04:14:29 PM UTC, comment #1: 

The problem is that your image M is not really a RGB image (or not a very sensible one at least). It will work if you change its type to uint8.


octave> [Mind, map] = rgb2ind (uint8 (M));
octave> Mrgb = ind2rgb (Mind, map);


Your rgb image is of class double therefore its values should be in the range [0 1]. The real issue is with ind2rgb  not handling values outside that range.  This has been addressed in bug #41851 and already fixed (it will be part of 4.2 or whatever is the upcoming minor release).

Note that even with the fix, you will not get back the same values. Your values will be clipped to the [0 1] range.

Carnë Draug <carandraug>
Group Member
Wed 23 Mar 2016 08:33:45 AM UTC, original submission:  

When running the following code, which converts rgb to ind and back to rgb, the following exception is raised:

Mrgb=ind2rgb(Mind,map)
error: ind2rgb: MAP must be a valid colormap
error: called from
    ind2x at line 37 column 5
    ind2rgb at line 49 column 10

Example code

M(:,:,1) =  [225  230  250  243   20    3  244  247  255  255
242  252  239    0  239  224   27  252  255  255
224  239   28  243  236  231  240   11  255  255
243  252   15  224   15   12  251    0  255  255
224   11  252  227    0   11  232  251    0  255
243    4  255  228   19    4  243  224    0  255

  1.  255  236  251  228  251  224  243  255    0

 19  236  255  224   27   12  251  236  255    0
  0  255  255  255  255  255  255  255  255    0
255    0    0    0    0    0    0    0    0  255];
M(:,:,2) =[255  255  255  255    0    0  255  255  255  255
255  255  255    0  255  255    0  255  255  255
255  255    0  255  255  255  255    0  255  255
255  255    0  255    0    0  255    0  255  255
255    0  255  255    0    0  255  255    0  255
255    0  255  255    0    0  255  255    0  255

  1.  255  255  255  255  255  255  255  255    0
  2.  255  255  255    0    0  255  255  255    0
  3.  255  255  255  255  255  255  255  255    0

255    0    0    0    0    0    0    0    0  255];
M(:,:,3) = [255  255  255  255    0    0  255  255  255  255
255  255  255    0    0    0    0  255  255  255
255  255    0    0    0    0    0    0  255  255
255  255    0    0    0    0    0    0  255  255
255    0    0    0    0    0    0    0    0  255
255    0    0    0    0    0    0    0    0  255

  1.    0    0    0    0    0    0    0    0    0
  2.    0    0    0    0    0    0    0    0    0
  3.    0    0    0    0    0    0    0    0    0

255    0    0    0    0    0    0    0    0  255];
[Mind map]=rgb2ind(M)
Mrgb=ind2rgb(Mind,map)

Daniel Roeske <dmjr>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dmjr (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-23 carandraug Open/ClosedOpen Closed
    2016-03-23 carandraug Item GroupSegfault, Bus Error, etc. Incorrect Result
        StatusNone Duplicate
        Dependencies- Depends on bugs #41851

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code