[GRASS-user] r.colors- transparent, HSB color

Glynn Clements glynn at gclements.plus.com
Thu Mar 19 00:22:40 EDT 2009

Dwight Needels wrote:

> I have been using r.mapcalc to set various combinations of colors in a  
> 13-color DRG to null to allow the map to be displayed as a series of  
> overlays on top of other maps. It occurs to me that it would be useful  
> to be able to accomplish this using r.colors by defining the color of  
> specific values (or ranges of values) as transparent. Unfortunately, I  
> have not been able to find a way to do this.
> Is it possible to define a color as transparent without changing the  
> pixels to null pixels?


> If not, would this be technically feasible in a future version of GRASS?

The main issue is that each file which reads colours would have to be
extended to understand transparency. AFAICT, there are 38 modules and
3 libraries which would be affected.

> Is there a different approach that would allow me to generate multiple  
> examples of partially transparent maps without the overhead of  
> duplicating the raster map multiple times?

For integer maps, you can create a reclass map using r.reclass. This
has much lower overhead than creating a complete new map with

> Secondly, is it possible to define colors within GRASS using HSB (or  
> HSL) instead of RGB values? There are some kinds of calculations, for  
> example reducing the saturation of all colors by a given amount, that  
> are easier to accomplish in the HSB domain.

This isn't supported directly.

Are you talking about simply specifying colours in HSB, and keeping
the internal data in RGB, or having interpolation performed in HSB

The former wouldn't be particularly involved; just an extension to
G_parse_color_rule(). OTOH, you can obtain this functionality by
pre-processing the rules with a script.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list