How does 'd.rgb' work?

Date: Tue, 3 Mar 92 12:03:46 HST
From: Jinn-Guey Lay <jinn@uhunix.uhcc.Hawaii.Edu>
To: grassu-list@amber.cecer.army.mil
Subject: How does 'd.rgb' work?

...

I was trying to display an elevation map in color with a shadow
releif map in grey tone. I have tried 'd.his' using elevation
as hue and shadow relief as intensity. It looks OK only if I stay
far enough; the display is somehow noisy with many pixels of
different colors scattering arround.

I have also tried 'blend.sh' to combine elevation and shadow
relief maps. What the 'blend.sh' script does is to grab the
R,G,B values of each map separately, add them together, and
store the added R,G,B values into three new raster files, i.e.
file.r, file.g, and file.b. Following this, I tried 'd.rgb' command
with the three raster files as input for red, green, and blue.
The result does not look right. It does not hold the original colors
of elevation and does not have any apparent pattern.

...

So, how can I display a map using its RGB values?
Does any netter have similar experience on these problem?
Any advice on 'd.rgb', 'd.his', and map overlay will
be appreciated.

Jinn-Guey Lay
GIS & Computer Cart. Lab
University of Hawaii at Manoa

I think i.median is what you are looking for. i.composite will also work
but the results will be different. The output of i.median looks best
on a driver that supports full 256 color display in colormode float.

while I am on the subject, I have a new derivative of blend.sh called
intens.sh. While blend.sh combines two colors into one, intens.sh
is designed to work with a color file, and a grayscale file, using the
grayscale to vary the intensity of the colors. This avoids the
'washed out' effect of you can get from blend.sh

Also, if you have a Silicon Graphics, the latest version of SG3d (not
in distribution yet, but will be shown at GRASS User's Conference, I hope)
has full lighting model support, so all this stuff is no longer necessary.

The program intens.sh follows:
------------------------------ Rip Here ------------------------------------
#!/bin/sh -f
# written by Dave Gerdes Nov 1991

if [ $# != 4 ] ; then
    echo 'Usage: intens.sh file1 file2 perc outbase'
    echo ''
    echo 'This program is a derivative from blend.sh. It is designed'
    echo 'for the special case when file2 is an aspect or other gray'
    echo 'scale map. It avoids the washed out affect of combining'
    echo 'a gray scale map with another map, by using ONLY the colors'
    echo 'from the color map, and using the aspect file to vary only the'
    echo 'intensity creating 3 new files representing the R,G, and B'
    echo 'components of the resultant image.'
    echo ''
    echo 'The files will be named outbase.r outbase.g outbase.b'
    echo 'and have data values in the range 0-255'
    exit 1
fi
    
first=$1
second=$2
perc=$3
out=$4

if [ $perc -eq 100 ]
then
  perc=1.0
else
  perc=.$perc
fi

for i in r g b
do
    r.mapcalc << ____EOF
  $out.$i = eval ( \
  first = $i#$first, \
  second = $i#$second, \
  range = first * $perc, \
  base = first * (1. - $perc), \
  gray = second / 255., \
  res = range * gray + base, \
  if (res > 255, 255, if (res < 0, 0, res)) )
____EOF
done

exit 0
------------------------------ Rip Here Too --------------------------------

--

  Dave Gerdes
  US Army Construction Engineering Research Lab
  Spatial Analysis & Systems Team
  dpgerdes@cerl.cecer.army.mil
  (217) 352-6511 x591