Dip Module - 5 Color Image Processing
Dip Module - 5 Color Image Processing
Dr. Chandrappa D N
Professor & Head
Dept of ECE, SJBIT
1
Module 5: Morphological Image Processing &
Color Image Processing
• Preliminaries
Erosion
Dilation
Opening and Closing
• Color Fundamentals
• Color models
• Pseudo color image processing
2
Preliminaries
◦ “Morphology “ – a branch in biology that deals with the form and structure of
animals and plants.
◦ “Mathematical Morphology” – as a tool for extracting image components, that are
useful in the representation and description of region shape.
◦ The language of mathematical morphology is – Set theory.
◦ Unified and powerful approach to numerous image processing problems.
◦ In binary images , the set elements are members of the 2-D integer space – Z 2.
◦ where each element (x,y) is a coordinate of a black (or white) pixel in the image.
Preliminaries
◦ Morphological operations are simple to use and works on the basis of set theory.
◦ The objective of using morphological operations is to remove the imperfections in
the structure of image.
◦ Most of the operations used here are combination of two processes, dilation and
erosion.
◦ The operation uses a small matrix structure called as structuring element. The shape
and size of the structuring element has significant impact on the final result.
◦ Matlab software is used as the tool for experimenting the morphological operations.
Cont..
Terminologies in Morphological Image Processing
All morphological processing operations are based on mentioned terms.
Structuring Element: It is a matrix or a small-sized template that is used to traverse
an image. The structuring element is positioned at all possible locations in the image,
and it is compared with the connected pixels. It can be of any shape.
Fit: When all the pixels in the structuring element cover the pixels of the object, we
call it Fit.
Hit: When at least one of the pixels in the structuring element cover the pixels of the
object, we call it Hit.
Miss: When no pixel in the structuring element cover the pixels of the object, we call
it miss.
Key Stages in Digital Image Processing:
Morphological Processing
Morphology
Morphological Image Processing (or morphology) describes a range of image
processing techniques that deal with the shape (or morphology) of features in an
image
Morphological operations are typically applied to remove imperfections
introduced during segmentation.
Key Stages in Digital Image Processing:
Morphological Processing
Structuring Element
Key Stages in Digital Image Processing:
Morphological Processing
Original Image Processed Image
Structuring Element
Key Stages in Digital Image Processing:
Morphological Processing
Subset
Union
Intersection
Complement
Difference
Reflection
Translation
Logic Operations Involving Binary Pixels
and Images
The principal logic operations used in image processing
are: AND, OR, NOT (COMPLEMENT).
These operations are functionally complete.
Logic operations are preformed on a pixel by pixel basis between corresponding
pixels (bitwise).
Other important logic operations :
XOR (exclusive OR), NAND (NOT-AND)
Logic operations are just a private case for a binary set operations, such : AND –
Intersection , OR – Union,
NOT-Complement.
Dilation
◦ Dilation is used for expanding an element A by using structuring
element B
Dilation of A by B and is defined by the following equation:
This equation indicates that the erosion of A by B is the set of all points z such
that B, translated by z, is combined in A.
Erosion – Example 1
Erosion – Example 2
Duality between dilation and erosion
Dilation and erosion are duals of each other with respect to set
complementation and reflection. That is,
One of the simplest uses of erosion is for eliminating irrelevant details (in
terms of size) from a binary image.
Erosion and Dilation summary
Opening And Closing
Opening –
◦ First – erode A by B, and then dilate the result by B
◦ In other words, opening is the unification of all B objects Entirely Contained in A
32
Categories of Color Image Processing
33
Color Fundamentals
Sir Isaac Newton discovered that white light when passes
through prism, breaks into seven colors VIBGYOR while each
color smoothly blends into other.
Color is perceived as the wavelength reflected back from object .
When the object reflects all seven colors in equal proportion it
appears white.
When an object reflects wavelength corresponding to green color
and absorbs all other wavelengths it will appear green.
When an object does not reflect at all i.e. absorbs all wavelengths
it appears black.
34
Color Spectrum
35
Electromagnetic Spectrum
36
Attributes of Light
37
Primary and Secondary Colors
In human eye cones and sensors are responsible for color vision.
There are 6 to 7 million cones in human eye which can be divided
into 3 categories red, green and blue.
65% are sensitive to red
35% are sensitive to green
2% are sensitive to blue.
Due to these absorption characteristics colors are seen as
combinations of 3 primary colors i.e. RED, BLUE, GREEN.
38
No single color can be called as RED, BLUE or GREEN since colors
blend with each other. Therefore, for Standardization CIE
designated 3 primary colors the following frequencies.
Blue = 435.8nm
Green= 546.1nm
Red = 700nm
Primary colors add to form secondary colors.
Magenta = Red + Blue
Cyan = Green + Blue
Yellow = Red + Green
39
40
Characteristics of Color
41
TRISMULUS VALUES
42
CIE Chromaticity Diagram
The various colors VIBGYOR are around tongue shape
chromaticity diagram.
These are pure colors.
Other points in diagram represents mixture of colors.
All points on boundaries are fully saturated.
As point leaves boundary and approaches point of equal energy,
it becomes less saturated.
Saturation at point of equal energy (WHITE) is zero.
Straight line joining any two colors on the chromaticity diagram
represents colors which can be formed by mixing two colors.
43
GREEN
COLORS MIXED USING
RED AND GREEN
RED
WHITE
ALL SHADES OF
RED
RED
44
CIE Chromaticity Diagram
45
COLOR MODELS
46
RGB Color Model
Model based on Cartesian co-ordinate system.
Color space is a cube.
RGB are 3 corners of cube.
Black is at origin.
White is at corner farthest from origin.
Line joining 2 points form gray scale.
Different colors are points on or inside the cube.
Cube is unit cube.
Value of R,G,B are in the range [0,1].
47
RGB Color Model
48
Pixel Depth:- Number of bits used to represent each pixel in RGB
space is called pixel depth.
If depth = 24 bits , each image plane is of 8 bits. Such type of
image is called full color image.
Total number of colors in 24-bit RGB image is
(28)3 = 16,777,216
49
50
51
CMY AND CMYK color models
CMY :- Cyan , Magenta , Yellow color model
Many color printers and copiers require this model.
[C,M,Y] = [1 1 1] – [R,G,B]
Therefore, pure cyan does not reflect red
Pure magenta does not reflect green
Pure yellow does not reflect blue.
Similarly,
[R,G,B] = [1 1 1] – [C,M,Y]
Combining CMY produces muddy looking black. To produce pure
black, fourth pure black color is added. So model known as CMYK
where K is black . The printing techniques using these four colors
is known as four color printing.
52
HSI COLOR MODEL
(Hue ,Saturation and Intensity)
53
Obtaining HSI from RGB
Intensity:- Take the RGB cube and stand it on the black (0,0,0)
vertex with (1,1,1) white directly above it.
Intensity is along line joining these vertices.
To find intensity component of any color, pass a plane
perpendicular to intensity axis containing the color point.
54
Hue:- Form plane take 3 points : Black, white and a color.
All points in the plane segment and points on boundaries of cube
have the same hue.
By rotating the plane on vertical axis, different hues are obtained.
55
CONVERSION AMONG DIFFERENT
COLOR MODELS
RGB to HSI
Assumed that RGB values have been normalized to [0,1] and
angle θ is measured with respect to red axis of HSI space.
Conversion equations
HSI to RGB
RG sector (0° <= H <= 120°)
GB sector (120° <= H <= 240°)
BR sector (240° <= H <= 360°)
56
Relation between RGB and HSI
Model
57
58
PSEUDOCOLOR IMAGE PROCESSING
59
INTENSITY SLICING
Let [0 – L-1] gray scale. This scale is divided into L levels where l0
represents black f (x,y) =0 and level lL-1 represents white f (x,y) =
L-1. Total P planes are defined perpendicular to intensity axis
defined at levels l1,l2,…,lp and 0 <P< L-1.
P planes partition gray scale into P+1 intervals V1, V2,…,V p+1
Gray to color assignments are made as
f (x,y) = ck if f (x,y) ε Vk
Vk :- interval formed by partitioning planes at l = k-1 and l=k
ck :- color associated with kth intensity interval Vk.
60
Any plane slice the image function into two levels.
Different color is assigned to each plane. Any pixel whose gray
level is above the plane will be coded with one color and below
the plane will be coded with other.
Pixels on the plane can be assigned any color.
Result is two color image.
When more colors are used, mapping function takes staircase
form.
61
Intensity Slicing
62
63
Gray level to Color Transformation
Perform three independent transformations on gray levels.
The three results are fed separately into red, green and blue
channels of TV.
Intensity slicing is a special case where piecewise linear function
of gray levels is used.
Here transformation function can be smooth , non-linear
function.
Many monochrome images can also be combined to form single
color composite image. Application is in multispectral imaging
where different sensors produce individual monochrome images
each in different spectral band.
64
Color Transformation
65
Pseudo color Processing
66
Full Color Image Processing
67
COLOR TRANSFORMATIONS
g (x,y) = T [f (x,y)]
T is the transformation on colored image f (x,y). g (x,y) is
transformed image.
Difference between color and gray level transformation is color
transformation pixels are group of triplets. Color transformation
have the form
si = Ti (r1, r2,…,rn) i=1,2,…,n
n=3 or 4
n=3 for RGB and HSI
N=4 for CMYK
68
Any transformation can be performed in any color model. For
choosing a particular color model, cost of conversion should be
considered.
example.:- If intensity has to be modified, HSI color space can be
used
s3 = k r3 only r3 is modified.
But for RGB all the 3 components must be transformed.
si = k ri i=1,2,3
and for CMY si = k ri + (1-k)i=1,2,3
Here intensity transformation in HSI space is simple but
calculations for converting RGB and CMY to HSI are more
complicated. But independent of color space output is always
same.
69
Color Complements (Here directly opposite to each other
in color circle. Equal to gray level negative.)
70
COLOR SLICING
Highlighting specific range of colors in an image for the
purpose of separating objects from surroundings.
Two approaches:-
1. Display colors of interest so they stand out from background.
2. Use region defined by colors as a mask.
One way to slice a color image is to map the colors outside
some range of interest to a neutral color. Suppose colors of
interest are enclosed by average color with components
a1,a2,…,an then set of transformations is:
This transformation highlight the color around the prototype
by forcing all other colors to midpoint of reference color
space. e.g. for RGB suitable neutral point is (0.5,0.5,0.5).
71
HISTOGRAM PROCESSING
72
SMOOTHING AND SHARPENING
SMOOTHING (Averaging):-
S x,y denote set of co-ordinates defining neighborhood
centered at (x,y) in RGB color image. Average of RGB
component vectors in neighborhood is
c (x,y) = 1/k Σ c (x,y)
x,yε Sxy
Matrix form:
COLOR IMAGE SHARPENING:
73
NOISE IN COLOR IMAGES
74