[SciPy-user] pilutil toimage

Addison, Jason JADDISON at SYSTEMS.TEXTRON.com
Sun May 16 22:29:30 CDT 2004


I'm trying to generate an image from a 2D array and a colormap.

Here is a simple example:

# python code <><><><><><><><><><><><><><><>

c0 = array([[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2]])

icm = array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

c0_im = toimage(c0, pal=icm)

c0_im.save('c0.png')

# python code <><><><><><><><><><><><><><><>
# Fedora Core 1
# python version 2.3.3
# scipy version 0.3
# Numeric 23.1
# PIL 1.1.4

But, I always get a grey scale image. I think that I should 
get 3 pixel by 4 pixel with the first row red, then green, 
then blue, but I get black, grey and white.

What am I missing? 

Does anyone have some examples of turning 2D arrays into 
color graphics files?

Thank you,
Jason



More information about the SciPy-user mailing list