2002.09.18 17:53 "Reading 16bits from a gray scale image", by Steven Luke

2002.09.18 19:05 "Re: Reading 16bits from a gray scale image", by Chris 'Xenon' Hanson

Let me clarify my last email, I am not sure it was so clear what I needed to do:

How can I turn the 8bit or 32bit data into 16bits?

Meant: How can I use this 8bit or 32bit data to reconstruct the origenal 16bit value?

Tried only shifting the pixels by 4 in line [9] since the data was actually acquired in 12 bits then stored as 16, but I got the same results.

AFAIK, you cannot get the 16-bit (per channel) data back from the 32-bit APIs like TIFFReadRGBAImage. The 32-bits is 8-bits per channel, 3 or 4 channels. You want 16 bits per channel, one channel I expect. No matter how many channels you get out of the TIFFReadRGBAImage output, each channel will never be more than 8 bits.

I am displaying the image in 8bits so the final number needs to be only 8bits

So, why are fiddling with it at all? Just use the 8-bit data found in the first channel provided by TIFFReadRGBAImage, and you're set. If the input was single-channel, 8 or 16 bit, then all three channels provided by TIFFReadRGBAImage will be equivalent and you can use whichever you like.

that is why I shifted the pixels the opposite direction at the end. I am not sure if I am doing this step correct either. I was thinking of dividing by 257 but am unsure of the rounding process and think that this is probably just as good because it is easier.

I think you're making it harder than you need to.

Chris - Xenon
  Chris Hanson | Xenon@3DNature.com | I've got friends in low latitudes!
        New World Construction Set 6!: http://www.3DNature.com/
  "There is no Truth. There is only Perception. To Perceive is to Exist." - Xen