# [PIL] 16 / 48 bit images?

ingo ingoogni at home.nl
Thu Feb 8 14:44:27 EST 2001

```Using PIL with 16 bit greyscale images I'm struggeling a 'bit'. How does
PIL work with 16/48 bit images?

>>> import Image
>>> im=Image.open("a1.png")
>>> len(im.histogram())
256
>>>
Here I expected the result to be 65536. Is the histogram fixed to 256
levels (per band), or is the image converted to 8 bit?

When using the point() operation on a 16 bit greyscale image I get an
error, the same operation on an 8 bit image is flawless. When done to one
band of a 48 bit image all seems to be ok, bu the mode of the band is "L".
Is the band converted to 8 bit?

>>> im=Image.open("a1.png")  #16 bit greyscale
>>> im.mode
'I'
>>> mask=im.point(lambda i: i<100 and 255)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "d:\programming\python20\pil\Image.py", line 582, in point
scale, offset = _getscaleoffset(lut)
File "d:\programming\python20\pil\Image.py", line 271, in
_getscaleoffset
data = expr(_E(stub)).data
AttributeError: 'int' object has no attribute 'data'
>>>

>>> im=Image.open("a2.png")    	#8 bit greyscale
>>> im.mode
'P'
>>> mask=im.point(lambda i: i<100 and 255)
>>>

>>> im=Image.open("a3.png")    	#48 bit colour
>>> im.mode
'RGB'
>>> S=im.split()
>>> R,G,B=0,1,2
>>> S[R].mode
'L'
>>> mask=S[R].point(lambda i: i<100 and 255)
>>>

Ingo

--
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/

```