bugGNU Octave - Bugs: bug #52599, gnuplot shows shaded images with...

 
 

bug #52599: gnuplot shows shaded images with imshow

Submitter:  Francesco Potortì <pot>
Submitted:  Wed 06 Dec 2017 01:42:45 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.2.1 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 21 Aug 2018 06:46:53 AM UTC, comment #14: 
Shane <sffc>
Mon 20 Aug 2018 05:18:14 PM UTC, comment #13: 

Shane / Dan - it would be very helpful if you would file a new bug report about this issue instead of continuing to comment on a closed 8-month-old bug report.

Mike Miller <mtmiller>
Group Member
Mon 20 Aug 2018 07:28:03 AM UTC, comment #12: 

Sure.  Here is a session:


$ gnuplot --version
gnuplot 5.0 patchlevel 2
$ ./run-octave --no-gui
GNU Octave, version 4.2.2
...
octave:1> graphics_toolkit fltk; figure(); imshow(imread("~/mandrill.png"));
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
octave:2> graphics_toolkit gnuplot; figure(); imshow(imread("~/mandrill.png"));
octave:3> exit


Screenshot of the figures: https://snag.gy/ljNxYJ.jpg

The file mandrill.png is a standard sample image from here: http://pngnq.sourceforge.net/pngnqsamples.html

This is with an unpatched Octave built from source on GNU/Linux from the tag "release-4-2-2".  All other packages are installed from the system repositories (CentOS 7).

Shane <sffc>
Mon 20 Aug 2018 04:51:18 AM UTC, comment #11: 

Can you give an example and some screen shots?  Include a screenshot of FLTK result for the same commands if possible, for comparison.  For example,


