U-3 Color Image
L-12
Processing
Color models–RGB, YUV, HSI;
L-13 Color transformations-formulation, color complements, color
slicing, tone and color corrections. Color image smoothing and
sharpening;
L-14 Color Segmentation
Digital Image Processing, 3rd edition by Gonzalez and Woods
L-12
Color models–
1. RGB
2. YUV
3. HSI
Color Fundamentals
Color Image Processing is divided into two major areas:
1) Full-color processing
Images are acquired with a full-color sensor, such
as a color TV camera or color scanner
Used in publishing, visualization, and the Internet
2) Pseudo color processing
Assigning a color to a particular monochrome intensity or
range of intensities
Color Fundamentals
• In 1666, Sir Isaac Newton discovered that when a beam of
sunlight passes through a glass prism, the emerging beam
of light is split into a spectrum of colors ranging from violet
at one end to red at the other
Color Fundamentals
• Visible light as a narrow band of frequencies in EM
• A body that reflects light that is balanced in all visible
wavelengths appears white
• However, a body that favors reflectance in a limited range of
the visible spectrum exhibits some shades of color
• Green objects reflect wavelength in the 500 nm to 570 nm
range while absorbing most of the energy at other
wavelengths
Color Fundamentals
If the light is achromatic (void of color), its only attribute is its
intensity, or amount
Chromatic light spans EM from 380 to 780 nm
Three basic quantities to describe the quality:
1) Radiance is the total amount of energy that flows from the
light source, and it is usually measured in watts (W)
2) Luminance, measured in lumens (lm), gives a measure of
the amount of energy an observer perceives from a light
source
For example, light emitted from a source operating in the far
infrared region of the spectrum could have significant energy
(radiance), but an observer would hardly perceive it; its
luminance would be almost zero
Color Fundamentals
• 3) Brightness is a subjective descriptor that is practically
impossible to measure. It embodies the achromatic notion
of intensity and is one of the key factors in describing color
sensation
Color Fundamentals
• Cones are the sensors in the eye responsible for color vision. 6 to 7
million cones in the human eye can be divided into three principle
categories: red, green, and blue
Color Fundamentals
• Approximately 65% of all cones are sensitive to red light,
33% are sensitive to green light, and only about 2% are
sensitive to blue (but the blue cones are the most sensitive)
• According to CIE (International Commission on
Illumination) wavelengths of blue = 435.8 nm, green =
546.1 nm, and red = 700 nm
Color Fundamentals
Color Fundamentals
• To distinguish one color from another are brightness, hue, and
saturation
• Brightness embodies the achromatic notion of intensity
• Hue is an attribute associated with the dominant wavelength in a
mixture of light waves. Hue represents dominant color as perceived
by an observer. Thus, when we call an object red, orange, or yellow,
we are referring to its hue
• Saturation refers to the relative purity or the amount of white light
mixed with a hue. The pure spectrum colors are fully saturated. Colors
such as pink and lavender are less saturated, with the degree of
saturation being inversely proportional to the amount of white light
added
Color Fundamentals
• Hue and saturation taken together are called Chromaticity
• Therefore a color may be characterized by its brightness
and chromaticity
• The amounts of red, green, and blue needed to form any
particular color are called the Tristimulus values and are
denoted, X, Y, and Z, respectively
• Tri-chromatic coefficients
X Y Z
x y z
XY XYZ XY
Z Z
xyz
1
Color Fundamentals
• Another approach for specifying colors is to use the
CIE chromaticity diagram
Color Fundamentals
• For any value of x and y, the corresponding value of z
is obtained by noting that z = 1-(x+y)
• 62% green, 25% red, and 13% blue
• Pure colors are at boundary which are fully saturated
• Any point within boundary represents some mixture
of spectrum colors
• Equal energy and equal fractions of the three
primary colors represents white light
• The saturation at the point of equal energy is zero
• Chromaticity diagram is useful for color mixing
Color Fundamentals
Color Gamut produced
by RGB monitors
Color Gamut produced
by high quality color
printing device
Color Fundamentals
• Printing gamut is irregular because color printing is a
combination of additive and subtractive color mixing, a
process that is much more difficult to control than that of
displaying colors on a monitor, which is based on the
addition of three highly controllable light primaries
Color Models
• Also known as color space or color system
• Purpose is to facilitate the specification of colors in some standard,
generally accepted way
• Oriented either toward hardware (such as monitors and printers) or
toward applications (color graphics for animation)
• Hardware oriented models most commonly used in practices are the
RGB model for color monitors or color video cameras, CMY and CMYK
models for color printing, and the HSI model, which corresponds
closely with the way humans describe and interpret color.
• HSI model also has the advantage that it decouples the color and
gray-scale information in an image
RGB Color Models
• Each color appears in its primary spectral components
of red, green, and blue.
• Model based on a Cartesian coordinate system
RGB Color Models
• RGB primary values are at three corners; the secondary colors cyan,
magenta, and yellow are at the other corners; black is at the origin;
and white is at the corner
• In this model, the gray scale (points of equal RGB values) extends
from black to white along the line joining these two points
• The different colors in this model are points on or inside the cube,
and are defined by vectors extending from the origin
• RGB images consist three images (R, G, and B planes)
• When fed into an RGB monitor, these three images combine on the
screen to produce a composite color image
RGB Color Models
• Number of bits used to represent each pixel in RGB space is
called the pixel depth
• RGB image has 24 bit pixel depth
• True color or full color image is a 24 bit RGB image
• Total colors in 24-bit image is (28)3 = 16,777,216
RGB Color Models
RGB Color Models
• Many systems in use today are limited to 256 colors
• Many applications require few colors only
• Given the variety of systems in current use, it is of
considerable interest to have subset of colors that are likely to be
reproduced faithfully, this subset of colors are 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
• On the assumption that 256 colors is the minimum number of
colors that can be reproduced faithfully
• Forty of these 256 colors are known to be processed differently by
various operating systems
RGB Color Models
CMY and CMYK Color Models
• CMY are the secondary colors of light, or, alternatively, the
primary colors of pigments
• For example, when a surface coated with cyan pigment is
illuminated with white light, no red light is reflected from
the surface because cyan subtracts red light from reflected
white light
• Color printers and copiers require CMY data input or
perform RGB to CMY conversion internally
C 1 R
M 1 G
1
Y
CMY and CMYK Color Models
• 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, a fourth color, black,
is added, giving rise to the CMYK color model
HSI Color Model
• Unfortunately, the RGB, CMY, and other similar color models are not
well suited for describing colors in terms that are practical for human
interpretation
• For example one does not refer to the color of
an
automobile by giving the percentage of the primaries composing its
color
• We do not think of color images as being composed of three primary
images that combine to form that single image
• When human view a color object, we describe it by its hue, saturation,
and brightness
HSI Color Model
Converting Colors from RGB to HSI
if B
H G
360
if B G
1
(R G) (R B)
cos1 2
2
1/
(R G) (R B)(G B) 2
3
S1
RG
B
1
I (R G
B) 3
Converting Colors from HSI to RGB
RG sector: 0 H 120 GB sector:120 H 240
H H 120
R I 1 S cos H
o R I (1 S
cos(60 H ) )
B I (1 S G I 1 S cos H
o
) cos(60 H )
G 1 (R
B) B 1 (R
BR sector: 240 H G)
360 H H 240
B I1
S coso H
cos(60 H )
G I (1
S)
R 1 (G
B)
HSI Color Model
• HSI (Hue, saturation, intensity) color model, decouples the
intensity component from the color-carrying information
(hue and saturation) in a color image
Example: HSI Components of RGB Colors
RGB
Image Hue
Saturation Intensity
(Images from Rafael C. Gonzalez and Richard E. Wood,
Digital Image Processing, 2nd Edition.
Example: Manipulating HSI Components
RGB
Image Hue Hue Saturation
Saturation Intensity Intensity RGB
Image
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
L-13
A. Color transformations-
1.Formulation
2.Color Complements
3.Color Slicing
4. Tone
5.Color Corrections
B. Color image smoothing and
sharpening
Color Transformation
Use to transform colors to colors.
Formulation:
g( x, y) T f ( x, y)
f(x,y) = input color image, g(x,y) = output color image
T = operation on f over a spatial neighborhood of (x,y)
When only data at one pixel is used in the transformation,
we can express the transformation as:
si Ti (r1, r2 ,K , i= 1, 2, …, n
rn )
Where ri = color component of f(x,y) For RGB images, n = 3
si = color component of g(x,y)
Example: Color Transformation
Formula for RGB:
sR ( x, y) krR ( x,
y)
sG ( x, y) krG ( x,
y)
Formula krB ( x,
fory)HSI:
sB ( x, k = 0.7
y)
sI ( x, y) krI ( x,
y)
Formula for CMY: I H,S
sC ( x, y) krC ( x, y) (1 k
)
These 3 transformations
sM ( x, y) krM ( x, y) (1 give the same results.
k)
(Images from Rafael C. Gonzalez and Richard E.
sY ( x, y) krY ( x, y) (1 k Wood, Digital Image Processing, 2nd Edition.
)
Color Complements
Color complement replaces each color with its opposite color in
the color circle of the Hue component. This operation is analogous to
image negative in a gray scale image.
Color circle
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Complement Transformation
Example
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Slicing Transformation
We can perform “slicing” in color space: if the color of each pixel is far from a
desired color more than threshold distance, we set that color to some specific
color such as gray, otherwise we keep the original color unchanged.
W Set to gray
si 0.5
if r a
j j
2 any 1 jn
otherwise Keep the original
i= 1, 2, …, n color
or
ri
n rj a j R Set to gray
0.5 if
2 2
0
s i j
otherwise
1 Keep the original
i= 1, 2, …, n color
ri
Color Slicing Transformation Example
After color slicing
Original image
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Tonal Correction Examples
In these examples, only
brightness and contrast are
adjusted while keeping
color unchanged.
This can be done by
using the same
transformation for all RGB
components.
Contrast
enhancement Power law
transformations
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Balancing Correction Examples
Color imbalance: primary color components in white
area are not balance. We can measure these components
by using a color spectrometer.
Color balancing can be
performed by adjusting
color components
separately as seen in this
slide.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Image Smoothing
2 Methods:
1. Per-color-plane method: for RGB, CMY color models
Smooth each color plane using moving averaging
and the combine back to RGB
2. Smooth only Intensity component of a HSI image while
leaving H and S unmodified.
Note: 2 methods are not equivalen
Color Image Smoothing Example (cont.)
Color image Red
Green Blue
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Image Smoothing Example (cont.)
Color image
HSI Components
Hue Saturation Intensity
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Image Smoothing Example (cont.)
Smooth all RGB components Smooth only I component of HSI
(faster)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Image Smoothing Example (cont.)
Difference between
smoothed results from
2 methods in the
previous slide.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Image Sharpening
We can do in the same manner as color image smoothing:
1. Per-color-plane method for RGB,CMY images
2. Sharpening only I component of a HSI image
Sharpening all RGB components Sharpening only I component of HSI
Color Image Sharpening Example (cont.)
Difference between
sharpened results from
2 methods in the
previous slide.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
L-14
Color Segmentation
Color Segmentation
2 Methods:
1. Segmented in HSI color space:
A thresholding function based on color information in H and
S Components. We rarely use I component for color image
segmentation.
2. Segmentation in RGB vector space:
A thresholding function based on distance in a color vector
space.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Segmentation in HSI Color Space
Color image Hue
1 2
3 4
Saturation Intensity (Images from Rafael C.
Gonzalez and Richard
E. Wood, Digital Image
Processing, 2nd Edition.
Color Segmentation in HSI Color Space (cont.)
Binary thresholding of S component
with T = 10% Product of 2 and 5
5 6
Red pixels
7 8
(Images from Rafael C.
Gonzalez and Richard
E. Wood, Digital Image Histogram of 6 Segmentation of red color
Processing, 2nd Edition.
pixels
Color Segmentation in HSI Color Space (cont.)
Color image Segmented results of red pixels
(Images from Rafael C.
Gonzalez and Richard
E. Wood, Digital Image
Processing, 2nd Edition.
2. Color Segmentation in RGB Vector Space
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
1.Each point with (R,G,B) coordinate in the vector space represents
one color.
2. Segmentation is based on distance thresholding in a vector space
if D(c( x, y), cT )
g( x, y)
0 Tif D(c( x, y), cT )
1
T
cT = color to be segmented.
D(u,v) = distance function c(x,y) = RGB vector at pixel (x,y).
Example: Segmentation in RGB Vector Space
Color image
Reference color cT to be segmented
cT average color of pixel in the box
Results of segmentation in
RGB vector space with
Threshold value
T = 1.25 times the SD of R,G,B values
In the box
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Gradient of a Color Image
Since gradient is define only for a scalar image, there is no
concept of gradient for a color image. We can’t compute gradient of
each
color component and combine the results to get the gradient of a
color image. Red Green We see
Blue 2 objects.
We see
4 objects.
Edges
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Gradient of a Color Image (cont.)
One way to compute the maximum rate of change of a color
image which is close to the meaning of gradient is to use the
following formula: Gradient computed in RGB color space:
1
F ( )
2
1
(g g
xx yy ) ( gxx g yy ) cos 2 2g
xy sin
2
2
2g x y
1
gxx g yy
tan1
2
2 2 2
R 2 G 2 B 2 R G B
gxx g yy
x x y y
x y
g xy R R G G B B
x y x y x
y
Gradient of a Color Image Example
2
Original Obtained using
image the formula
in the previous
slide
Sum of
gradients of Difference
each color between
component 22 and 33
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Gradient of a Color Image Example
Red Green Blue
Gradients of each color component
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.