[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Colour scaling in imshow
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: Colour scaling in imshow |
Date: |
Thu, 20 Jan 2011 01:15:56 -0600 |
2011/1/17 John W. Eaton <address@hidden>:
> On 17-Jan-2011, Jordi Gutiérrez Hermoso wrote:
>
> | 2011/1/16 John W. Eaton <address@hidden>:
> | > On 16-Jan-2011, Jordi Gutiérrez Hermoso wrote:
> | >
> | > | There's currently a bug in imshow where
> | > |
> | > | x =rand(100:
> | > | imshow(x);
> | > | figure;
> | > | imshow(x,[0,255]);
> | > |
> | > | produces two identical images, whereas the second one should be almost
> | > | black. Attached is a patch that seems to fix this.
> | > Does Matlab set clim to [0, 1] for this case? If not, then this is
> | > not the right fix.
> | Asking around in the ##matlab channel in IRC, it appears that imshow
> | does indeed set the clim property of the parent axes object to [0,1].
[snip]
> | Can someone with Matlab access please confirm?
>
> >> version
>
> ans =
>
> 7.10.0.499 (R2010a)
>
> >> x = rand (100);
> >> h = imshow (x);
> >> get (h, 'type')
>
> ans =
>
> image
>
> >> image_clim = get (h, 'clim')
>
> image_clim =
>
> on
>
> >> axes_clim = get (gca, 'clim')
>
> axes_clim =
>
> 0 1
>
> >> figure
> >> h = imshow (x, [0, 255]);
> >> get (h, 'type')
>
> ans =
>
> image
>
> >> image_clim = get (h, 'clim')
>
> image_clim =
>
> on
>
> >> axes_clim = get (gca, 'clim')
>
> axes_clim =
>
> 0 255
Thanks for testing. Attached is a patch that replicates at least this
behaviour, but I'm pretty sure it has other problems. Now I've run
into a different problem, an annoying Matlabism.
If you try to do imshow on an ordinary double matrix type, Matlab
assumes you intended to use the [0,1] range whereas Octave assumes you
wanted the range from the highest to the lowest element of your
matrix. The result is that Octave by default always plots something
visible if your matrix is double, whereas Matlab may plot something
completely white if your matrix mostly has elements greater than 1.
I don't like what Matlab does here; I think Octave's way is better.
Can someone convince me otherwise?
On another note, what imshow and image do about reversing the ydir
property... and going as far as to have to explain this odd behaviour
in image's docstring... shouldn't it be the image that's reversed, not
the y axis?
- Jordi G. H.
imshow.patch
Description: Text Data
- Colour scaling in imshow, Jordi Gutiérrez Hermoso, 2011/01/16
- Colour scaling in imshow, John W. Eaton, 2011/01/16
- Re: Colour scaling in imshow, Jordi Gutiérrez Hermoso, 2011/01/17
- Re: Colour scaling in imshow, John W. Eaton, 2011/01/17
- Re: Colour scaling in imshow,
Jordi Gutiérrez Hermoso <=
- Re: Colour scaling in imshow, Jordi Gutiérrez Hermoso, 2011/01/20
- Re: Colour scaling in imshow, Søren Hauberg, 2011/01/20
- Re: Colour scaling in imshow, John W. Eaton, 2011/01/20
- Re: Colour scaling in imshow, Jordi Gutiérrez Hermoso, 2011/01/21
- Re: Colour scaling in imshow, John W. Eaton, 2011/01/21