bugGNU Octave - Bugs: bug #49009, wrong colors in the default image


bug #49009: wrong colors in the default image

Submitted by:  Pantxo Diribarne <pantxo>
Submitted on:  Mon 05 Sep 2016 12:48:55 PM UTC  
Category:  Plotting Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

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


( Jump to the original submission)

Wed 21 Sep 2016 04:13:19 PM UTC, comment #16: 

I fine with keeping the high level behavior for this case. Thanks

Pantxo Diribarne <pantxo>
Project Member
Wed 21 Sep 2016 04:10:43 PM UTC, comment #15: 

For Octave

octave:1> image
octave:2> get (gca, 'ydir')
ans = reverse

So Octave is Matlab-incompatible here, but I really don't see it making a big difference.  I vote for leaving it the way it is and if someone is really interested in this little discrepancy they will file a bug report about it.

Rik <rik5>
Project Administrator
Wed 21 Sep 2016 03:52:02 PM UTC, comment #14: 

Sorry if I was unclear. Yes, the default image in Matlab appears upside down.

>> close all
>> image
>> get (gca, 'Ydir')

ans =


>> image(rand(8))
>> get (gca, 'Ydir')

ans =


I don't think we need to reproduce this behavior as it's slightly odd; I was just pointing it out.



Guillaume <gyom>
Wed 21 Sep 2016 03:27:15 PM UTC, comment #13: 

Pantxo had the same question I did.

Actual test code to run in Matlab

close all
get (gca, 'Ydir')

Rik <rik5>
Project Administrator
Wed 21 Sep 2016 02:13:24 PM UTC, comment #12: 

Ok, since the no argument call is not mentioned in ML doc, it is hard to decide wether it leads to low (no change in default axes properties) or high level form of the image function.
They even state that providing image data in the form of prop(cdata)/value pairs is how you switch to the low level form, which is not what we do here.
Does the default ML image show up upside down?

Pantxo Diribarne <pantxo>
Project Member
Wed 21 Sep 2016 09:17:31 AM UTC, comment #11: 

I actually like it - well done!

If you want to mimic Matlab behavior, this default image should also be displayed when imagesc() is called. It also seems that when the default image is displayed, the default value of the 'YDir' property is 'normal' instead of 'reverse' (with the effect that the logo appears upside down).

Guillaume <gyom>
Wed 21 Sep 2016 03:20:14 AM UTC, comment #10: 
Rik <rik5>
Project Administrator
Tue 20 Sep 2016 08:43:24 PM UTC, comment #9: 

I attached take #3, with "GNU Octave" written in the background (anti aliasing enabled). I don't like the text only version.

Pantxo Diribarne <pantxo>
Project Member
Tue 20 Sep 2016 05:02:55 PM UTC, comment #8: 

Pantxo, Guillaume: What do you guys think?  Do you like the text or sombrero #2?  It doesn't need to be visually perfect since it won't get invoked that often, but I'd like to have something in place for the 4.2 release.

Rik <rik5>
Project Administrator
Tue 20 Sep 2016 05:00:37 PM UTC, comment #7: 

I made an attempt at just displaying "OCTAVE".  I disable anti-aliasing since that would have introduced strange colors.  It looks okay, but not amazing.  See attached defimage.png.

Rik <rik5>
Project Administrator
Tue 20 Sep 2016 10:28:11 AM UTC, comment #6: 

Yes, the only remaining discrepancy would then be that the default image would be a 64-by-64-by-3 array instead of a 64-by-64 matrix.

Then we could at some point have users reporting that

him = image ();
him2 = ind2rgb (get (him, "cdata"));

doesn't work, but this is probably acceptable (even though I hanppen to like the last version of the sombrero image :-)).

Pantxo Diribarne <pantxo>
Project Member
Tue 20 Sep 2016 09:38:25 AM UTC, comment #5: 

From the Matlab documentation:


