# Color Images (Introduction to Video and Image Processing) Part 3

## Other Color Representations

From a human perception point of view the triangular representation in 3.10(b) is not intuitive. Instead humans rather use the notion of hue and saturation, when perceiving colors. The hue is the dominant wavelength in the perceived light and represents the pure color, i.e., the colors located on the edges of the triangle in Fig. 3.10(b). The saturation is the purity of the color and represents the amount of white light mixed with the pure color. To understand these entities better, let us look at Fig. 3.11(a). First of all we see that the point C corresponds to the neutral point, meaning the colorless center of the triangle where (r, g) = (1 /3,1 /3). Let us define a random point in the triangle as P. The hue of this point is now defined as an angle, θ, between the vectors Cr2\ and cP. So hue = 0° means red and hue = 120° means green.

If the point P is located on the edge of the triangle then we say the saturation is 1, hence a pure color. As the point approaches C the saturation goes toward 0, and ultimately becomes 0 when P = C. Since the distance from C to the three edges of the triangle is not uniform, the saturation is defined as a relative distance. That is, saturation is defined as the ratio between the distance from C to P, and the distance from C to the point on the edge of the triangle in the direction of cP . Mathematically we have

where Hcp|| is the length of the vector cP. The representation of colors based on hue and saturation results in a circle as opposed to the triangle in Fig. 3.10(b). In Fig. 3.11(b) the hue-saturation representation is illustrated together with some of the pure colors.

Table 3.3 Some different colors and their representation in the different color spaces. ND = Not Defined

 Color (R.G.B) (r. g. b) (r. g. I) (H. S, I) (H, S, V) (Y, U, V) (YC6lCr) Red (255, 0, 0) (1,0,0) (1,0, 85) (0, I, 85) (0, 1,255) (76, -37,157) (76, 85,255) Yellow (255,255,0) (1/2,1/2,0) (1/2, 1/2, 170) (60,1, 170) (60,1,255) (226,-111,26) (226,255, 149) Green (0,255, 0) (0,1,0) (0,1,85) (120,1,85) (120, 1,255) (150, -74,-131) (150,100, 115) Cyan (0,255,255) (0,1/2,1/2) (0,1/2, 170) (180,1,170) (180, 1,255) (179,38,-157) (179,171,0) Blue (0,0,255) (0,0,1) (0,0, 85) (240,1,85) (240, 1,255) (29, 111,-26) (29,255,107) Magenta (255,0,255) (1/2,0,1/2) (1/2,0, 170) (300,1,170) (300, 1,255) (105,74,131) (105,212,235) Black (0,0,0) (0,0,0) (0,0,0) (ND, 0,0) (ND, 0,0) (0,0,0) (0,128, 128) White (255,255,255) (1/3,1/3,1/3) (1/3, 1/3,255) (ND, 0,255) (ND, 0,255) (255,0,0) (255,128, 128) 25% white (64,64,64) (1/3,1/3,1/3) (1/3, 1/3,64) (ND, 0,64) (ND, 0,64) (64, 0, 0) (64, 128,128) 50% white (128, 128,128) (1/3,1/3,1/3) (1/3, 1/3, 128) (ND, 0,128) (ND, 0,128) (128,0,0) (128,128, 128) 25% Blue (0,0,64) (0,0,1) (0,0,21) (240,1,21) (240, 1,64) (7,28, -6) (7,160, 123) 50% Blue (0,0, 128) (0,0,1) (0,0,43) (240,1,43) (240, I, 128) (15,58,-13) (15, 192,118) 75% Blue (0,0, 192) (0,0,1) (0,0,64) (240,1,64) (240, I, 192) (22, 84,-19) (22,224,112) Orange (255, 165,0) (0.6,0.4,0) (0.6,0.4,140) (40,1, 140) (39,1,255) (173,10,72) (173,30,186) Pink (255, 192,203) (0.4,0.3,0.3) (0.4,0.3,217) (351,0.1,217) (350, 0.2,255) (212,-4,57) (212,123, 157) Brown (165,42,42) (0.6,0.2,0.2) (0.6,0.2,83) (0, 0.5,83) (0,0.7, 165) (79, -18,76) (79, 107,190)

Fig. 3.11 (a) The definition of hue and saturation. (b) The hue-saturation representation. The color of a pixel (indicated by a dot) is represented by a hue value and a saturation value (denoted S in the figure). The figure also indicates the location of some of the pure colors

It is important to realize how this figure relates to Fig. 3.7, or in other words, how the hue-saturation representation relates to the RGB representation. The center of the hue-saturation circle in Fig. 3.11(b) is a shade of gray and corresponds to the gray-vector in Fig. 3.7. The circle is located so that it is perpendicular to the gray-vector. For a particular RGB value, the hue-saturation circle is therefore centered at a position on the gray-vector, so that the RGB value is included in the circle.

A number of different color representations exist, which are based on the notion of hue and saturation. Below two of these are presented.4

## The HSI Color Representation

The HSI color representation is short for hue, saturation and intensity. The representation follows the exact definition mentioned above. That is, the intensity is defined asand hue and saturation is defined as illustrated in Fig. 3.11. When calculating the conversion from RGB to HSI we seek a way of avoiding fist converting from RGB to rg, i.e., we want to represent the conversion in terms of RGB values. It is shown how this is possible and the resulting conversion from RGB to HSI is defined as

