
Thread
2003.03.18 22:58 "Grayscale 16-bit images", by Claus Ekstroem
Hi,
I'm completely new to tiff images and libtiff in particular so bear with me if I asking something that is beeding obvious. From searching the net (and the archives) I can see that this seems to be a fairly common answer, but I can't find any solutions or real documentation to guide me. So here goes....
I'm trying to read a 16-bit grayscale image:
Width 2200
Height 1695
BitsPerSample 16
SamplesPerPixel 1
The pixels are a scan from a microarray experiment (a "DNA chip") sp I need to access the intensities of each pixel and I need all 16 bits of information. Currently, I considered the following piece of code:
if (TIFFReadRGBAImage(tif, imageWidth, imageHeight, raster, 0)) {
long index = 0;
for (e = imageHeight-1; e!=-1; e--) {
for(c = 0; c < imageWidth; c++){
int Red = TIFFGetR(raster[e * imageWidth + c]);
int Green = TIFFGetG(raster[e * imageWidth + c]);
int Blue = TIFFGetB(raster[e * imageWidth + c]);
data[index] = Red;
index++;
}
}
}
but that is clealy wrong as the image is converted to 8 bit and the colour-channels become identical. I figure reading the file as a RGBAImage is the wrong approach, so could someone mail me a couple of lines of code to read and access the individual pixels?
All the best,
Claus
*****************************************
Claus Thorn Ekstrøm <ekstrom@dina.kvl.dk>
Dept of Mathematics and Physics, KVL
Thorvaldsensvej 40
DK-1871 Frederiksberg C
Denmark
Phone:[+45] 3528 2341
Fax: [+45] 3528 2350
*****************************************