imread.m

John W. Eaton jwe at bevo.che.wisc.edu
Wed Jul 16 10:29:00 CDT 2008


On 15-Jul-2008, Daniel J Sebald wrote:

| Daniel J Sebald wrote:
| > On 15-Jul-2008, Thomas L. Scofield wrote:
| > 
| > | Just got your message about it being imshow.  Can it be the source of  
| > | the problem I describe here, too?
| > 
| > Yes, I think the problem is that uint8 images of size MxNx3 are not
| > displayed properly by imshow.  For example, try this:
| > 
| >  imshow (uint8 (repmat (kron ((0:255)', ones (1, 200)), [1, 1, 3])))
| > 
| > It should show a smooth black to white gradient from top to bottom,
| > but I see the attached image instead.
| 
| I haven't updated to Mercurial and the latest code yet so can't put together a patch.  But I think I see what the problem is.  Perhaps a lower level routine no longer automatically ranges the data.  This test in imshow.m is true for your example:
| 
|   elseif (size (im, 3) == 3)
|     if (ismember (class (im), {"uint8", "uint16", "double", "single"}))
|       true_color = true;
| 
| This means it is to be an rgb image in "truecolor".  In that case, scaling of data is NOT done:
| 
|   ## Scale the image to the interval [0, 1] according to display_range.
|   if (! (true_color || indexed || islogical (im)))
| 
| So, the questions are.  What does "truecolor" mean here?  Does it simply mean RGB?  Or does it mean RGB and no data scaling?  The help for imshow simply says that RGB.  If the data came from a file, I could see that no scaling should be applied.  (But that is already present as "indexed".)  But if the data comes from the command line, like John's example, I'd say no.
| 
| My thinking is that "true_color" should be removed from the scaling test above.  I don't think TrueColor images have any implicit scaling properties, just that a colormap is not used.

The following patch seems to fix the problem for me, and also improves
compatibility with regard to the way cdata is stored and clim is
computed.  But maybe I messed up something else with this change, so
it would help if people who work with images could do some testing.

Thanks,

jwe

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diffs
Url: https://www.cae.wisc.edu/pipermail/octave-maintainers/attachments/20080716/aae90f82/attachment.ksh 


More information about the Octave-maintainers mailing list