examples of PIL and paletts?

Michael A. Miller mmiller3 at iupui.edu
Fri Jan 5 18:43:04 EST 2001


>>>>> "Michael" == Michael A Miller <mmiller3 at iupui.edu> writes:

    > Can anyone point me to an example of using paletts and
    > image mode 'P' with PIL?

To be more specific, I have grey scale images for which I've
calculated an equalized lut.  I'd like to view the image using
that lut, so I try this:

>>> import Image, ImagePalette, Numeric
>>> im = Image.open('lena.jpg')
>>> im.show()
>>> im2 = im.convert('P')
>>> lut = equalize(im2)
>>> p = ImagePalette.new('RGB',lut)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python1.5/site-packages/PIL/ImagePalette.py", line 57, in new
    Image.core.new_palette(mode, data)
AttributeError: new_palette


What I'm looking for is an example of how to apply a new lut to
an existing image.  Any hints?

Mike



More information about the Python-list mailing list