[Image-SIG] PIL: TIFF images loaded as 16 bit signed integers

Fredrik Lundh fredrik at pythonware.com
Sun Aug 1 13:14:24 CEST 2010


2010/7/6 Chris Mitchell <chris.mit7 at gmail.com>:
> I'm running into a problem where my image intensities are being loaded
> as 16 bit signed integers.  The code I'm using to open the tiff file
> is:
>
> im = Image.open(file)
> self.pixels = np.array([im.getdata()], np.uint16)
>
> the filetype is a 16bit TIFF, whose intensities load fine into ImageJ.
>  I load their intensities into a numpy 16bit array, and for the time
> being I've fixed this problem with this code:
>
> np.where(self.pixels<0, -1*self.pixels+(32768+self.pixels),self.pixels)
>
> That basically takes any negative values and compensates for the
> rollover.  Does anyone have any idea why PIL is loading my TIFF files
> as signed integers?

Could be that something goes wrong on the way to numpy.  What values
do you get from PIL's own access methods (e.g. getpixel)?

Also, what platform is this on?

</F>


More information about the Image-SIG mailing list