[Gdal-dev] sample scaling

Frank Warmerdam warmerdam at pobox.com
Mon Oct 30 10:50:27 EST 2006


Alan Stewart wrote:
> I've got NITF files that have three bands @ 16 bits per sample. I need 
> to produce a GeoTIFF with 8-bit samples, JPEG compressed. In my first 
> attempts the resulting image appeared black. I discovered a GDAL 
> metadata item. "NITF_USE00A_DYNAMIC_RANGE=02047", which I take it means 
> that sample values range from 0 to 2047. If I use "-scale 0 2047 0 
> 65535" the resulting TIFF looks fine, but if I use "-scale 0 2047 0 255 
> -ot Byte" the image is much darker and greenish. I thought this would 
> just rescale the sample values to fit in the range 0-255 and create a 
> TIFF with 8-bit samples. I didn't expect the color balance of the image 
> to change. Is "Byte" actually a signed value or something? If so, how do 
> I get an unsigned 8-bit sample?

Alan,

Your understanding of how things should work sound right.  I don't know
why the results are bad.  How are you checking the results?  What viewer
did you use with the -scale 0 2047 0 65536 output tiff that looked good?

You might want to view your image in OpenEV, and inspect various pixels
to make sure that the dynamic range info of 02047 is accurate.  Or
use "gdalinfo -mm your.ntf" to actually scan the data for min and max values.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list