[GRASS-user] r.cpt2grass now handles HSV input

Hamish hamish_b at yahoo.com
Sun Apr 27 04:53:39 EDT 2008


Hi,

I just added a little awk function into the r.cpt2grass addon script so
it will translate GMT .cpt legend color rules which use the HSV color
model.

script is here:
 http://trac.osgeo.org/grass/browser/grass-addons/raster/r.colors.tools/

Conversion of HSV to RGB is based on the Foley and Van Dam HSV algorithm
used by James Westervelt's (CERL) hsv.rgb.sh script from GRASS 4/5 (ie
the "mod 60" method).

CMYK rules are not supported, but I am yet to come across a .cpt file
which uses that.

example
   r.cpt2grass in=/usr/share/gmt/cpt/GMT_topo.cpt \
     out=palette_GMT_topo.gcolors --verbose


there is a problem with result looking very washed-out:

http://bambi.otago.ac.nz/hamish/grass/bugs/r.colors/nz_topo_GMT_topo_cpt.jpg
compare to overview pic at
http://topex.ucsd.edu/marine_topo/mar_topo.html

maybe the conversion algorithm could be better? e.g. method given here
doesn't simplify the hue color circle into a hexagon:
 http://www.mandelbrot-dazibao.com/HSV/HSV.htm

or is it because the starting saturation levels are all in the 0.25-0.45
range? original GMT HSV rules: (format: elev1 H S V  elev2 H S V)
 ftp://topex.ucsd.edu/pub/global_topo_1min/gmt_examples/map/topo.cpt


There is also a problem with the /usr/share/gmt/cpt/GMT_sealand.cpt
rules, as the "V" value is always 1 so the rule is always white. Again,
I'm not sure if that's a bug with the original file, the algorithm used,
or my understanding of HSV. (e.g. is "full" saturation at 50% not 100%? -
ie at the max radius of the double-cone half way between the black and
white ends)


Hamish




      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ



More information about the grass-user mailing list