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

 
 

bug #36473: colormaps different from matlab

Submitted by:  Carnë Draug <carandraug>
Submitted on:  Tue 15 May 2012 11:12:53 AM UTC  
 
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 09 Apr 2013 10:23:29 PM UTC, 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 08 Apr 2013 10:31:48 PM UTC, comment #29:

I've attatched jetmaps.mat.zip

(file #27819)

Ben Abbott <bpabbott>
Project Member
Mon 08 Apr 2013 10:29:10 PM UTC, comment #28:

Ben,

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 05 Apr 2013 11:58:31 PM UTC, comment #27:

Attached bone.mat.zip

(file #27785)

Ben Abbott <bpabbott>
Project Member
Fri 05 Apr 2013 11:53:19 PM UTC, 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 25 Mar 2013 11:38:52 PM UTC, comment #25:

pinkmaps8.zip is attached.

(file #27689)

Ben Abbott <bpabbott>
Project Member
Mon 25 Mar 2013 11:17:20 PM UTC, 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 25 Mar 2013 06:14:55 PM UTC, comment #23:

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

(file #27683)

Ben Abbott <bpabbott>
Project Member
Mon 25 Mar 2013 05:28:56 PM UTC, 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 25 Mar 2013 03:35:39 PM UTC, comment #21:

I've zipped and attached the hotmaps.mat

(file #27678)

Ben Abbott <bpabbott>
Project Member
Mon 25 Mar 2013 03:06:54 PM UTC, 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 22 Mar 2013 01:40:32 AM UTC, comment #19:

Rik,

I've added pink200 to the mat-file

Ben

(file #27648)

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

Ben,

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 21 Mar 2013 10:32:46 PM UTC, comment #17:

RIk,

The pink-maps are attached.

(file #27647)

Ben Abbott <bpabbott>
Project Member
Thu 21 Mar 2013 09:53:58 PM UTC, 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 21 Mar 2013 02:50:26 PM UTC, comment #15:

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

http://hg.savannah.gnu.org/hgweb/octave/rev/b8a4f313e78e
http://hg.savannah.gnu.org/hgweb/octave/rev/ca395af72d88

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 19 Jun 2012 11:28:07 AM UTC, 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 19 Jun 2012 08:33:55 AM UTC, 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 19 Jun 2012 12:58:16 AM UTC, 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 17 Jun 2012 09:18:09 PM UTC, 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 17 May 2012 02:17:37 AM UTC, 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 16 May 2012 08:57:57 PM UTC, comment #9:

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

http://hg.savannah.gnu.org/hgweb/octave/rev/b9c02ee24de1
http://hg.savannah.gnu.org/hgweb/octave/rev/5f1d4def40e1

Thanks!

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

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

(file #25865)

Carnë Draug <carandraug>
Project Member
Tue 15 May 2012 10:18:59 PM UTC, 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 15 May 2012 10:07:30 PM UTC, comment #6:

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

Carnë Draug <carandraug>
Project Member
Tue 15 May 2012 09:53:04 PM UTC, 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 15 May 2012 05:02:29 PM UTC, 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 15 May 2012 04:18:21 PM UTC, 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 15 May 2012 03:35:16 PM UTC, 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.

Carnë

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

Carnë Draug <carandraug>
Project Member
Tue 15 May 2012 02:36:50 PM UTC, 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 15 May 2012 11:12:53 AM UTC, original submission:

Hi

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ë

Carnë Draug <carandraug>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

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 09 Apr 2013 10:23:29 PM UTCrik5StatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Mon 08 Apr 2013 10:31:48 PM UTCbpabbottAttached File-=>Added jetmaps.mat.zip, #27819
    Fri 05 Apr 2013 11:58:31 PM UTCbpabbottAttached File-=>Added bonemaps.mat.zip, #27785
    Mon 25 Mar 2013 11:38:52 PM UTCbpabbottAttached File-=>Added pinkmaps8.zip, #27689
    Mon 25 Mar 2013 06:14:55 PM UTCbpabbottAttached File-=>Added hotmaps8.zip, #27683
    Mon 25 Mar 2013 03:35:39 PM UTCbpabbottAttached File-=>Added hotmaps.zip, #27678
    Mon 25 Mar 2013 03:06:54 PM UTCrik5StatusFixed=>In Progress
    Fri 22 Mar 2013 01:40:32 AM UTCbpabbottAttached File-=>Added pinkmaps.zip, #27648
    Thu 21 Mar 2013 10:32:46 PM UTCbpabbottAttached File-=>Added pinkmaps.zip, #27647
    Tue 19 Jun 2012 11:28:07 AM UTCbpabbottAttached File-=>Added changeset.patch, #26061
    Tue 19 Jun 2012 08:33:55 AM UTCcarandraugAttached File-=>Added colormaps.mat, #26059
    Tue 19 Jun 2012 12:58:16 AM UTCbpabbottAttached File-=>Added changeset.patch, #26056
    Thu 17 May 2012 02:26:17 AM UTCjweOpen/ClosedClosed=>Open
    Wed 16 May 2012 08:57:57 PM UTCjweStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 15 May 2012 11:21:17 PM UTCcarandraugAttached File-=>Added colormaps.diff, #25865
    Tue 15 May 2012 09:53:04 PM UTCcarandraugAttached File-=>Added colormaps-list.diff, #25862
    Tue 15 May 2012 05:02:29 PM UTCcarandraugAttached File-=>Added colormaps-small-sizes.diff, #25860

    Back to the top


    Powered by Savane 3.1-cleanup