where min{R, G, B} means the smallest of the R, G, and B values.Saturation is defined to be zero when (R,G, B) = (0, 0,0) and hue is undefined for gray-values, i.e., when R = G = B. The conversion from HSI to RGB is given as

In Table 3.3 the HSI values of some RGB pixels are shown.5

## The HSV Color Representation

The HSV color representation is short for hue, saturation and value. One can think of HSV as an approximation of HSI, but much simpler to calculate. This is true, but it is important to notice that HSV is not defined to be an approximation of HSI. It is rather defined from an artist’s point of view. Consider the situation when an artist mixes paint. She would choose a pure color and lighten it by adding white or darkening it by adding black. In the HSV representation the actions of the artist are modeled in the following way. The pure color obviously corresponds to hue. Increasing the whiteness (by adding white) corresponds to lowing the saturation. Finally, increasing the amount of black corresponds to lowering the intensity of R,

G, and B. Concretely, this is modeled by the intensity of the maximum color and denoted value, i.e., value = max{R, G, B}.

Following these definitions, a very elegant geometric argument can be made leading to a computationally simpler representation of hue, saturation, and value, than HSI. The conversion from RGB to HSV is given as:

where min{R, G, B} and max{R, G, B} are the smallest and biggest of the R, G, and B values, respectively. As for HSI saturation is defined to be zero when (R,G, B) = (0,0, 0) and hue is undefined for gray-values, i.e., when R = G = B. The conversion from HSV to RGB is given as

where |xJ means the floor of x,.In Table 3.3 the HSV values of some RGB colors are shown.

## The YUV and YCbCr Color Representations

A number of other color representations exist, but those mentioned above are those most often applied in image processing. One exception, however, is the color representations used for transmission, storage, and compression of image and video. These representations all have a similar structure, which is presented in this section.

In the early days of TV only monochrome screens were available and hence only intensity information was transmitted from the TV stations. RGB cameras captured RGB signals, but converted them into luminance values, denoted Y, before transmitting them. Knowledge of human perception was taken into account when defining the weights used for the conversion, see Sect. 3.2.2:

where

As the color screen technology matured, a need for transmitting color signals arose. Two requirements were set up when defining how to transmit color signals: 1) The signal should be compatible with the already existing signals used for monochrome screens and 2) the decoding on the receiver side should be as simple as possible. From this it followed that the color information was transmitted as weighted difference signals with respect to Y :

where WX1 and WX2 are weight factors, Wr and Wb are from Eq. 3.24, and Xi and X2 encode the blue and red information, respectively. The green information can then be inferred from Y, X1 and X2. Note that when no color is present, i.e. R = G = B ,we have X1 = 0 and X2 = 0.

So, by transmitting (Y,X1,X2) a monochrome receiver can simply show Y, while a color receiver can decode (R,G,B) and show a color signal using the following equations:

Note that since all the weights are known in advance the conversion becomes rather simple.

One of the most well known color spaces using this principle is the YUV color space. The YUV color space is for example used in most European TV transmission standards. YUV uses the weights: Wr = 0.299, Wg = 0.587, Wb = 0.114, WX1 = 0.436, and WX2 = 0.615, and has the conversion listed below.In Table 3.3 the YUV values of some RGB values are shown.

Another well know color space using this principle is the YCbCr color space, which is used in for example JPEG and MPEG. YCbCr uses the weights: Wr = 0.299, Wg = 0.587, Wb = 0.114, Wxi = 0.5, and Wx2 = 0.5, and has the conversions listed below.

Note that 128 is added/subtracted in order to bring the values into the range [0,255]. Note also the simplicity of the conversions compared to those for HSI and HSV. In Table 3.3 the YCbCr values of some RGB values are shown.

## Further Information

When reading literature on color spaces and color processing it is important to realize that a number of different terms are used.6 Unfortunately, some of these terms are used interchangeably even though they might have different physical/perceptual/technical meanings. We therefore give a guideline to some of the terms you are likely to encounter when reading literature on colors:

Chromatic Color All colors in the RGB color cube except those lying on the gray-line spanned by (0, 0, 0) and (255, 255, 255).

Achromatic Color The colorless values in the RGB cube, i.e., all those colors lying on the gray-line. The opposite of chromatic color.

Shades of gray The same as achromatic color.

Intensity The average amount of energy, i.e., (R + G + B)/3.

Brightness The amount of light perceived by a human.

Lightness The amount of light perceived by a human.

Luminance The amount of light perceived by a human. Note that when you venture into the science of color understanding, the luminance defines the amount of emitted light.

Luma Gamma-corrected luminance.

Fig. 3.12 Examples of pseudo color mapping

Shade Darkening a color. When a subtractive color space is applied, different shades (darker nuances) of a color are obtained by mixing the color with different amounts of black.

Tint Lightening a color. When a subtractive color space is applied, different tints (lighter nuances) of a color are obtained by mixing the color with different amounts of white.

Tone A combination of shade and tint, where gray is mixed with the input color. ’(denoted prime) The primed version of a color, i.e., R’, means that the value has been gamma-corrected.

Sometimes a gray-scale image is mapped to a color image in order to enhance some aspect of the image. As mentioned above a true color image cannot be reconstructed from a gray-level image. We therefore use the term pseudo color to underline that we are not talking about a true RGB image. How to map from gray-scale to color can be done in many different ways. In Fig. 3.12 and Fig. 2.22 examples are illustrated.

Fig. 3.13 A color image captured by a Bayer pattern