bugGNU Octave - Bugs: bug #36473, colormaps different from matlab


bug #36473: colormaps different from matlab

Submitted by:  Carnë Draug <carandraug>
Submitted on:  Tue May 15 11:12:53 2012  
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Tue Apr 9 22:23:29 2013, comment #30:

Finished the last colormap, jet, with this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/3731a1992083). Closing report.

Rik <rik5>
Project Administrator
Mon Apr 8 22:31:48 2013, comment #29:

I've attatched jetmaps.mat.zip

(file #27819)

Ben Abbott <bpabbott>
Project Member
Mon Apr 8 22:29:10 2013, comment #28:


I checked in a change for the bone map (http://hg.savannah.gnu.org/hgweb/octave/rev/328048fd43b8). Only the jet map remains to be deciphered. Can you get me the output from the following commands?

Rik <rik5>
Project Administrator
Fri Apr 5 23:58:31 2013, comment #27:

Attached bone.mat.zip

(file #27785)

Ben Abbott <bpabbott>
Project Member
Fri Apr 5 23:53:19 2013, comment #26:

I checked in a change for the pink colormap(http://hg.savannah.gnu.org/hgweb/octave/rev/7762d56dbc8a).

Only two more maps to go. Can I get the results of running the following?

Rik <rik5>
Project Administrator
Mon Mar 25 23:38:52 2013, comment #25:

pinkmaps8.zip is attached.

(file #27689)

Ben Abbott <bpabbott>
Project Member
Mon Mar 25 23:17:20 2013, comment #24:

I checked in a changeset which fixes hot.m (http://hg.savannah.gnu.org/hgweb/octave/rev/6964e6b92fc1). Now back to pink. I suspect Matlab is doing the same thing with something modulo 8. Can you upload the results of the following?

Rik <rik5>
Project Administrator
Mon Mar 25 18:14:55 2013, comment #23:

I've added those maps to the attached zip archive.

(file #27683)

Ben Abbott <bpabbott>
Project Member
Mon Mar 25 17:28:56 2013, comment #22:

Matlab is doing something funny, occasionally, for the hot colormap. I'm trying to decide if it is something that is cyclical in 4 or in 8. Could I get the following code run and attached to this report?

Rik <rik5>
Project Administrator
Mon Mar 25 15:35:39 2013, comment #21:

I've zipped and attached the hotmaps.mat

(file #27678)

Ben Abbott <bpabbott>
Project Member
Mon Mar 25 15:06:54 2013, comment #20:

I have a cset ready for the hot colormap. I need a bit more data to verify the result, which seem different for n<64. Can someone run the following in Matlab and upload the results?

Rik <rik5>
Project Administrator
Fri Mar 22 01:40:32 2013, comment #19:


I've added pink200 to the mat-file


(file #27648)

Ben Abbott <bpabbott>
Project Member
Thu Mar 21 22:55:52 2013, comment #18:


Different results than what I expected, particularly for pink73. Does pink(200) for you match the pink200 that Carne uploaded earlier? I'm wondering if there are different versions of Matlab at play and whether there might be any differences due to that. It seems unlikely, given that these colormaps have been in Matlab for a long time. But I thought I would check because otherwise I have to figure out a different scheme for pink().

Rik <rik5>
Project Administrator
Thu Mar 21 22:32:46 2013, comment #17:


The pink-maps are attached.

(file #27647)

Ben Abbott <bpabbott>
Project Member
Thu Mar 21 21:53:58 2013, comment #16:

I've got a changeset for pink() which works for all but pink(2). In order to debug it could someone upload a file with the Matlab results for

Rik <rik5>
Project Administrator
Thu Mar 21 14:50:26 2013, comment #15:

I checked in two changesets that make copper and hsv colormaps compatible with Matlab:


This leaves bone, hot, jet, and pink. The work by Ben suggests that jet is a very complicated beast and maybe we can't actually get to identical results for that map.

Rik <rik5>
Project Administrator
Tue Jun 19 11:28:07 2012, comment #14:

Rather than trying to precisely implement ML's versions, what about a simple solution the new version I've attached ... or are the current implementations ok as they are?

(file #26061)

Ben Abbott <bpabbott>
Project Member
Tue Jun 19 08:33:55 2012, comment #13:

I don't know how to fix it on a more elegant way either. At the time I got the results from matlab and thought I could make sense of them.

I have attached a .mat file with the matlab results for colormaps that are still incompatible (they are bone, copper, hot, hsv, jet and pink) of size 2, 10, 64, 200 and 1000.

(file #26059)

Carnë Draug <carandraug>
Project Member
Tue Jun 19 00:58:16 2012, comment #12:

I've attached an ugly changeset. Is strict compatibility needed. If not, I'd prefer a more elegant solution.

(file #26056)

Ben Abbott <bpabbott>
Project Member
Sun Jun 17 21:18:09 2012, comment #11:

I took a look at how ML behaves.

For jet(n) with n = 16, 32, or 64, the code below works.

However, something very different is being done for other values of n. Some examples are below. The "# m" comments indicate when the value coincides with cmap(m).

I don't recognize what ML is doing here.

Ben Abbott <bpabbott>
Project Member
Thu May 17 02:17:37 2012, comment #10:

Don't close this bug just yet. The changeset I sent only fix the bug for length =< 1 and implement a list of colormaps (which came up in the discussion but was not originally related to the bug report).

The original bug, still exists. It's not fixed yet. I'll need some time to understand how the hell do they build their colormaps. I don't understand how is it acceptable for such thing to not be properly documented...

Carnë Draug <carandraug>
Project Member
Wed May 16 20:57:57 2012, comment #9:

I checked in the changes as separate changesets with a few minor edits.



John W. Eaton <jwe>
Project Administrator
Tue May 15 23:21:17 2012, comment #8:

Done. Both commits in a changeset and a NEWS entry.

(file #25865)

Carnë Draug <carandraug>
Project Member
Tue May 15 22:18:59 2012, comment #7:

Sure, you could add a NEWS entry for this change.

Could you also merge all the changes into one changeset?

John W. Eaton <jwe>
Project Administrator
Tue May 15 22:07:30 2012, comment #6:

I remember now, should have I added a NEWS entry for the new options to colormap?

Carnë Draug <carandraug>
Project Member
Tue May 15 21:53:04 2012, comment #5:

This second changeset (it applies after the previous), implements the list, register and unregister options to colormap. I have also made the colormaps functions register with with PKG_ADD.

I don't think that contrast is really a colormap so I didn't add it.

(file #25862)

Carnë Draug <carandraug>
Project Member
Tue May 15 17:02:29 2012, comment #4:

I attahced the first changeset. I won't have time to look more into this today. Some of the current colormaps behave bad when size is < 1 (sometimes errors, others NaN, etc). Others return an empty matrix 0x0 (matlab returns 0x3). This changeset fixes those problems.

It also makes sure that when size is 1 the values returned are the same as matlab.

(file #25860)

Carnë Draug <carandraug>
Project Member
Tue May 15 16:18:21 2012, comment #3:

I'd rather not hard code a list of colormaps if possible.

How about using a persistent cellstr list in the colormap function, then
allow the list to be displayed with

and added to with

Then you could add lines like

to all the colormap functions and the documentation just needs to say
"colormap ("list") displays a list of all available colormaps."

The docstrings for all the available colormap functions (with
descriptions) should be grouped together in the manual, so I
don't think it is necessary to provide a list describing them in the
colormap function docstring.

John W. Eaton <jwe>
Project Administrator
Tue May 15 15:35:16 2012, comment #2:

I don't think their contents are listed anywhere. I'll have to deduce it myself, can't be that complicated. I just wanted to know if I should even bother in the first place.

The only one that seems to be explained is `hsv' that according to mathworks site says hsv(m) is the same as hsv2rgb([h ones(m,2)]) where h is the linear ramp, h = (0:m–1)'/m.

Also, it has been asked on the mailing list to have a way to list all available colormaps[1]. Other than having their list hardcoded somewhere I don't see how to do it. Would it be acceptable to have colormap ("list") return such a list? If not, can I submit a patch that at least lists them on the documentation of colormap? In the case of colormap ("list"), would there be a way to make it increase the list. For example, the image package implementing extra colormaps and have PKG_ADD add it.


[1] http://octave.1599824.n4.nabble.com/list-available-colomaps-td4366121.html

Carnë Draug <carandraug>
Project Member
Tue May 15 14:36:50 2012, comment #1:

It would be nice to be compatible, but are the contents of the colormaps precisely documented somewhere?

If not, then I suppose you could try to make Octave compatible by writing a test script and having someone run that in Matlab for you, then attempt to deduce the algorithm used to generate the colormap values.

What you should defintely NOT do is read (or have someone read for you) the Matlab colormap functions and base your implementation on that.

John W. Eaton <jwe>
Project Administrator
Tue May 15 11:12:53 2012, original submission:


I noticed that the colormaps we have in Octave are a bit different from matlab. I have noticed this when trying to implement imhist and kept getting different results from matlab, then I noticed that after indexing my images were different.

For example:

I didn't try every single colormap as I don't have matlab and didn't want to bother anyone too much but at least jet and hot are different.

Is this considered a bug? Should I even try to fix it?

Carnë Draug <carandraug>
Project Member


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

Attach File(s):

Attached Files
file #27819:  jetmaps.mat.zip added by bpabbott (3kB - application/zip)
file #27785:  bonemaps.mat.zip added by bpabbott (12kB - application/zip)
file #27689:  pinkmaps8.zip added by bpabbott (15kB - application/zip)
file #27683:  hotmaps8.zip added by bpabbott (3kB - application/zip)
file #27678:  hotmaps.zip added by bpabbott (867B - application/zip)
file #27648:  pinkmaps.zip added by bpabbott (6kB - application/zip)
file #27647:  pinkmaps.zip added by bpabbott (2kB - application/zip)
file #26061:  changeset.patch added by bpabbott (2kB - application/octet-stream - simple implementation)
file #26059:  colormaps.mat added by carandraug (180kB - application/octet-stream - colormap results from matlab)
file #26056:  changeset.patch added by bpabbott (4kB - application/octet-stream)
file #25865:  colormaps.diff added by carandraug (18kB - text/x-diff)
file #25862:  colormaps-list.diff added by carandraug (10kB - text/x-diff)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by bpabbott (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by carandraug (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 19 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue Apr 9 22:23:29 2013rik5StatusIn Progress=>Fixed
    Mon Apr 8 22:31:48 2013bpabbottAttached File-=>Added jetmaps.mat.zip, #27819
    Fri Apr 5 23:58:31 2013bpabbottAttached File-=>Added bonemaps.mat.zip, #27785
    Mon Mar 25 23:38:52 2013bpabbottAttached File-=>Added pinkmaps8.zip, #27689
    Mon Mar 25 18:14:55 2013bpabbottAttached File-=>Added hotmaps8.zip, #27683
    Mon Mar 25 15:35:39 2013bpabbottAttached File-=>Added hotmaps.zip, #27678
    Mon Mar 25 15:06:54 2013rik5StatusFixed=>In Progress
    Fri Mar 22 01:40:32 2013bpabbottAttached File-=>Added pinkmaps.zip, #27648
    Thu Mar 21 22:32:46 2013bpabbottAttached File-=>Added pinkmaps.zip, #27647
    Tue Jun 19 11:28:07 2012bpabbottAttached File-=>Added changeset.patch, #26061
    Tue Jun 19 08:33:55 2012carandraugAttached File-=>Added colormaps.mat, #26059
    Tue Jun 19 00:58:16 2012bpabbottAttached File-=>Added changeset.patch, #26056
    Thu May 17 02:26:17 2012jweOpen/ClosedClosed=>Open
    Wed May 16 20:57:57 2012jweStatusNone=>Fixed
    Tue May 15 23:21:17 2012carandraugAttached File-=>Added colormaps.diff, #25865
    Tue May 15 21:53:04 2012carandraugAttached File-=>Added colormaps-list.diff, #25862
    Tue May 15 17:02:29 2012carandraugAttached File-=>Added colormaps-small-sizes.diff, #25860

    Back to the top

    Powered by Savane 3.1-cleanup1