[gdal-dev] Colored images from grayscale images.

Frank Warmerdam warmerdam at pobox.com
Wed Jul 8 13:54:43 EDT 2009


Belaid MOA wrote:
> Hi everyone,
>   Is there any easy way to do the following using C++ in GDAL: I have a 
> floating-point image and I'd like to associate arbitrary colors with 
> ranges of the pixel levels. For example: for the pixel values in [0,0.1) 
> associate red, for [0.1, 0.2) associated orange, for [0.2, 0.3) 
> associate light blue, for [0.3,0.4) associate dark blue, for [0.4, 0.5) 
> associate green, etc. I would like also to have this information 
> available in the metadata or as legend so that users know what the 
> colors stand for when they view the image.

Belaid,

This sort of information can be preserved with some images as
a RasterAttrbuteTable:

   http://www.gdal.org/classGDALRasterAttributeTable.html

Since few formats intrinsically support these tables, they will
normally be stored in an associated .aux.xml file.

Note that very few applications take any advantage of raster
attribute tables, so even if you do this it will have little
immediate effect.

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    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list