[FWTools] Converting RBGA UIint 16 images to RGB Byte images

Frank Warmerdam warmerdam at pobox.com
Mon Jan 22 16:46:55 EST 2007


Travis Kirstine wrote:
> Hi All
> I've been tring to translate a RGBA UInt16 image to a RGB Byte type image
> without much success.  The output is almost all white 255 255 255 with a few
> red/green/blue pixels.  My guess is that since most of the input pixel
> values are greater than 255 gdal assigns a value of 255 to the output pixels
> (that isprobally the way it should work).  Is there a switch or method to
> compress the int16 input image pixels range to a Byte range 0 - 255(does
> that make any sence?). So that I retain the image info.

Travis,

Yes, the -scale option!

You could let GDAL pick default scaling with:

  gdal_translate -ot Byte -scale in.tif out.tif

or if you want to ensure the same scaling is used for all bands, and if you
know the scaling do something like:

  gdal_translate -ot Byte -scale 0 1500 0 255 in.tif out.tif

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 FWTools mailing list