COLOR_CONVERT Procedure

Converts colors to and from the RGB color system, and either the HLS or HSV systems.

Usage

  • COLOR_CONVERT, i0, i1, i2, o0, o1, o2, keyword

Input Parameters

i0, i1, i2—The input color triple(s). May be either scalars or arrays of the same length.

Output Parameters

o0, o1, o2—The variables to receive the result. Their structure is copied from the input parameters.

Keywords

One of the following keywords is required:

CMY_RGB—Convert from CMY (cyan, magenta, yellow) to RGB (red, green, blue).

HLS_RGB—Convert from HLS (hue, lightness, saturation) to RGB .

HSV_RGB—Convert from HSV (hue, saturation, value) to RGB.

RGB_CMY—Convert from RGB to CMY.

RGB_HLS—Convert from RGB to HLS.

RGB_HSV—Convert from RGB to HSV.

Discussion

RGB and CMY values are bytes in the range of 0 to 255.

Hue is a floating-point number measured in degrees, from 0.0 to 360.0; a hue of 0.0 degrees is the color red, green is 120.0 degrees, and blue is 240.0 degrees.

Saturation, lightness, and value are floating-point numbers in the range of 0.0 to 1.0.

Note that when RGB values are the same during an RGB to HSV conversion, the saturation is set to 0.0 and the hue is undefined.

Example

; Convert the RGB color triple (0,255,255), which is the color
; yellow at full intensity and saturation, to the HSV system. 
COLOR_CONVERT, 255, 255, 0, h, s, v, /RGB_HSV
PRINT, h, s, v
; PV-WAVE prints: 60.00000    1.00000    1.00000

Resulting hue in the variable h is 60 degrees. The saturation and value (s and v) are set to 1.0.

See Also

HLS, HSV, HSV_TO_RGB,  LOADCT, MODIFYCT, PSEUDO, RGB_TO_HSV, STRETCH, TVLCT, WgCeditTool

For more background information about color systems, see the PV‑WAVE User Guide.

For a discussion of the various color systems, see Computer Graphics: Principles and Practice, by Foley, Van Dam, Feiner, and Hughes, Second Edition, Addison Wesley Publishing Company, Reading, MA, 1990, pp. 585-596.