This property [CDataMapping] has no effect if CData is a 3-D array defining true colors.

>> figure,h=image(rand(16,16));get(h,'CDataMapping')
ans = direct
>> figure,h=image(rand(16,16,3));get(h,'CDataMapping')
ans = direct

so maybe that's still an option?

Guillaume <gyom>
Mon 19 Sep 2016 11:08:39 AM UTC, comment #4: 

We generally try to make default properties the same as in ML. The constraints is thus that the default image must be an indexed image because by default, "cdatamapping" must be "direct", hence the discussion.

Pantxo Diribarne <pantxo>
Project Member
Mon 19 Sep 2016 10:02:35 AM UTC, comment #3: 

What about storing the Octave logo in RGB in octave-default-image.h, so that it does not rely on any colormap?


If we want the same behavior than Matlab, this image should be displayed by default with image() and imagesc().

Guillaume <gyom>
Sun 18 Sep 2016 08:41:10 PM UTC, comment #2: 

Yes I also liked the Octave logo, even though the green background was still really ugly.
The "sombrero" is a second nice Octave trademark, and it now happens to be drawn using "viridis" colormap by default.

>> Is there a way to get a white background ...

Not that I know of, and unless it is a documented ML feature, IMHO if NANs or out of range indices accidentally produce white pixels we should not use this hacky trick.
FWIW according to this (not so recent) SO thread [1] ML displays the first color in the cmap when it finds NaNs.

Did you try to change the background color (it is easy using the provided script)? I attached another version of the patch with a light blue background.

>> Maybe we should have something completely different, like the letters for "O C T A V E" on a dark background.

I don't expect pixelated characters (the image is only 64 pixels wide) to be very nice, did you try it out?

[1] http://stackoverflow.com/questions/14933039/matlab-imagesc-plotting-nan-values

(file #38544)

Pantxo Diribarne <pantxo>
Project Member
Sun 18 Sep 2016 01:24:39 AM UTC, comment #1: 

I liked having the Octave logo be the default image, but it doesn't seem possible to preserve that if there is no color orange in the viridis colormap.

I tried your patch, but I don't like the ugly yellow background it displays.  Is there a way to get a white background so it looks more like the results of executing


I tried replacing the value of 64 with NaN in Octave, but that produces black rather than white.

Maybe we should have something completely different, like the letters for "O C T A V E" on a dark background.

Rik <rik5>
Project Administrator
Mon 05 Sep 2016 12:48:55 PM UTC, original submission:  

Now that "viridis" is the default color map, the default image, which is supposed to represent the Octave logo, is not indexed correctly (hence the "regression" tag). Actually it is not possible to represent part of the logo colors with "viridis" which has no shade of orange.

I propose to use a sombrero instead of the logo. The advantage is that we wouldn't need any external tool to produce the image header file (the current image was dithered using Gimp).
I used the attached script to produce a new octave-default-image.h header file. I also attached a patch.

Pantxo Diribarne <pantxo>
Project Member


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

Attach Files:

Attached Files
file #38579:  def_image3.patch added by pantxo (26KiB - text/x-diff)
file #38570:  defimage.png added by rik5 (12KiB - image/png)
file #38544:  def_image2.patch added by pantxo (26KiB - text/x-diff)
file #38431:  def_image.patch added by pantxo (27KiB - text/x-diff)
file #38432:  build_default_image.m added by pantxo (3KiB - text/x-objcsrc)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Submitted the item)

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

    Only project members can vote.




    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-21 rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2016-09-20 pantxo Attached File- => Added def_image3.patch, #38579
    2016-09-20 rik5 Attached File- => Added defimage.png, #38570
    2016-09-18 pantxo Attached File- => Added def_image2.patch, #38544
    2016-09-05 pantxo Attached File- => Added def_image.patch, #38431
        Attached File- => Added build_default_image.m, #38432

    Back to the top

    Powered by Savane 3.5