[GRASS-dev] Re: i.rgb.his/i.his.rgb and 16bit images

Glynn Clements glynn at gclements.plus.com
Wed Sep 30 17:52:27 EDT 2009

Georg Kaspar wrote:

> > this could be corrected by replacing the constant 255 with a variable 
> > according to the encoding of the image.
> > i'm not quite shure how to do this (only did some scripting so far) - 
> > can somebody help?
> to be more precise: how can i read-out the encoding of a raster file (or 
> the maximum value) in c? I already took a look at the programmer's 
> manual but didn't find what i'm looking for (i'm accustomed to javadoc...).

You can read the minimum and maximum values using G_read_range() or
G_read_fp_range() (these have been renamed from G_* to Rast_* in 7.0).

However, that tells you the minimum and maximum values which actually
occur, not the nominal 0 and 1 values which should be used for
colour-space conversion.

A more suitable approach is to use the colour tables, e.g. using
G_get_raster_row_colors() rather than G_get_raster_row(). This is the
mechanism used by r.composite.

Then, the user can apply grey-scale colour tables which match the
nominal range of the data (e.g. the predefined "grey255" colour table
maps 0 to black and 255 to white, while "grey1.0" maps 0 to black and
1.0 to white).

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list