octave:1> colormap(hot)
octave:2> image(triu(ones(256))'*triu(ones(256)))
[screen capture here]
octave:3> colormap(hot(256))
[screen capture here]


See attached PNG examples, for development version and gnuplot 5.3 patchlevel 0.

The gnuplot change was in version 5.2 (from NEWS):


New features introduced to 5.2 in patchlevel releases
=====================================================
[snip]
* NEW command "set rgbmax <value>" controls interpretation of input RGB values


and it would be a simple matter to put a conditional statement in place to determine if


-    retval = 1 + cdata * (cmap_sz-1)/255;


scaling should be done, but I want to make sure to understand what exactly the scaling problem is.

Dan Sebald <sebald>
Sun 19 Aug 2018 12:52:53 AM UTC, comment #10: 

Hi,

I'm using gnuplot 5.0 and Octave 4.2.2.

imshow was working fine before this change.  However, images plotted with imshow or imagesc appear too bright.  I've determined that if I reverse the Dan's patch to _gnuplot_draw_axes_.m, images plot correctly.

I have not tested whether this problem still exists in Octave 4.4.

Shane <sffc>
Thu 07 Dec 2017 06:48:39 PM UTC, comment #9: 

I pushed Dan's patch here: http://hg.savannah.gnu.org/hgweb/octave/rev/d8626fd6bb36.

Closing this report and #52401.

Rik <rik5>
Group administrator
Thu 07 Dec 2017 12:11:03 PM UTC, comment #8: 

Thank you, your patch fixes my test case.

By the way, any hope of fixing bug #49140 (duplicate of bug #41584)?

Francesco Potortì <pot>
Thu 07 Dec 2017 09:55:43 AM UTC, comment #7: 

Yes, let's do that.  I built gnuplot 5.0.3 and tested "rundemos draw" with the patch applied and see no differences.  So we don't need any type of conditional test on gnuplot version for this change.

Dan Sebald <sebald>
Thu 07 Dec 2017 12:56:27 AM UTC, comment #6: 

@Dan: So would you like me to apply your cset from comment #1 and then close this bug and bug #52401?

Rik <rik5>
Group administrator
Wed 06 Dec 2017 11:05:12 PM UTC, comment #5: 

Yeah this could be a case of a change in gnuplot.  I'm using the development version 5.3.0.

There is this other bug report from a month or so ago:

https://savannah.gnu.org/bugs/?52401

at which point I looked into what was going on with gnuplot.  gnuplot made a change without too much discussion about syntax.  Typically gnuplot is very conservative about changing syntax.  Rather than autoscaling to determine range, gnuplot now has this "rgbmax" variable:


gnuplot> help rgbmax
 Syntax:
      set rgbmax {1.0 | 255}
      unset rgbmax
 The red/green/blue color components of an rgbimage plot are by default
 interpreted as integers in the range [0:255].  `set rgbmax 1.0` tells the
 program that data values used to generate the color components of a plot
 with `rgbimage` or `rgbalpha` are floating point values in the range [0:1].
 `unset rgbmax` returns to the default integer range [0:255].


If anything, I wish the syntax change would have been "set rgbrange [0:255]" which would have been fully consistent with other range settings in gnuplot.

Nonetheless, gnuplot now has 0 to 255 as the default range and that is probably why this comes up now.

The good thing is that I just went back to the example of https://savannah.gnu.org/bugs/?52401 and changing the color map size to 256


octave:1> I=uint8(zeros(16,16,3));
octave:2> for i=1:16; I(i,:,1)=i*16-1; end
octave:3> for i=1:16; I(:,i,2)=i*16-1; end
octave:4> for i=1:16; I(:,i,3)=[i-1:15,0:i-2]*16+15; end
octave:5> imshow(I)
octave:6> colormap(jet(256))


appears to correct the image darkness.  So, I'd say if the changeset has no affect on your result with gnuplot 5.0.3 (because that is using autoscaling), then it would be a good fix for the issue without using gnuplot's new "rgbmax" syntax.  We could then close this bug report and https://savannah.gnu.org/bugs/?52401

Dan Sebald <sebald>
Wed 06 Dec 2017 10:33:14 PM UTC, comment #4: 

Size of colormap is 64x3.  I tried changing it with


colormap (jet (128))


after the plot had been created but that also didn't affect anything.

This is with gnuplot 5.0.3.

Rik <rik5>
Group administrator
Wed 06 Dec 2017 10:24:44 PM UTC, comment #3: 

Hmm.  What are you seeing for the size of your colormap?  Is that being set anywhere in your .octaverc?


octave:8> size(colormap)
ans =

   64    3


It's the fact that 64 doesn't file 2^8 that causes the problem.

Dan Sebald <sebald>
Wed 06 Dec 2017 10:15:36 PM UTC, comment #2: 

I used


close all;
graphics_toolkit fltk; figure (); imshow(double(imread('legend.png')));
graphics_toolkit gnuplot; figure(); imshow(double(imread('legend.png')));


to test, but both images seem the same.  This is before applying the patch in comment #1.  Is there a different test to try?

Rik <rik5>
Group administrator
Wed 06 Dec 2017 08:28:44 PM UTC, comment #1: 

Try the attached patch.

The image you are seeing is range 0-63 for 8-bit image, which naturally comes out darker.  I can't recall why I would have scaled the true-color data to the range of the color map for Truecolor data.  gnuplot does have a means of generating images through a color map (and I'm sure that's what was on my mind at the time), but that's not pertinent to 3-component data.  In any case, I don't see any adverse effects in "rundemos draw" with the attached patch.

(file #42585)

Dan Sebald <sebald>
Wed 06 Dec 2017 01:42:45 PM UTC, original submission:  

After applying the patch for bug #52589 (have not tried without the patch) gnuplot shows a shaded image when using imshow on a png image containing only primary saturated colours.

THe following works well with the attached file


close all; graphics_toolkit fltk; imshow(double(imread('path2017/legend.png')));


If you try using gnuplot rather than fltk, you see a shaded image.

By the way, note that I force the output of imread to double because of bug #49140.

Francesco Potortì <pot>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #42583:  legend.png added by pot (1KiB - image/png - contains only primary saturated colours)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by sffc (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by sebald (Updated the item)
  • -email is unavailable- added by pot (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-20 mtmiller Carbon-CopyRemoved 80942 -
    2017-12-07 rik5 StatusWorks For Me Fixed
        Open/ClosedOpen Closed
    2017-12-06 rik5 StatusNone Works For Me
    2017-12-06 sebald Attached File- Added octave-gnuplot_tk_truecolor_do_no_scale-djs2017dec06.patch, #42585
    2017-12-06 pot Attached File- Added legend.png, #42583

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code