Module 4.2 - Colour Image Processing
Module 4.2 - Colour Image Processing
We notice that: 𝑥 + y + z = 1
▪ For any wavelength of light in the visible spectrum, the
tristimulus values needed to produce the color
corresponding to that wavelength can be obtained
directly from curves or tables that have been compiled
from extensive experimental results.
▪ Alternative approach – use the CIE chromaticity
diagram, which shows color composition as a function
of x (red) and y (green).
▪ For any value of x and y, the corresponding value of z
(blue) is obtained as
𝑧 = 1– (𝑥 + 𝑦)
▪ The positions of the various spectrum colors - from
violet at 380 nm to red at 780 nm - are indicated around
the boundary - pure colors.
▪ Any point not on the boundary but within the diagram
represents some mixture of spectrum colors.
▪ The point of equal energy - corresponds to equal
fractions of the three primary colors – the CIE standard
for white light.
▪ Any point located on the boundary of the chromaticity
chart is fully saturated.
▪ As a point leaves boundary and approaches the point of
equal energy, more white light is added to the color and it
▪ becomes less saturated.
▪ The saturation at the point of equal energy is zero.
▪ The chromaticity diagram is useful for color mixing.
▪ Straight-line segment joining any two points in the
diagram defines all the different color variations that can
be obtained by combining these two colors additively.
▪ Line drawn from the point of equal energy to any point
on the boundary of the chart will define all the shades of
that particular spectrum color.
▪ How do we extend this to 3 Colors?
o Simply draw connecting lines to each of the three color points.
The result is a Triangle, and any color on the boundary or inside
the triangle can be produced by various combinations of the 3
colours.
▪ A triangle with 3 fixed vertices cannot enclose the entire
colour region.
▪ Triangle in earlier image shows typical range of colours
produced by RGB monitors (Colour Gamut)
▪ Irregular region inside triangle represents the Colour
Gamut of modern high quality colour printing devices.
▪ Printer colour gamut boundary is irregular because
printing is a combination of additive and subtractive
colour mixing – very hard to control, compared to
displays.
Color Models
▪ Purpose of a color model (color space or color system) is
to facilitate the specification of colors in some standard,
generally accepted way.
▪ In essence, 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.
▪ Most color models are oriented either toward
o Hardware (such as for color monitors and printers)
o Applications where color manipulation is a goal (such as in the
creation of color graphics for animation).
▪ Most common colour models – RGB for colour
monitors, CMY or CMYK for printing, HSI model for
applications where processing is to be similar to human
eye.
RGB Colour Model
▪ Here, each color appears in its primary spectral
components of red, green, and blue.
▪ Model is based on a Cartesian coordinate system.
o RGB primary values are at three corners
o Secondary colors cyan, magenta, and yellow are at three other
corners
o Black is at the origin
o White is at the corner farthest from the origin.
o Gray scale (points of equal RGB values) extends from black to
white along the line joining these two points.
▪ For convenience, the assumption is that all color values
have been normalized (ie. In the range [0,1])
▪ Images represented in the RGB color model consist of
three component image, one for each primary color.
▪ In RGB monitor, 3 channels (layers) combine to form
composite colour image.
▪ The number of bits used to represent each pixel in RGB
space is called the pixel depth.
▪ In a RGB image where each of the red, green, and blue
images is an 8-bit image, each RGB color pixel [triplet
of values (R,G,B)] has depth of 24 bits (3 image planes
times the number of bits per plane).
▪ The term full-color image is used often to denote a 24-bit
RGB color image.
▪ The total number of colors in a 24-bit RGB image is
(28)3 = 16,777,216
▪ A convenient way to
view these colors is to
generate color planes
(faces or cross sections of
the cube).
▪ This is accomplished
simply by fixing one of
the three colors and
allowing the other two to
vary.
▪ Consider a cross-
sectional plane through
the center of the cube and
parallel to the GB-plane
in Fig. 6.8 is the plane
(127, G, B) for G, B = 0,
1,2, ... ,255.
▪ A color image can be acquired by using three filters sensitive
to red, green, and blue, respectively.
▪ When we view a color scene with a monochrome camera
equipped with one of these filters, the result is a monochrome
image whose intensity is proportional to the response of that
filter.
▪ Repeating this process with each filter produces three
monochrome images that are the RGB component images of
the color scene.
▪ While high-end display cards and monitors provide a
reasonable rendition of the colors in a 24-bit RGB image,
many systems are limited to 256 colors.
▪ In many applications we need only a few hundred (or
fewer) colours.
▪ So, we need a subset of colours that are likely to be
reproduced faithfully, reasonably independently of
viewer hardware capabilities.
▪ This subset of colors is called the set of safe RGB colors,
or the set of all-systems-safe colors.
▪ In Internet applications, they are called safe Web colors
or safe browser colors.
▪ Assuming 256 colors is the minimum number of colors
that can be reproduced faithfully by any display system,
we need a standard notation to refer to these colors.
▪ 40 of these 256 colours are processed differently by
various OSes. Remaining 216 colours are common to
most systems – de facto standard for safe colours.
▪ Each of the 216 safe colors is formed from three RGB
values as before, but each value can only be 0, 51, 102,
153, 204 or 255.
▪ Thus, RGB triplets give us a possible 63 = 216 colours.
▪ These numbers are usually represented in hex format.
▪ Since it takes three numbers to form an RGB color, each
safe color is formed from three of the two-digit hex
numbers in Table.
o Eg: Purest Red would be FF0000, Blue would be 0000FF,
Magenta would be FF00FF
o Black would be 000000, White would be FFFFFF
The CMY and CMYK Color Models
▪ Subtractive Colour Models, used for Pigmentation.
o Eg- when a surface coated with cyan pigment is illuminated with white light, no
red light is reflected from the surface. That is, cyan subtracts red light from
reflected white light.
▪ Most color printers and copiers require CMY data input or perform an
RGB to CMY conversion internally.
▪ When all colors are normalized, RGB to CMY Conversion is done as:
𝐶 1 𝑅
𝑀 = 1 − 𝐺
𝑌 1 𝐵
▪ This color model is used for generating hardcopy output, so the inverse
operation from CMY to RGB generally is of little practical interest.
▪ Equal amounts of the pigment primaries, cyan, magenta, and yellow
should produce black.
▪ In practice, combining these colors for printing produces a muddy-
looking black.
▪ So, in order to produce true black (predominant color in printing), a
fourth color, black, is added, giving rise to the CMYK color model.
The HSI Color Model
▪ RGB and CMY models are easy to implement and
convert, and are ideal for hardware implementations.
▪ They also match well with human visual system, which
is sensitive to R, G and B primaries.
▪ Unfortunately, these color models are not well suited for
describing colors in terms that are practical for human
interpretation.
o Eg: Human description does not express colours in terms of
composition of primary colours, but in terms of brightness,
saturation, hue, etc.
▪ This gives rise to the HSI (or HSV) model, where
colours are represented in terms of their Hue, Saturation
and Intensity – model decouples intensity information
from the chrominance information.
▪ RGB color image can be viewed as three monochrome
intensity images (representing red, green, and blue).
▪ Stand the RGB colour cube on the black (0,0,0) vertex,
with the white vertex (1, 1, 1) directly above it, as shown
in figure.
▪ Where:
1
𝑅 − 𝐺 + (𝑅 − 𝐵)
𝜃 = 𝑐𝑜𝑠 −1 2
1ൗ
(𝑅 − 𝐺)2 +(𝑅 − 𝐵)(𝐺 − 𝐵) 2
▪ Saturation Component is given by:
3
𝑆 =1− [min 𝑅, 𝐺, 𝐵 ]
𝑅+𝐺+𝐵
▪ Intensity Component is given by:
1
𝐼 = (𝑅 + 𝐺 + 𝐵)
3
▪ Assumptions:
o RGB values have been normalized to the range [0,1]
o Angle 𝜃 is measured with respect to red axis of the HSI space
▪ Hue normalized to the range [0,1] by dividing by 360°
▪ Other two HSI components already are in this range if
the given RGB values are in the interval [0,1].
HSI to RGB Conversion
▪ Given values of HSI in the interval [0, 1], Conversions
equations depend on the values of H.
▪ 3 sectors of interest, corresponding to the 120° intervals
in the separation of primaries.
▪ We begin by multiplying H by 360°, which returns the
hue to its original range of [0°, 360°].
➢RG sector (𝟎° ≤ 𝑯 < 𝟏𝟐𝟎°):
▪ When H is in this sector, the RGB components are given
by:
𝐵 =𝐼 1−𝑆
𝑆 cos 𝐻
𝑅 =𝐼 1+
cos(60° − 𝐻)
𝐺 = 3𝐼 − (𝑅 + 𝐵)
➢GB sector (𝟏𝟐𝟎° ≤ 𝑯 < 𝟐𝟒𝟎°):
▪ When H is in this sector, we first subtract 120° from it.
𝐻 = 𝐻 − 120°
▪ The RGB components are given by:
𝑅 =𝐼 1−𝑆
𝑆 cos 𝐻
𝐺 =𝐼 1+
cos(60° − 𝐻)
𝐵 = 3𝐼 − (𝑅 + 𝐺)
➢BR sector (𝟐𝟒𝟎° ≤ 𝑯 < 𝟑𝟔𝟎°):
▪ When H is in this sector, we first subtract 240° from it.
𝐻 = 𝐻 − 240°
▪ The RGB components are given by:
𝐺 =𝐼 1−𝑆
𝑆 cos 𝐻
𝐵 =𝐼 1+
cos(60° − 𝐻)
𝑅 = 3𝐼 − (𝐺 + 𝐵)
Problem
▪ Convert RGB = (0.683, 0.1608, 0.1922) to HSI model
values
𝒇 𝒙, 𝒚 = 𝒄𝒌 if 𝒇 𝒙, 𝒚 ∈ 𝑽𝒌
where 𝑐𝑘 is the color associated with the 𝑘-th intensity interval 𝑉𝑘
defined by the partitioning planes at l=k-1 and l=k.
▪ Idea of planes is useful primarily for a geometric
interpretation of the intensity-slicing technique.
▪ Here is an alternative representation that defines the
same mapping as shown earlier: