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

Hi,

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?

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?

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.

Thanks,

-Dwight

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?

No.

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
r.mapcalc.

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
space?

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@gclements.plus.com>

Glynn Clements wrote:

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

That is exactly what I was looking for (thanks!).

Glynn Clements wrote:

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

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.

I was thinking of all interpolations in HSB space. However your first option (calculating RGB values from specified HSB colors but continuing to work in RGB space) would meet my current need. In fact, that is exactly what I have been doing, but externally to GRASS because I don't know how to write the script for HSB => RGB conversion. I would find this capability to be a useful enhancement of r.colors.