next up previous contents index
Next: I.5 Artificial illumination Up: I. Color Space: The Previous: I.3 The color cube   Contents   Index


I.4 Color interpolation

From studying the RGB cube, we hope you will have understood that there are different routes to follow between two colors, depending whether you are in the RGB or HSV system. Suppose you would make an interpolation between blue and red. In the RGB system you would follow a path diagonally across a face of the cube, from 0/0/255 (blue) via 127/0/127 (purple) to 255/0/0 (red). In the HSV system, you would trace two edges, from 240-1-1 (blue) via 300-1-1 (magenta) to 360-1-1 (red). That is even assuming software would be smart enough to go the shorter route. More likely, red will be recorded as 0-1-1, so hue will be interpolated the other way around, reducing hue from 240° to 0°, via cyan, green, and yellow.

Depending on the design of your color palette, you may want to have it either way. By default, GMT interpolates in RGB space, even when the original color palette is in the HSV system. However, when you add the line #COLOR_MODEL=+HSV (with the leading `+' sign) in the header of the color palette file, GMT will not only read the color representation as HSV values, but also interpolate colors in the HSV system. That means that H, S, and V values are interpolated linearly between two colors, instead of their respective R, G, and B values.

The top row in Figure I.4 illustrates two examples: a blue-white-red scale (the polar palette in Appendix M) interpolated in RGB and the rainbow palette interpolated in HSV. The bottom row of the Figure demonstrates how things can go terribly wrong when you do the interpolation in the other system.

Figure: When interpolating colors, the color system matters. The polar palette on the left needs to be interpolated in RGB, otherwise hue will change between blue (240°) and white (0°). The rainbow palette should be interpolated in HSV, since only hue should change between magenta (300°) and red (0°). Diamonds indicate which colors are defined in the palettes; they are fixed, the rest is interpolated.
\includegraphics[width=0.80\textwidth]{scripts/GMT_color_interpolate}


next up previous contents index
Next: I.5 Artificial illumination Up: I. Color Space: The Previous: I.3 The color cube   Contents   Index
Paul Wessel 2009-09-20