bugGNU Octave - Bugs: bug #44070, most colormaps return invalid...

 
 

bug #44070: most colormaps return invalid colormap when N is not class double

Submitter:  Hartmut <hardy>
Submitted:  Thu 22 Jan 2015 07:15:23 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 23 Jan 2015 04:49:11 PM UTC, comment #1: 



The problem is in Octave. Most colormaps use N when calculating the colormap and preserve its class.  In this case, N is being of class uint8, so you get a colormap of class uint8 and all values get truncated to 0 or 1. Also, a colormap must by definition be of class double.

This bug was present in the colormaps autumn, bone, cool, copper, cubehelix, gray, hsv, ocean, rainbow, spring, summer, and winter.  I have fixed this in Octave by always casting to double.  I also added a new test for all colormaps.  See http://hg.savannah.gnu.org/hgweb/octave/rev/e8e3a89fa370

I applied a fix for image package anyway http://hg.code.sf.net/p/octave/image/rev/44eedba3a2e6 so it will work for older octave versions





This problem has been fixed in the development version. The fix
will be available in the next major software release. Thank you
for your bug report.

Carnë Draug <carandraug>
Group Member
Thu 22 Jan 2015 07:15:23 PM UTC, original submission:  

The command label2rgb seems to works with some colormaps but not with others. Here is a short script to show the behavior:


clear
pkg load image

labeled =uint8([1 0 0; 0 0 2;2 2 2]);

RGB_label = label2rgb(labeled, @prism);  % works fine
RGB_label = label2rgb(labeled, @spring); % gives an error = bug?


Both colormaps are implemented, as you can see with

colormap list


This is a behavior occures with Octave 3.8.2 and the current version 2.2.2 of the image package. (In my case under Linux, but I suspect it to be the same for all OS.)

It seems that the number of distinct values in the input variable "labeled" is relevant. And also the data type uint8 (which is the normal output data type of the "labelmatrix" command.)

Hartmut <hardy>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by hardy (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
    2015-01-23 carandraug StatusNone Fixed
        Open/ClosedOpen Closed
        Release3.8.2 dev
        Summaryforge package &quot;image&quot;: &quot;label2rgb&quot; works only with some colormaps most colormaps return invalid colormap when N is not class double

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code