On Thu, May 6, 2010 at 10:18 AM, Antony Lee <[email protected]> wrote:
> asarray (and there's no copy) works too, so my question now is rather, why
> does imshow cast (I suppose that's what it does) 32bit arrays but not 16bit
> ones?
> Thanks for your help.
> Antony
It turns out that this is not a 16bit-32bit issue.
I think the culprit is how overflow is handled fro numpy integers.
For example,
im1 = imshow(np.loadtxt("dump", dtype=np.int16))
vmin, vmax = im1.norm.vmin, im1.norm.vmax
print vmax, vmin
print type(vmax), type(vmin)
print vmax - vmin
gives
30172 -32082
<type 'numpy.int16'> <type 'numpy.int16'>
-3282
And the normalization is incorrect.
For a workaround, try something like below.
im1 = imshow(np.loadtxt("dump", dtype=np.int16))
im1.set_clim(map(float, im1.get_clim()))
For how to fix this, I'm not quite clear what is the best way.
My inclination is to cast the min, max to float by default, i.e.,
in Normalize.autoscale and Normalizr.autoscale_None (in colors.py),
change ma.minimum(A) to float(ma.minimum(A)).
but I'll leave it to other developers. Just in case, I filed a bug.
http://sourceforge.net/tracker/?func=detail&aid=2997687&group_id=80706&atid=560720
Regards,
-JJ
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users