2009.09.10 15:52 "Re: [Tiff] Manually convert 16-bit grayscale image data to 8-bit grayscale in Borland c++", by Bob Friesenhahn
How on earth may I be able to convert my 16-bit grayscale image data
> to 8-bit? I have been able to take 2 bytes to a short value, then > truncate it to a single byte like so:
> unsigned short value16 = *TmpBits++;
> value16 = value16 + (*TmpBits++ << 8)
Be sure to consider endian order since TIFF can be big or little endian.
When I dislpay my data in Borland through a TImage object, I will recieve my image (meaning, you can make out my object I am looking
> at, but the gray values for each pixel is way off. Sometimes too > much white and some pixels are correct for black) but the gray
coloration is way off. have to do this because in Borland, to I
Someone else here mentioned ImageMagick, but I will instead (naturally!) suggest installing a "Q16" build of GraphicsMagick from http://www.GraphicsMagick.org/ and you can use that to see if the results look the same as with your Borland results. If results look similar, then add the -normalize option when converting the file and see if there is now a recognizable image.
It is important to realize that Geotiff data may use the full range and resolution of the 16 bits. A simple conversion to 8 bit would loose all of the data if it happened to only use the range of 0 to 255. Some sensors may only produce a range of 0-4095 but the values are still stored in 16-bits. It could be a particularly dark or bright day. Due to this, software which deals with such images often reads the data twice. The first read is used to estimate the scaling parameters to be applied during the second read. User interaction may be necessary to fine-tune the results.
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/