Experimental Physics and Industrial Control System
Hi Mark, all,
On Tue, Mar 20, 2012 at 8:03 AM, Mark Rivers <firstname.lastname@example.org> wrote:
> Hi Tim (and tech-talkers),
> I know you've done quite a bit with TIFF files, so I've got a question for you.
> The areaDetector NDFileTIFF plugin can write 8-bit, 16-bit and 32-bit TIFF files. All of them can be read fine by ImageJ and IDL. However, the 32-bit TIFFs cannot be read by the Python Imaging Library (PIL). But 32-bit TIFF files written by the Dectris Pilatus driver can be read by PIL.
> Do you have any idea what needs to be done to make a 32-bit TIFF readable by PIL?
Actually, I see a problem with PIL even when doing what I recommended earlier:
>>> data = open('32bit_int_1.tiff').read() # raw file read
>>> img = Image.frombuffer('I', (1024, 1024), data, 'raw', 'I')
There seems to be corrupt data in the first few pixels, as if the
offset in the file was incorrect. So, there are definitely problems
with the Python Imaging Library and 32-bit tiff files. That
"Image.frombuffer()" does work well to convert raw image data (say,
straight from AreaDetector's ArrayData PV) or from a 2D intensity
I tried the newer pylibtiff: http://code.google.com/p/pylibtiff/ and
had much better success.
>>> from libtiff import TIFF
>>> tiff_img = TIFF.open('32bit_int_1.tiff')
>>> im_array = tiff_img.read_image() # reads image to numpy array
>>> import Image
>>> im = Image.frombuffer('I', im_array.shape),
im_array.tostring()) # numpy-> image
I tried several TIFF images from Area Detectors, and they all worked
fine this way, with the arrays have the correct shape and min/max
values (comparing with IDL's read_tiff). Reading Tiff images from the
Pilatus 100K still gives the same warnings as the tiffinfo utility.
I'm not sure why the one Pilatus 32-bit TIFF could be read with PIL's
"Image.open()" while the rest could not -- the error message seems to
suggest that it couldn't even identify it as a TIFF file. But it
looks like the pylibtiff library is better at reading these TIFF
- Re: 32-bit TIFFs and PIL Timothy Madden
- 32-bit TIFFs and PIL Mark Rivers
- Navigate by Date:
Re: "Size of symbol changed" warnings building EPICS Base 188.8.131.52 Dirk Zimoch
Re: "Size of symbol changed" warnings building EPICS Base 184.108.40.206 Andrew Johnson
- Navigate by Thread:
32-bit TIFFs and PIL Mark Rivers
Re: 32-bit TIFFs and PIL Timothy Madden