# Example 9 -- nonlinearly shaded image colorscale # # Contributed 31 July 1996 by Dan Kelley <Dan.Kelley@Dal.CA> # Create a HSB palette file, using 'perl' system command. # You could do this with 'gawk' or other system commands, # or you could create the file in matlab or a text editor, # outside Gri. # Note: tan is RGB=(210,180,140) in /usr/lib/X11/rgb.txt, in the X11 # 0 to 256 RGB coordinate system. This is (0.820,0.703,0.547) in # the Gri's 0 to 1 rgb coordinate system. This translates to # (0.095,0.333,0.820) in the Gri hsb coordinate system. (Note: # a program to translate RGB to HSB is available from Dan # Kelley at Dan.Kelley@Dal.CA.) \min = "-0.20" # min image value \a = "-0.002" # black if value is < \a \b = " 0.002" # tan if between this and \a \max = " 0.030" # spectrum from \b up to this set y axis 200 0 -25 -5 set x axis 0 2340 180 60 set image range \min \max # NOTE: I have inserted comments into the example9.colorscale file, # particularly to track the value of '$value', etc. This is highly # recommended procedure. system perl <<"EOF" open(CS, ">example9.colorscale") || die "Cannot open 'example9.colorscale'\n"; $value = \min; $increment = (\max - \min) / 255; for($i=0; $i<256; $i++) { if ($value < \a) { print CS "0.000 0.000 0.000 # value=$value is <\a so use black\n"; } elsif ($value < \b) { print CS "0.095 0.333 0.820 # value=$value is between \a and \b so use tan\n"; } else { print CS ($value - \b) / (\max - \b), " 1.000 1.000 # value=$value is > \b so use spectrum up to \max\n"; } $value += $increment; } EOF open example9.colorscale read image colorscale hsb draw image palette left -0.01 right 0.04 increment 0.01