setColorSpace
Top  Previous  Next

setColorSpace ( integer Space)

Use this function to assign a specific color model as the coordinate system for processing color images. Equivalent to selecting Color Space in Preferences/Processing (the Edit menu).

Parameters
 
Space  
An enumerated integer that describes the color space to be used as the coordinate system for processing color images. Must be one of the following values:  
 
CS_DEFAULT – each image processing function will be using a color space that is considered optimal for that particular function.  
 
CS_RGB – image processing will be performed in the RGB space. The RGB color model is an additive color model based on the human eye perception of colors. It uses transmitted light to display color and consists of three components: red (R), green (G) and blue (B). These components are the amounts of red, green, and blue light measured in values ranging from 0 to 255, and they are combined in varying intensities to produce all other colors in the RGB color model. If the processed image is a 16-bit-per-channel one, the range of the RGB values is extended to 0-65535.  
 
CS_HLS – image processing will be performed in the HLS space. The HLS color model consists of three components: hue (H), luminance (L) and saturation (S). Hue defines the pigment of a color measured in relative values from 0 to 255 (for instance, 0 is red; 40, yellow; 85, green; 128, cyan; 170, blue; and 213, magenta), luminance defines perceived intensity measured in percent from 0 to 256 (the higher the percentage, the brighter the color), and saturation defines the vividness of a color measured in percent from 0 to 256 (the higher the percentage, the more vivid the color, while zero value corresponds to pure gray). If the processed image is a 16-bit per channel one, the upper limit for all the values is extended to 65535.  
 
CS_YIQ – image processing will be performed in the YIQ space. The YIQ color model corresponds to the U.S. commercial television broadcast standard where colors are split into a luminance value (Y) and two chromaticity values (I or I-Phase and Q or Quadrature). Y is a weighted average of the colors red, green, and blue which gives more weight to red and green than to blue; I corresponds to color changing from orange to blue where the eye is much sensitive; Q corresponds to yellow-green color changing where the eye is less sensitive. The YIQ color model calls for more bits to be used to represent the Y component and few representing the I and Q components.  
 
CS_LRGB – image processing will be performed in the LRGB space. The LRGB model is based on the color distance vector (the distance between the color black and the current position of a pixel in the RGB coordinate system). The processing algorithms are applied to the luminance absolute values, then pixels in each color component are proportionally recalculated to match a luminance change.  
 
CS_LAB – image processing will be performed in the Lab space. The Lab color model is defined by the CIE colorimetry standard as perceptually uniform color space, where each color is represented by three numbers: lightness value (L*) and two chromaticity values (a* and b*). The choice of a* and b* components is based on the theory of color vision that states that two colors cannot be both green and red at the same time, nor blue and yellow at the same time. As a result, a* denotes the red/green value and b* the yellow/blue value. The uniformity of the Lab space allows color differences to be equally weighted throughout its domain.  
 
CS_LCH – image processing will be performed in the LCH space. The LCH color model is defined by the CIE colorimetry standard as perceptually uniform color space, based on the polar coordinate system. L is a measure of lightness of an object, C is a measure of chroma (saturation) which represents the distance from the neutral axis, and H is an angular measure of hue. The uniformity of the LCH space allows color differences to be equally weighted throughout its domain.  
 
Error flags

ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  

Example


This set of statements demonstrates an edge detection of an image in the RGB and HLS color spaces:  
 
setCurDir("samples")  
loadIm (1,"sample14.iwd")  
setColorSpace(CS_RGB)  
sobel (1,2,7)  
setColorSpace(CS_HLS)  
sobel (1,3,7)  
 
Remarks

If any other system than the CS_RGB is assigned for processing, an image will be converted to a corresponding color space before a processing function is applied and the resulting image will be converted back to the RGB space in the end.