2004.05.24 22:39 "[Tiff] read and write stacks of image", by Penn Shan

2004.05.25 20:13 "Re: [Tiff] read and write stacks of image", by Frank Warmerdam

I met a problem in reading and writing stacks of image in TIFF, for example 512x512x10. Using my own function, I was able to write the whole data into a long 1-D array with dimension of [512x512x10, 1]. Now I would like to output this array to a file as stacks of images, i.e., 512x512x10.

Can someone show me how to use libtiff's function to do this?

Penn,

Are you ok with emitting the file with PLANARCONFIG_CONTIG? This implies all sample values for the first pixel appear, followed by all the sample values for the second pixel and so on.

Just make sure you set the TIFFTAG_PLANARCONFIG to PLANARCONFIG_CONTIG and then when you call TIFFWriteStrip(), TIFFWriteTile(), or TIFFWriteScanline() that you write all samples of the data for the region in question interleaved as explained above. Honestly, if you look at example code that writes out RGB or RGBA data you should see what to do - just extent it to 10 samples.

There is a link to an IBM DeveloperWorks tutorial on libtiff on the libtiff web site that might be helpful.

Best regards,

---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent