AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2003.12.26 02:25 "[Tiff] problems with custom TIFF", by Pushkar Pradhan
2003.12.26 09:36 "Re: [Tiff] problems with custom TIFF", by Andrey Kiselev
2003.12.30 00:09 "RE: [Tiff] problems with custom TIFF", by Pushkar Pradhan
2003.12.30 00:27 "Re: [Tiff] problems with custom TIFF", by Joris Van Damme
2003.12.30 00:47 "RE: [Tiff] problems with custom TIFF", by Pushkar Pradhan
2003.12.31 11:40 "Re: [Tiff] problems with custom TIFF", by Andrey Kiselev
2004.01.01 23:11 "RE: [Tiff] problems with custom TIFF", by Pushkar Pradhan

2003.12.30 00:09 "RE: [Tiff] problems with custom TIFF", by Pushkar Pradhan

Andrey,

Extra Samples: 2<unspecified, unspecified>

Samples/Pixel: 3

These two tags means that you don't have RGB image, but single band image with the two extra channels. It is not clear how to interpret the two external channels, it should be application dependent. SamplesPerPixel tag contains total band number, and ExtraSamples tag specifies how many extra bands in the total number.

I read in the 3 bands using TIFFReadEncodedStrip and write out to a new file (after converting RGB to LHS in IEEE FP format). This is info given by tiffinfo of output file:

Image Width: 421 Image Length: 295
Bits/Sample: 32
Sample Format: IEEE floating point
Compression Scheme: None
Photometric Interpretation: min-is-black
Samples/Pixel: 3
Rows/Strip: 9
Planar Configuration: single image plane

However, the software is unable to open this file. I suspect this has got something to do with the Extra Samples: 2<unspecified, unspecified> thing? I found out that this tells whether there is alpha information in the file or not. But can somebody explain to me how to read it? The man page is confusing. Also once I get it what should I do with it when writing out the output file?

Description looks fine. Have you used Imagine to read that file or other software?

Here's my code for more information:

size = TIFFReadEncodedStrip(tif, strip, bufRGB, (tsize_t)-1);

Why do you using -1 here? It should be a size of bufRGB in bytes.

I read in the libtiff tutorial that by passing -1 it will read in the whole tile/strip.

 Rgb2Lhs(bufRGB, bufRGB+size, bufRGB+(size*2), tags.dType, tags.config,
bufLHS, bufLHS+size, bufLHS+(size*2),
tags.imageLength, tags.rowsPerStrip);

I think you are trying to do th wrong thing here. With the above PalnarConfiguration the values in buffer are pixel interleaved:

RGBRGBRGB....

Right, I do it that way to keep the function args. same for tile/stripe. That's why I have tags.config which tells my function whether it's a tiled/striped image and it accesses the buffer accordingly.

 size = TIFFWriteEncodedStrip(wtif, strip, bufLHS, size*sizeof(float));

It should be (size/TIFFDataWidth(inputType))*sizeof(float), because TIFFReadEncodedStrip() returns the number of taken bytes, not number of taken samples.

I did this both the changes you suggested, still it doesn't work. This is how I get/set in the tags is this correct?

 TIFFGetField(tif, TIFFTAG_EXTRASAMPLES, &tags->extra, &tags->extraTypes);
 TIFFSetField(wtif, TIFFTAG_EXTRASAMPLES, wtags.extra, wtags.extraTypes);

Where tag members are:

  uint16 extra;
  uint16 *extraTypes;

Thanks,
Pushkar