[SciPy-User] Trying to use PIL and numpy

Jim Vickroy Jim.Vickroy@noaa....
Tue Jan 12 09:27:53 CST 2010


alan@ajackson.org wrote:
> I'm having some issues trying to use PIL and numpy (for the first time).
> It's probably something simple, it usually is.
>
> When I run the following, the output is all buggered up. It looks like
> the array indicies got switched about somewhere.
>
> import Image
> im = Image.open('test.ppm')
> im2 = im.convert(mode='F')
>
> a = np.asarray(im2)
> imback2 = Image.fromarray(a)
>
> imback = imback2.convert(mode='RGB')
> imback.save('testout.png')
>
> I tried removing bits, and it is the asarray -> fromarray sequence that
> messes stuff up.
>
> I'm running Karmic Koala with
> Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) 
> numpy 1.3.0
> Image 1.1.6
>
>
>   
I believe there is a logic error in the PIL 1.1.6 fromarray() procedure 
(see 
http://mail.scipy.org/pipermail/numpy-discussion/2006-December/024903.html) 
that may be relevant.
Try explicitly specifying the mode parameter in the fromarray(...) call.
 -- jv
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100112/fca74480/attachment.html 


More information about the SciPy-User mailing list