[SciPy-User] Trying to use PIL and numpy

alan@ajackso... alan@ajackso...
Mon Jan 11 17:22:54 CST 2010

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')

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

| Alan K. Jackson            | To see a World in a Grain of Sand      |
| alan@ajackson.org          | And a Heaven in a Wild Flower,         |
| www.ajackson.org           | Hold Infinity in the palm of your hand |
| Houston, Texas             | And Eternity in an hour. - Blake       |

More information about the SciPy-User mailing list