[Image-SIG] 16bit to 8bit conversion with a lut

Lourette, Richard W - SSD RICHARD.LOURETTE at itt.com
Wed Feb 7 22:01:16 CET 2007

Here is the code that I am using to perform a look up table conversion
from 16 bit imagery to 8 bit imagery.

tif_image = "in.tif"	#16 bit tiff image

# create 65536 entry lut. All 255s for demonstration purposes
lut = []
lut = [255] * 65536
print len(lut)	# 65536, to make sure it is the right length

im1 = Image.open(tif_image)
print im1.mode	# "I;16"

im2 = im1.point(lut, "L")
print "done"

When I run this, I get the following error:

Unhandled exception while debugging...
Traceback (most recent call last):
  File "D:\Projects\Stare Python Development\ProcessImage.py", line 34,
in ?
    im2 = im1.point(lut, "L")
  File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1109, in point
    return self._new(self.im.point(lut, mode))
ValueError: wrong number of lut entries

I would rather not have to iterate through all the pixels with a loop
since the images I am working with are 11Mpixels in size.

I am running PIL 1.1.6


This e-mail and any files transmitted with it are proprietary and intended solely
for the use of the individual or entity to whom they are addressed. If you have
received this e-mail in error please notify the sender. Please note that any views
or opinions presented in this e-mail are solely those of the author and do not
necessarily represent those of ITT, Inc. The recipient should check
this e-mail and any attachments for the presence of viruses. ITT accepts
no liability for any damage caused by any virus transmitted by this e-mail.

More information about the Image-SIG mailing list