2009.09.11 00:21 "Re: [Tiff] Manually convert 16-bit grayscale image data to 8-bit grayscale in Borland c++", by Robert Zermeno
>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
Can you elaborate a little more on the idea behind 2 reads ("used to estimate the scaling parameters?")
I have to provide my own tiff reader/writer because the type of handheld device the software will be placed on cannot use libtiff. For some reason, it cannot compile and work on the handheld (as claimed by my team lead). So, I am forced to re-invent the wheel, but with a different purpose.
I have all the different types of tiff images my firm will deal with written out to read them except for 16-bit grayscale images. I am aware of Little/Big endian byte ordering and I account for this as well.
--- On Thu, 9/10/09, Bob Friesenhahn <email@example.com> wrote:
> 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. I have to do this because in Borland, to
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. results look similar, then add the -normalize option when converting the file and see if there is now a recognizable image. If
It is important to realize that Geotiff data may use the full range and resolution of the 16 bits. 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. could be a particularly dark or bright day. Due to this, software which deals with such images often reads the data twice. first read is used to estimate the scaling parameters to be applied during the second read. interaction may be necessary to fine-tune the results. A It The User