Color Model Conversion function
Converts the color model of an image from either the hue, saturation, and value (HSV) to red, green, and blue (RGB) or vice versa.
The inputs for this function are the following:
- Input Raster
- Type—RGB to HSV or HSV to RGB
The RGB color model
RGB is a color model based on additive primary colors. On a cathode ray tube (CRT) screen, each pixel (picture element) consists of a triad of phosphor colors: red, green, and blue. Light is emitted and displayed by the intensity at which these colors are projected by electron guns. An equal triad of fully saturated colors (255 255 255) will illuminate white, and conversely, 0 values will illuminate nothing, or black. Colors can be viewed spatially by using the RGB cube below.
- Red—Specifies the intensity of red as an integer between 0 and 255. A color with red set to 0 specifies the absence of color and emits no red light. A color with red set to 255 will appear bright red or fully saturated with color.
- Green—Specifies the intensity of green as an integer between 0 and 255. A color with green set to 0 specifies the absence of color and emits no green light. A color with green set to 255 will appear bright green or fully saturated with color.
- Blue—Specifies the intensity of blue as an integer between 0 and 255. A color with blue set to 0 specifies the absence of color and emits no blue light. A color with blue set to 255 will appear bright blue or fully saturated with color.
In the RGB color model, pure gray shades are obtained by combining equal quantities of all three color values: red, green and blue. If all three values are set to 255, the total presence of color will illuminate white and, conversely, if all three color values are set to 0, the absence of color will illuminate black. This leaves 1 through 254 available indices for shades of gray. Approximately 20 shades of gray are discernible by the human eye.
The HSV color model
The HSV color model is based on a color system in which the color space is represented by a single cone. The three components of the cone are the hue, saturation, and value.
- Hue—Specifies the hue (color) to which the color will be set. Hue is given as an integer between 0 to 360 based on the Tektronix color standard (in which the hue is given as an angle counterclockwise around the color cone). The primary and secondary colors have the following hue values: red = 0, yellow = 60, green = 120, cyan = 180, blue = 240, and magenta = 300.
- Saturation—Specifies the intensity of saturation to which the color will be set. Saturation is given as an integer between 0 and 100. The saturation of a color refers to the extent to which it departs from a neutral color such as gray, or in simpler terms, its colorfulness. When saturation is 100, the color is fully saturated. When saturation is 0, the color is unsaturated, and will appear gray (unless the value is set to 0 or 100, in which case it will appear black or white).
- Value—Specifies the intensity of white in the color. Value is given as an integer between 0 and 100. A color with a value set to 0 will appear black. A color with a value set to 100 and the saturation set to 0 will appear white.