2007.08.20 01:34 "[Tiff] can libtiff deal with this file? [re-sent]", by Abraham D. Smith

2007.08.20 18:25 "Re: [Tiff] can libtiff deal with this file? [re-sent]", by Craig Bruce

I have hundreds of gigabytes of microscope images which libTiff cannot seem to handle properly. Indeed, the only program on Linux which can seem to handle these files is the NIH's ImageJ. Every libtiff-based image viewer seems to truncate the brightness.

The problem isn't with LibTiff per se. The problem is that the TIFF images really aren't encoded properly. The TIFF tags indicate that they are 16-bit grayscale, whereas they are actually 14-bit grayscale images. As such, the ImageMagick display is correct and ImageJ is showing a (perhaps unauthorized) constrast stretching.

The correct way to encode these images would be to scale the samples up to 16 bits or to encode the image using 14 physical bits. The latter approach, however, probably isn't compatible with any existing software.

Other approaches would be to use MinSampleValue/MaxSampleValue or SMinSampleValue/SMaxSampleValue tags. The former isn't supposed to be used in this way, but we have customers who do this, so I check if the max value is one less than a power of 2 and if so, I use it as the physical range limit. The description of SMaxSampleValue in the 6.0 spec doesn't disallow this usage (though it's probably inteded to have the same semantics as MaxSampleValue).

--------------------------+----------------------+--------------------------
Dr. Craig S. Bruce        | Ph 819-771-8303 x205 |             CubeWerx Inc.
Senior Software Developer |   Fax 819-771-8388   |  Gatineau, Québec, Canada
csbruce@cubewerx.com      |  http://csbruce.com/ |  http://www.cubewerx.com/
--------------------------+----------------------+--------------------------

       "Did you ever notice that 'love' spelled backwards is 'evil'?
              Well, not exactly, but it's still pretty scary."