Digital Image Processing
Digital Image Processing
SVCE TIRUPATI
COURSE MATERIAL
UNIT 5
COURSE B.TECH
DEPARTMENT 4-1
B Chandrakala
Assistant Professor
PREPARED BY
Revised by
(Faculty Name/s) A Krishna Mohan
Asst professor
Version 2
DIP-UNIT-V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
TABLE OF CONTENTS – UNIT 5
S. NO CONTENTS PAGE NO.
1 COURSE OBJECTIVES 1
2 PREREQUISITES 1
3 SYLLABUS 1
4 COURSE OUTCOMES 1
5 CO - PO/PSO MAPPING 1
6 LESSON PLAN 2
7 ACTIVITY BASED LEARNING 2
8 LECTURE NOTES 3
5.1 Introduction 3
5.2 Color Models 5
5.2.1 RGB color model 5
5.2.2 HSI color model 6
5.2.3 YUV color model 6
5.3 Color Transformations 8
5.3.1 Formulation 9
5.3.2 Color complements 10
5.4 Color Slicing 10
5.5 Tone and Color Corrections 11
5.6 Smoothing and Sharpening 13
5.7 Color Segmentation 115
9 PRACTICE QUIZ 18
10 ASSIGNMENTS 20
11 PART A QUESTIONS & ANSWERS (2 MARKS QUESTIONS) 21
12 PART B QUESTIONS 22
13 SUPPORTIVE ONLINE CERTIFICATION COURSES 22
14 REAL TIME APPLICATIONS 22
15 CONTENTS BEYOND THE SYLLABUS 23
16 PRESCRIBED TEXT BOOKS & REFERENCE BOOKS 23
17 MINI PROJECT SUGGESTION 24
DIP-UNIT-V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
Course Objectives
The objectives of this course is to
To introduce fundamentals of Image Processing.
To expose various intensity transformations in spatial and frequency domains.
To dissimilate various segmentation techniques for images.
To impart concepts of wavelets and various coding techniques for image
compression.
To teach various color models and to introduce the concepts of color image
segmentation.
1. Prerequisites
Students should have knowledge on
1. Preliminary Mathematics
2. Principals of Signals and systems
2. Syllabus
UNIT V
Color Fundamentals, Color Models - RGB, YUV, HIS, Pseudo Color, Full Color image
processing, Color transformations – formulation, Color complements, Color slicing,
tone and Color corrections. Color image smoothing and Sharpening.
.
3. Course outcomes
Analyze various types of images mathematically.
Compare image enhancement methods in spatial and frequency domains.
Demonstrate various segmentation algorithms for given image.
Justify DCT and wavelet transform techniques for image compression.
Describe various color models for color image processing.
4. Co-PO / PSO Mapping
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 P10 PO11 PO12 PSO1 PSO2
CO1 3 3 2 3 3
CO2 3 3 2 2 3 3 3
CO3 3 3 3 2 2 3 3 3
CO4 3 3 3 3 2 2 3 3 3
CO5 3 3 2 3 3 3
1|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
5. Lesson Plan
1 Introduction T1
7 Formulation T1, R1
2|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
8. Lecture Notes
5.1 INTRODUCTION
Color is the perceptual sensation of light in the visible range incident upon the
retina. Color is the most visually striking feature of any image and it has a
significant bearing on the scenic beauty of an image, To understand color, it is
necessary to understand the nature of light. Light exhibits a dual nature. It λ rise to
electric impulses, which on reaching the brain are translated into color. Different
wavelengths of light are perceived as different colors. However, not every
wavelength can be perceived by the human eye. The wavelengths between
380nm and 780nm form the visible spectrum.
Light and Color
The frequency of light determines the color. The amount of light determines the
intensity. The famous Einstein relation is given by
ℎ𝑐
E = hv =
𝜆
As stated earlier, the visible spectrum is approximately between 400nm to 700 nm.
The human visual system perceives electromagnetic energy having wavelengths
in the range 400-700 nm as visible light. Lightness of brightness refers to the
amount of light a certain color reflects or transmits. Light that has a dominant
frequency or set of frequencies is called chromatic. Achromatic light has no color
and it contributes only to quantity or intensity. The intensity is determined by the
energy, whereas brightness is determined by the perception of the color; hence it
is psychological. Color depends primarily on the reflectance properties of an
object.
COLOR FORMATION
(iii) Pigmentation
3|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
Additive color formation: In additive color formation, the spectral distributions
corresponding to two or more light rays get added. The resulting color is the sum
of the number of photons in the same range present in the component colors.
The additive color-formation is employed in TV monitors.
Subtractive color formation: Subtractive color formation occurs when the light is
passed or transmitted through a light filter. A light filter partly absorbs part of the
light that reaches it and transmits the rest. For example, a green filter lets through
the radiation in the green part of the spectrum, while radiation with other
wavelengths is blocked. Several filters can be used in series, the resulting color
being made up of those wavelengths that can go through all of them.
Subtractive color formation occurs when color slides are projected onto a screen.
Color fundamentals
Color are seen as variable combinations of the primary colors of light: Red(R),
Green(G), Blue(B). The primary colors can be mixed to produce the secondary
colors: Magenta(Red+Blue), Cyan(Green+Blue), yellow(Red+Green). Mixing the
three primaries, or a secondary with its opposite primary color, produces white
light.
4|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
RGB colors are used for color TV, Monitors, and video cameras.
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.CMY colors are used for color printing.
Color characteristics
The characteristics used to distinguish one color from another are:
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
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.
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.
Fig 5.3. A Full color image and its RGB component images
5.2.2 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
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
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
7|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
The Y′UV model defines a color space in terms of one luma component (Y′) and
two chrominance (UV) components. The Y′ channel saves black and white data.
If there is only the Y component and there are no U and V components, then the
graph represented is grayscale.
The Y component can be calculated with the following equation: Y = 0. 299R+ 0.
587G+ 0. 114*B, which is the commonly used grayscale formula. The color
difference U and V are compressed by B-Y and R-Y in different proportions. The
YUV model is used in PAL and SECAM composite color video standards. Previous
black and white and white systems used only luma (Y’) information.
Color information (U and V) was added separately via a sub-carrier so that a
black- and-white receiver would still be able to receive and display a color
picture transmission in the receiver's native black- and-white format.
The Digital Video Signal or YUV
YUV has basically three components:
the luminance or green channel (Y),the color value of the luminance deducted
from the color red (R-Y),the color value of the luminance deducted from the color
blue (B-Y).When digitized, these three parameters of the component video signal
are assigned a numeric value.
5.3 COLOR TRANSFORMATIONS
The techniques described in this section, collectively called color transformations,
deal with processing the components of a color image within the context of a
8|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
single color model, as opposed to the conversion of those components between
models (like the RGB-to-HSI and HSI-to-RGB conversion transformations.
5.3.1 Formulation
where f(x, y) is a color input image, g(x, y) is the transformed or processed color
output image T is an operator on f over a spatial neighborhood of (x, y) The
principal difference between this equation and equation used in segmentation is
in its interpretation. The pixel values here are triplets or quartets (ie., groups of
three or four values) from the color space chosen to represent the
images.Analogous to the approach we used to introduce the basic intensity
trans- formations we will restrict attention in this section to color
transformations of the form
i =1,2,...,n
where, for notational simplicity, r, and s, are variables denoting the color
components of f(x, y) and g(x, y) at any point (x, y), n is the number of color
components, and {T1, T2,..., T) is a set of transformation or color mapping functions
that operate on r, to produce s i. Note that n transformations, I, combine to
implement the single transformation function, T. The color space chosen to
describe the pixels of ƒ and g determines the value of n. If the RGB color space is
selected, for example, n = 3 and r₁, r2, and r3, denote the red, green, and blue
components of the input image, respectively. If the CMYK or HSI color spaces are
chosen, n = 4 or n = 3.
For example, that we wish to modify the intensity of the full- color image using
g(x, y) = kf(x, y)
Where 0 < k <1 . In the HSI color space, this can be done with the
simple transformation
s3 = k*r3
9|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
Where s₁ = r1 and s2 = r2 Only HSI intensity component r3 is modified. In the RGB
color space, three components must be transformed:
si = k*ri
i =1,2,3
5.3.2 Color Complements
The hues directly opposite one another on the color circle of Figare called
complements. Our interest in complements stems from the fact that they are
analogous to the gray-scale negatives(image negatives).As in the gray-scale case,
color complements are useful for enhancing detail that is embedded in dark
regions of a color image-particularly when the regions are dominant in size.
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
prototypical (e.g., average) color with components, the necessary set of
transformations is
These transformations highlight the colors around the prototype by forcing all
other colors to the midpoint of the reference color space (an arbitrarily chosen
neutral point). For the RGB color space, for example, a suitable neutral point is
middle gray or color (0.5, 0.5, 0.5). If a sphere is used to specify the colors of
interest, the above equation becomes
Here, Ro is the radius of the enclosing sphere (or hyper sphere for n > 3) and (a,
a... a) are the components of its center (i.e., the prototypical color) other useful
variations of Eqs include implementing multiple color prototypes and reducing
the intensity of the colors outside the region of interest-rather than setting them to
a neutral constant.
11|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
fact, the colors of the monitor should represent accurately any digi- tally scanned
source images, as well as the final printed output. This is best accomplished with a
device-independent color model that relates the color gamuts (see Section 6.1)
of the monitors and output devices, as well as any other devices being used, to
one another. The success of this approach is a function of the quality of the color
profiles used to map each device to the model and the model itself. The model of
choice for many color management systems (CMS) is the CIE Lab model, also
called CIELAB (CIE [1978], Robertson [1977]). The Lab color components are given
by the following equations:
and Xw. Yw, and Zw are reference white tristimulus values-typically the white of a
perfectly reflecting diffuser under CIE standard D65 illumination (defined by x =
0.3127 and y = 0.3290 in the CIE chromaticity diagram of Fig. 6.5). The Lab color
space is colorimetric (i.e., colors perceived as matching are encoded identically),
perceptually uniform (i.e., color differences among various hues are perceived
uniformly-see the classic paper by MacAdams [1942]), and device independent.
While not a directly displayable format (conversion to another color space is
required), its gamut encompasses the entire visible spectrum and can represent
accurately the colors of any display, print, or input device. Like the HSI system, the
L*a*b* system is an excellent decoupler of intensity (represented by lightness L*)
12|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
and color (represented by a* for red minus green and b* for green minus blue),
making it useful in both image manipulation (tone and contrast editing) and
image compression applications.
The principal benefit of calibrated imaging systems is that they allow tonal and
color imbalances to be corrected interactively and independently-that is, in two
sequential operations. Before color irregularities, like over- and under- saturated
colors, are resolved, problems involving the image's tonal range are corrected.
The tonal range of an image, also called its key type, refers to its general
distribution of color intensities. Most of the information in high-key im- ages is
concentrated at high (or light) intensities; the colors of low-key images are
located predominantly at low intensities; middle-key images lie in between. As in
the monochrome case, it is often desirable to distribute the intensities of a color
image equally between the highlights and the shadows. The following examples
demonstrate a variety of color transformations for the correction of tonal and
color imbalances.
13|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
(x, y) in an RGB color image. The average of the RGB component vectors in
this neighborhood is
We recognize the components of this vector as the scalar images that would be
obtained by independently smoothing each plane of the starting RGB image
using conventional gray-scale neighborhood processing. Thus, we conclude that
smoothing by neighborhood averaging can be carried out on a per-color- plane
basis. The result is the same as when the averaging is performed using
RGB color vectors.
In this section we consider image sharpening using the Laplacian. From vector
analysis, we know that the Laplacian of a vector is defined as a vector whose
components are equal to the Laplacian of the individual scalar components of
the input vector. In the RGB color system, the Laplacian of vector e in Eq.is
14|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
which, as in the previous section, tells us that we can compute the Laplacian of a
full-color image by computing the Laplacian of each component
image separately.
These results were combined to produce the sharpened full-color result. This result
was generated by combining the Laplacian of the intensity component with the
unchanged hue and saturation components. The difference between the RGB
and HSI sharpened images.
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
denote an arbitrary point in RGB space. We say that z is similar to a if the distance
between them is less than a specified threshold, D_{0} The Euclidean distance
between z and a is given by
where the subscripts R, G and B denote the RGB components of vectors a and z.
The locus of points such that D(z, a) <= D_{0} is a solid sphere of radius Do, as il-
lustrated in Fig. 6.43(a). Points contained within the sphere satisfy the specified
color criterion; points outside the sphere do not. Coding these two sets of points in
the image with, say, black and white, produces a binary segmented image. A
useful generalization of Eq. (6.7-1) is a distance measure of the form
Fig 5.5.Three approaches for enclosing data regions for RGB vector segmentation
Because distances are positive and monotonic, we can work with the distance
squared instead, thus avoiding square root computations. However,
implementing Eq. is computationally expensive for images of practical size, even if
16|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
the square roots are not computed. A compromise is to use a bounding box. In
this approach, the box is centered on a, and its dimensions along each of the
color axes is chosen proportional to the standard deviation of the samples along
each of the axis Computation of the standard deviations is done only once using
sample color data.
17|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
9. PRACTICE QUIZ
18|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
17) HSI color model stands for
a) hue, system, intensity
b) high, saturation, intensity
c) hue, saturation, intensity
d) high, system, intensity
20) What is the equation used for calculating G value in terms of HSI components?
a) G=3I-(R+B)
b) G=3I+(R+B)
c) G=3I-(R-B)
d) G=2I-(R+B)
10. Assignments
S.No Question BL CO
1 Explain the color image fundamentals? 2 3
2 Explain the RGB color model? 2 3
3 Explain the HSI color model? 2 3
Explain how the HSI color model converted in to RGB color
4 2 3
space?
Explain how the RGB color model converted in to HSI color
5 3 3
space?
6 What is color slicing and give the basic formulation ? 3 3
20|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
11. Part A- Question & Answers
1 5
1 5
1 5
Ans.
1 5
21|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
S.No Question BL CO
1 Explain the color image fundamentals? 2 5
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
In automated image analysis, color is a powerful descriptor,
which simplifies object identification and extraction. and intensities but
only about 20-30 shades of gray. Hence, use of color in human image
processing would be very effective.
5 Define psycho visual redundancy? 1
In normal visual processing certain information has less importance than
other information. So this information is said to be psycho visual
redundant.
23|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41
SVCE TIRUPATI
SVCE TIRUPATI
References:
1. S jayaraman, S Esakkirajan, T Veerakumar, “Digital Image processing”,Tata
McGraw Hill
2. William K. Pratt, “Digital Image Processing”, John Wilely, 3rd Edition, 2004
3. Rafael C. Gonzalez, Richard E woods and Steven L.Eddins, “Digital Image
processing using MATLAB”, Tata McGraw Hill, 2010.
https://www.geeksforgeeks.org/multiple-color-detection-in-real-time-using-
python-opencv/
24|D I P - U N I T - V
BTECH_ECE-SEM
BTECH_ECE-SEM 41
41