2007.07.23 22:24 "[Tiff] Planar Images", by Christian Henning

2007.07.23 22:24 "[Tiff] Planar Images", by Christian Henning

Hi there, can somebody point me to an explanation on how planar images are stored inside a file. Esspecially when using TIFFReadEncodedStrip.

I'm trying to read one the test files I found online. Its name is caspian.tif. And the parameter are:

width = 279
height = 220
samples_per_pixel = 3
bits_per_sample = 64
planar_configuration = 2
compression = 32946
rows_per_strip = 3

scanline_size = 2232
raster_scanline_size = 6696
strip_size = 6696
number_of_strips = 222

When I understand it correctly I can read through the image like this:

   typedef std::vector< std::vector< double > > vec_t;
   vec_t image( max_strips );
   vec_t::iterator it = image.begin();
   vec_t::iterator end = image.end();

   for( ; it != end; ++it )
   {
      it->resize( scanline_size );
   }

   for( int stripCount = 0; stripCount < max_strips; stripCount++ )
   {
      if( TIFFReadEncodedStrip( img
                              , stripCount
                              , &image[stripCount].front()
                              , scanline_size ) == -1 )
      {
         cout << "error" << endl;

         break;
      }
   }

How can I access the red, green and, blue components? Or asks differently when I read a strip what's in it? I could image several memory pattern.

By the way on http://www.awaresystems.be/imaging/tiff/tifftags/baseline.html the tag bits_per_sample is defined as an array. But when I try to get_field it I only get an invalid pointer? Is that expected? I'm using libtiff 3.8.2.

Thanks a lot,

Christian