ENDS489 Course Notes - Fall 2000
Section 1-4

Color Spaces

(Based on material from Digital Imaging: Theory and Applications, H. E. Burdick, McGraw-Hill, 1997)

Computer display CRTs typically have three electron guns that illuminate three different kinds of phosphor dots on the screen. Those phosphor dots, when illuminated, glow with the red, green, and blue primary colors of light. From these primary colors, all other shades are generated.

A combination of real world physical characteristics determines what the human vision system perceives as color. A color space is a mathematical representation of these characteristics. Color Spaces are always three-dimensional. There are many possible color space definitions:

Though most work in digital imagery is performed in RGB, which is native to computer displays, many digital image processing applications require transformation to the other color spaces. Usually utility programs are provided to perform these color space transformations.

Red, Green, Blue (RGB)

All color spaces are three-dimensional orthogonal coordinate systems, meaning that there are three axes (in this case the red, green, and blue color intensities) that are perpendicular to one another. This color space is illustrated below. The red intensity starts at zero at the origin and increases along one of the axes. Similarly, green and blue intensities start at the origin and increase along their axes. Because each color can only have values between zero and some maximum intensity (255 for 8-bit depth), the resulting structure is the cube. We can define any color simply by giving its red, green, and blue values, or coordinates, within the color cube. These coordinates are usually represented as an ordered triplet - the red, green, and blue intensity values enclosed within parentheses as shown below.

(red, green, blue)

Several colors are shown mapped into their locations in the RGB cube, or color space. Black has zero intensities in red, green, or blue, so it has the coordinates (0,0,0). At the opposite corner of the color cube, white has maximum intensities of each color, or (255,255,255). Full intensity red, having zero green or blue components, also is positioned at a corner of the cube at location (255,0,0). Yellow, which is combination of red and green, is positioned at (255,255,0). Cyan and magenta, which are combinations of green and blue and red and blue, respectively, are at (0,255,255) and (255,0,255). Finally, note that a middle gray is at the exact center of the cube at location (128,128,128). All other colors can be described by specifying their coordinates within this cube.

The RGB color space is an additive color space. Its origin starts at black, and all other colors are derived by adding various amounts of the primary colors. It is a natural choice for computer displays where black, or no light intensity, is the starting point, and the increasing intensity of the red, green, and blue electron guns provides the range of colors.

Cyan, Yellow, Magenta (CYM)

The CYM color space is related to the RGB color space by being the inverse of it. The origin of this color space is not black, but is white, and the primary axes of the coordinate system are not red, green, and blue but are cyan, yellow, and magenta. The color red in this space is a combination of yellow and magenta, while green is composed of yellow and cyan. Blue is made up of cyan and magenta. The following equations define how to convert from the RGB color space into the CYM color space and back again.

c = max-r  m = max-g   y = max-b

r = max-c  g = max-m   b = max-y

where max is the maximum possible intensity value (for 8-bit depth resolution images this is 255). Once an image has been converted, or transformed, into the CYM color space, it cannot be displayed correctly on a computer monitor, which requires images in the RGB color space. If this resultant image is displayed, using the red, green, and blue planes for the cyan, magenta, and yellow data, respectively, an inverted or negative color image will be seen.

The CYM color space is most often used in the printing industry, where images start with a white piece of paper (the origin) and ink is applied to generate colors. After years of experience, many techniques have been developed to create the highest-quality printed images at the lowest possible cost. One of these methods is called under color removal and modifies the normal CYM color space into something called CYMK, where the K stands for black.

This approach notes that any CYM color has some underlying gray component, which is equal amounts of cyan, yellow, and magenta. This gray component can be generated with cheaper black ink, and small amounts of more expensive colored inks can be added to give the correct shade. In addition to being more economical, the printed image quality is increased because less ink is used overall, which in turn enhances drying and reduces the likelihood of smears. For example a color has certain components of cyan, yellow, and magenta on an arbitrary scale. In this case, 7 units of cyan ink, 5 units of yellow ink, and 9 units of magenta ink are required, for a total of 21 units. That same color can then have its underlying gray, or under color, removed. To reproduce this same color now takes 5 units of black ink, with 2 units of cyan, no yellow, and 4 units of magenta. This makes a total of 11 units of ink, only 6 units of which are expensive colors.

