[SciPy-user] bug in pilutils?

Stefan van der Walt stefan at sun.ac.za
Wed Apr 25 18:54:57 EDT 2007


On Wed, Apr 25, 2007 at 02:17:29PM -0700, Yaroslav Bulatov wrote:
> In [12]: scipy.misc.fromimage(scipy.misc.toimage(20*ones((1,1))))
> Out[12]: array([[0]], dtype=uint8)
> 
> No matter what the starting array is, converting it to image and then
> back to array gives me an array of 0's, but I expect to get the
> starting array

scipy.misc.toimage tries to estimate the range of the input image.  If
you supply data that is already of dtype N.uint8 it won't, i.e.

In [9]: scipy.misc.fromimage(scipy.misc.toimage(20*ones((1,1)).astype(uint8)))
Out[9]: array([[20]], dtype=uint8)

The following also illustrates the bahaviour you are seeing:

In [15]: scipy.misc.fromimage(scipy.misc.toimage([[0,1,2]]))
Out[15]: array([[  0, 127, 255]], dtype=uint8)

Regards
Stéfan



More information about the SciPy-User mailing list