AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
June 2009

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2009.06.14 13:24 "Tiff 16 bit and 32 bit images", by Keshab Neupane
2009.06.14 16:50 "Re: Tiff 16 bit and 32 bit images", by Kai-uwe Behrmann
2009.06.14 23:11 "Re: Tiff 16 bit and 32 bit images", by Keshab Neupane
2009.06.14 23:48 "Re: Tiff 16 bit and 32 bit images", by Bob Friesenhahn
2009.06.15 00:00 "Re: Tiff 16 bit and 32 bit images", by Scott Ribe
2009.06.15 06:17 "Re: Tiff 16 bit and 32 bit images", by Joris Van Damme
2009.06.15 16:57 "Re: Tiff 16 bit and 32 bit images", by Chris Cox

2009.06.14 23:48 "Re: Tiff 16 bit and 32 bit images", by Bob Friesenhahn

On Sun, 14 Jun 2009, Keshab Neupane wrote:

> Hi All, Can you please look at my code and check what am I doing 
> wrong. I have to copy data from tiff 16 bit image into buffer and 
> then into destination buffer.

If you plan for your support of TIFF sample depths to be limited, then 
it seems easier for you to allocate 'buffer' as a uint16 type and add 
a necessary cast to (char *) only when passing a pointer to 
TIFFReadScanline().  Depending on how you use the data, this may offer 
performance benefits as well.  The problem you are running into is 
with basic C programming and not libtiff related.  The more complex 
your solution looks, the more likely it is to be wrong.

> Here, photometric interpretation is min-is-black, what will happen 
> if I have RGB or greyscale image i.e how do I copy data from buffer 
> to destination ?

If the image has only gray samples then it is organized as just gray 
samples.  If it is RGB, it is usually ordered RGBRGBRGB except for in 
the case of planar TIFF, in which case you need to specifically 
request the red, green, or blue planes and they look like the gray 
case.  If you need to deal with TIFF with an alpha channel, or extra 
samples, then there may be additional samples sandwiched between the 
RGB samples (e.g. RGBA).  It is also possible for extra samples to be 
included with grayscale files.

> Sometimes, SAMPLEFORMAT is not given/available, how I can decide 
> what data types are tiff image made from. I need to handle 16 bit 
> signed/unsigned and 32 bit float values !!

If sample format is not defined, then it must be unsigned integer 
data.  This should not be a problem for your code since you can 
retrieve the tags via TIFFGetFieldDefaulted() and libtiff will supply 
the default if the file does not supply a value.

> Any nice books where I can read all about tiff image format ? What 
> are the possible tiff image formats available/theoretically possible 
> ? I googled it but couldn't find any satisfactory result ?

The Encyclopedia of Graphic File Formats provides a nice overview. 
Unfortunately, the book is out of print but it is online here:

   http://www.fileformat.info/format/tiff/egff.htm

Otherwise there is the TIFF specification itself, and several Adobe 
application notes.

As far as what is available/theoretically possible, you may be 
astonished at what TIFF is capable of.  I generated some integer and 
float TIFF sample files using GraphicsMagick and made them available 
at:

   ftp://ftp.graphicsmagick.org/pub/outgoing/tiff-sample-images.tar.gz
   ftp://ftp.graphicsmagick.org/pub/outgoing/bigtiff-sample-images.tar.gz

They are intended to be used by software developers.

This is just to start since these files are all uncompressed and only 
represent one endian order, one bit order, and don't include any extra 
samples such as an alpha channel.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/