Hue, Saturation, Intensity (HSI)

Artists tend to describe scenes not in terms of red, green, and blue, but as hue, saturation, and intensity (HSI). We do not see things as quantities of primary colors mixed in certain proportions. We see the brilliant orange of a sunset or the dark, muted greens of a forest. We see things as colors, or hues, that either have a washed-out look or have deep, rich tones. This means having low or high saturation, respectively. A bright afternoon sun gives everything a high-intensity look, while dusk provides dark images of low intensity.

HSI is very different three-dimensional color space from RGB or CYM. The following figure illustrates a common representation of this space. The cone shape has one central axis representing intensity. Along this axis are all the gray values, with black at the pointed end of the cone and white at its base. The greater the distance along this line from the pointed end, or origin, the brighter or higher the intensity.

If this cone is viewed from above, it becomes a circle. Different colors, or hues, are arranged around this circle - the familiar color wheel used by artists. Hues are determined by their angular location on this wheel. Saturation, or the richness of color, is defined as the distance perpendicular to the intensity axis. Colors near the central axis have low saturation and look pastel. Colors near the surface of the cone have high saturation.

It may be preferable to modify an image in HSI color space rather than RGB. For example, we might want to change the color of a bright yellow car moving down a road to blue, but we want to leave the rest of the scene, including highlights and shadows on the car, unaffected. This would be a difficult task in RGB, but it is relatively simple in HSI. Because the yellow pixels of the car have a specific range of hue, regardless of intensity or saturation, those pixels can be isolated easily and their hue component modified, thus giving a different-colored car.

Since almost all digital image processing systems operate on RGB images, the example described above would be performed in three steps. First, the original RGB image would be converted to HSI. Second, the hue (or saturation or intensity) would be modified, Finally, the image would be converted back to RGB. There are many techniques for transforming an image from RGB to HSI and back again because the transformation is somewhat subjective.

The hue, saturation and value (HSV) system is a minor variation on the HSI system. The HSV color model, uses a hue value of 0 degrees to 360 degrees, with red at 0. Saturation is in the range of 0 to 1, with 0 being no color (along the central axis) and 1 being on the outer edge of the cone. The value (a variation of intensity) also has a range of 0 to 1, where 0 is black and 1 is white. Note that these calculations require higher numerical precision than is offered by 8-bit integer arithmetic. It therefore is advisable to maintain a HSV image as floating-point numbers, or at least 16-bit or 32-bit integers, and reduce them to 8-bit values as they are being transformed back into RGB.

Luminance-Chrominance

The last color spaces to be discussed are those based on luminance and chrominance, which correspond to brightness and color. These color spaces are denoted as YUV and YIQ. The YUV space is used for the PAL broadcast television system used in Europe. The YIQ color space is used for the NTSC broadcast standard in North America. The two methods are nearly identical, using slightly different conversion equations to transform to and from RGB color space. In both systems, Y is the luminance or brightness component and the I and Q (or U and V) are the chrominance, or color, components. These are the variables that are changed by the brightness, color, and tint controls on a television.

The advantages of using YUV or YIQ for broadcast is that the amount of information needed to define a color television image is greatly reduced. However, this compression restricts the color range in these images. Many colors that can appear on a computer display cannot be recreated on a television screen. Listed below are the equations for converting RGB colors into YUV and YIQ, and back to RGB. These equations assume that the red, green, and blue components have values between 0.0 and 1.0. Since this range is typical represented using 8-bit values between 0 and 255, they need to be scaled and processed as floating-point numbers:

RGB-to-YUV

Y =  .299R + .587G + .114B
U = -.147R - .289G + .437B
V =  .615R - .515G - .100B

RGB-to-YIQ

Y = .299R + .587G + .114B
I = .596R - .274G - .322B
Q = .211R - .523G - .312B

YUV-to-RGB

R = 1.00Y +  .000U + 1.403V
G = 1.00Y -  .344U -  .714V
B = 1.00Y + 1.773U +  .000V

YIQ-to-RGB

R = -1.129Y + 3.306I - 3.000Q
G =  1.607Y -  .934I +  .386Q
B =  3.458Y - 3.817I + 5.881Q