Color Image Processing
The use of color is important in image processing because:
• Color is a powerful descriptor that simplifies object identification
and extraction.
• Humans can discern thousands of color shades and intensities,
compared to about only two dozen shades of gray.
Color image processing is divided into two major areas:
• Full-color processing: images are acquired with a full-color sensor,
such as a color TV camera or color scanner.
• Pseudocolor processing: The problem is one of assigning a color to
a particular monochrome intensity or range of intensities.
Color Fundamentals
Colors are seen as variable combinations of the primary colors of light:
red (R), green (G), and blue (B). The primary colors can be mixed to
produce the secondary colors: magenta (red+blue), cyan (green+blue),
and yellow (red+green). Mixing the three primaries, or a secondary with
its opposite primary color, produces white light.
Figure 15.1 Primary and secondary colors of light
RGB colors are used for color TV, monitors, and video cameras.
1
However, the primary colors of pigments are cyan (C), magenta (M), and
yellow (Y), and the secondary colors are red, green, and blue. A proper
combination of the three pigment primaries, or a secondary with its
opposite primary, produces black.
Figure 15.2 Primary and secondary colors of pigments
CMY colors are used for color printing.
Color characteristics
The characteristics used to distinguish one color from another are:
• Brightness: means the amount of intensity (i.e. color level).
• Hue: represents dominant color as perceived by an observer.
• Saturation: refers to the amount of white light mixed with a hue.
Color Models
The purpose of a color model is to facilitate the specification of colors in
some standard way. A color model is a specification of a coordinate
system and a subspace within that system where each color is represented
by a single point. Color models most commonly used in image processing
are:
2
• RGB model for color monitors and video cameras
• CMY and CMYK (cyan, magenta, yellow, black) models for color
printing
• HSI (hue, saturation, intensity) model
The RGB color model
In this model, each color appears in its primary colors red, green, and
blue. This model is based on a Cartesian coordinate system. The color
subspace is the cube shown in the figure below. The different colors in
this model are points on or inside the cube, and are defined by vectors
extending from the origin.
Figure 15.3 RGB color model
All color values R, G, and B have been normalized in the range [0, 1].
However, we can represent each of R, G, and B from 0 to 255.
Each RGB color image consists of three component images, one for each
primary color as shown in the figure below. These three images are
combined on the screen to produce a color image.
3
Figure 15.4 Scheme of RGB color image
The total number of bits used to represent each pixel in RGB image is
called pixel depth. For example, in an RGB image if each of the red,
green, and blue images is an 8-bit image, the pixel depth of the RGB
image is 24-bits. The figure below shows the component images of an
RGB image.
Full color
Red Green Blue
Figure 15.5 A full-color image and its RGB component images
4
The CMY and CMYK color model
Cyan, magenta, and yellow are the primary colors of pigments. Most
printing devices such as color printers and copiers require CMY data
input or perform an RGB to CMY conversion internally. This conversion
is performed using the equation
𝐶 1 𝑅
[𝑀] = [1] − [𝐺]
𝑌 1 𝐵
where, all color values have been normalized to the range [0, 1].
In printing, combining equal amounts of cyan, magenta, and yellow
produce muddy-looking black. In order to produce true black, a fourth
color, black, is added, giving rise to the CMYK color model.
The figure below shows the CMYK component images of an RGB image.
Full color Cyan Magenta
Yellow Black
Figure 15.6 A full-color image and its CMYK component images
5
The HSI color model
The RGB and CMY color models are not suited for describing colors in
terms of human interpretation. When we view a color object, we describe
it by its hue, saturation, and brightness (intensity). Hence the HSI color
model has been presented. The HSI model decouples the intensity
component from the color-carrying information (hue and saturation) in a
color image. As a result, this model is an ideal tool for developing color
image processing algorithms.
The hue, saturation, and intensity values can be obtained from the RGB
color cube. That is, we can convert any RGB point to a corresponding
point is the HSI color model by working out the geometrical formulas.
Converting colors from RGB to HSI
The hue H is given by
𝜃 𝑖𝑓 𝐵 ≤ 𝐺
𝐻={ }
360 − 𝜃 𝑖𝑓 𝐵 > 𝐺
Where
1
[(𝑅 − 𝐺) + (𝑅 − 𝐵)]
𝜃 = 𝑐𝑜𝑠−1 { 2 }
√(𝑅 − 𝐺)2 + (𝑅 − 𝐵)(𝐺 − 𝐵)
The saturation S is given by
3
𝑆 =1− [min (𝑅, 𝐺, 𝐵)]
(𝑅 + 𝐺 + 𝐵)
The intensity I is given by
1
𝐼 = (𝑅 + 𝐺 + 𝐵)
3
6
All RGB values are normalized to the range [0,1].
7
Converting colors from HSI to RGB
The applicable equations depend on the value of H:
If 0° ≤ 𝐻 < 120° :
𝐵 = 𝐼(1 − 𝑆)
𝑆 cos 𝐻
𝑅 = 𝐼 [1 + ]
cos (60°− 𝐻)
𝐺 = 3𝐼 − (𝑅 + 𝐵)
If 120° ≤ 𝐻 < 240° :
𝐻 = 𝐻 − 120°
𝑅 = 𝐼(1 − 𝑆)
𝑆 cos 𝐻
𝐺 = 𝐼 [1 + ]
cos (60°−𝐻)
𝐵 = 3𝐼 − (𝑅 + 𝐺)
If 240° ≤ 𝐻 ≤ 360° :
𝐻 = 𝐻 − 240°
𝐺 = 𝐼(1 − 𝑆)
𝑆 cos 𝐻
𝐵 = 𝐼 [1 + ]
cos (60°−𝐻)
𝑅 = 3𝐼 − (𝐺 + 𝐵)
The next figure shows the HSI component images of an RGB image.
8
Full color
Hue Saturation Intensity
Figure 15.7 A full-color image and its HSI component images
Basics of Full-Color Image Processing
Full-color image processing approaches fall into two major categories:
• Approaches that process each component image individually and
then form a composite processed color image from the individually
processed components.
• Approaches that work with color pixels directly.
In full-color images, color pixels really are vectors. For example, in the
RGB system, each color pixel can be expressed as
𝑐𝑅(𝑥, 𝑦) 𝑅(𝑥, 𝑦)
𝑐(𝑥, 𝑦) = [𝑐𝐺(𝑥, 𝑦)] = [𝐺(𝑥, 𝑦)]
𝑐𝐵(𝑥, 𝑦) 𝐵(𝑥, 𝑦)
For an image of size M×N, there are MN such vectors, c(x, y), for x = 0,1,
9
2,...,M-1; y = 0,1,2,...,N-1.
10
Color Transformation
As with the gray-level transformation, we model color transformations
using the expression
𝑔(𝑥, 𝑦) = 𝑇[𝑓(𝑥, 𝑦)]
where f(x, y) is a color input image, g(x, y) is the transformed color output
image, and T is the color transform.
This color transform can also be written
𝑠𝑖 = 𝑇𝑖(𝑟1, 𝑟2, … , 𝑟𝑛) 𝑖 = 1,2, … , 𝑛
For example, we wish to modify the intensity of the image shown in
Figure 14.8(a) using
𝑔(𝑥, 𝑦) = 0.7𝑓(𝑥, 𝑦)
• In the RGB color space, three components must be transformed:
𝑠𝑖 = 0.7𝑟𝑖 𝑖 = 1,2,3
• In CMY space, also three component images must be transformed
𝑠𝑖 = 0.7𝑟𝑖 + 0.3 𝑖 = 1,2,3
• In HSI space, only intensity component 𝑟3is transformed
𝑠3 = 0.7𝑟3
(a) (b)
Figure 15.8 (a) Original image. (b) Result of decreasing its intensity
11