0

Currently I am trying to utilize libtiff.net library for processing digital Tiff images. but the image that I have is not with standard ones.

The image contains 3 samples per pixel. And it is LZW compressed.

My question is: how to read the value of each pixel value. I have tried ReadScanline method. Values returned are all 0's. Is there any other method which returns the RGB pixel values?

I have other images with 5 samples per pixels and its not compressed. I could use ReadScanLine and it worked fine with the below code.

Here is my code snippet:

tiffReader = Tiff.ClientOpen("SomeTiff", "r", tiffStream, new TiffStream());
int imgHeight = tiffReader.GetField(TiffTag.IMAGELENGTH)[0].ToInt();
for (int rowIdx = 0; rowIdx < imgHeight; rowIdx++)
            {
                tiffReader.ReadScanline(totalScanline, rowIdx);

                'use totalScanline
               }

thanks in advance

Programmer2.0
  • 54
  • 1
  • 10
  • Did you see any warnings / errors in console? Did you try `ReadRGBAImage` method? – Bobrovsky Aug 01 '14 at 15:48
  • There are no warnings/error.When I tried RGBAImage method, I see output values. But those values are all negative values which does not make sense for RGB values. I was expecting values between 0 to 255. – Programmer2.0 Aug 04 '14 at 14:24
  • Negative values actually make sense in this case. `ReadRGBAImage` returns signed integers for each pixel. Each integer contains values for red, green, blue and alpha channels. You can extract each individual channel value by using `Tiff.GetR`, `Tiff.GetG`, `Tiff.GetB` and `Tiff.GetA` methods. These methods will return values in 0..255 range. – Bobrovsky Aug 04 '14 at 16:34
  • Thanks @Bobrovsky. That was what I needed. But I got to know that the data that I am getting is NIR, G B and not RGB. Do you know if there is a method specific for reading this. Or ReadRGBA should do the job since its 3 channel? – Programmer2.0 Aug 04 '14 at 20:18
  • I do not know much about NIRGB imagery, but 'ReadRGBAImage' should convert existing samples to RGBA format if possible. I.e. the method can add alpha channel if needed. – Bobrovsky Aug 05 '14 at 16:09
  • You are right @Bobrovsky. Thanks for helping me out! – Programmer2.0 Aug 05 '14 at 19:40

0 Answers0