You are on page 1of 113

Digital Image Processing

Unit-5
M. Lenin babu
Assistant Professor
SYLLABUS
Morphological Image
Processing
Some points
Once segmentation is complete, morphological
operations can be used to remove imperfections
in the segmented image and provide information
on the form and structure of the image.
Some points
All of the discussion that follows assumes
segmentation has already taken place and that
images are made up of 0s for background pixels
and 1s for object pixels
After this it doesn’t matter if 0 is black, white,
yellow, green…….
Morphology
• It is a branch of biology that deals with the
form and structure of animals and plants.
• Morphological image processing is used to
extract image components for representation
and description of region shape, such as
boundaries, skeletons etc.
Some more…
• Morph means shape.

• We do Morphology for shape analysis & shape


study.

• Shape analysis became easy in case of binary


images.

• Pixel Locations describe the shape.

• Digital Morphology is a way to describe or analyze


the shape of a digital image.
Example

Image after segmentation Image after segmentation and


morphological processing
Structuring Elements, Hits & Fits
B Structuring Element

Fit: All on pixels in the


structuring element cover on
pixels in the image
A
Hit: Any on pixel in the
C structuring element covers an
on pixel in the image

All morphological processing operations are based on


these simple ideas
Structuring Elements
Structuring elements can be of any size and
make any shape.
However, for simplicity we will use rectangular
structuring elements with their origin at the
middle pixel
0 0 1 0 0
1 1 1 0 1 0 0 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 1 0 0 1 1 1 0
0 0 1 0 0
Fitting & Hitting
0 0 0 0 0 0 0 0 0 0 0 0
1 1 1
0 0 0 1 1 0 0 0 0 0 0 0
1 1 1
0 0 1 B1 1 1 1 0 C0 0 0 0
1 1 1
0 1 1 1 1 1 1 1 0 0 0 0 Structuring
0 1 1 1 1 1 1 1 0 0 0 0 Element 1

0 0 1 1 1 1 1 1 0 0 0 0 0 1 0
0 0 1 1 1 1 1 1 1 0 0 0 1 1 1
0 0 1 1 1 1 1 A1 1 1 1 0 0 1 0
0 0 0 0 0 1 1 1 1 1 1 0 Structuring
Element 2
0 0 0 0 0 0 0 0 0 0 0 0
Fundamental Operations
Fundamentally morphological image processing
is like spatial filtering.
The structuring element is moved across every
pixel in the original image to give a pixel in a
new processed image.
The value of this new pixel depends on the
operation performed.
Fundamental Operations
There are two basic morphological operations:
erosion and dilation.
Erosion
Erosion of image f by structuring element s is
given by f  s
The structuring element s is positioned with its
origin at (x, y) and the new pixel value is
determined using the rule:
 1 if s fits f
g ( x, y )  
0 otherwise
Erosion Example
Original Image Processed Image

Structuring Element
Erosion Example

Original image Erosion by 3*3 Erosion by 5*5 square


square structuring structuring element
element

Watch out: In these examples a 1 refers to a black pixel!


Erosion Example 2

After erosion
Original
with a disc of
image
radius 10

After erosion After erosion


with a disc of with a disc of
radius 5 radius 20
What Is Erosion For?
Erosion can split apart joined objects

Erosion can split apart

Erosion can strip away extrusions

Watch out: Erosion shrinks objects


Dilation
Dilation of image f by structuring element s is
given by f  s
The structuring element s is positioned with its
origin at (x, y) and the new pixel value is
determined using the rule:
1 if s hits f
g ( x, y )  
0 otherwise
Dilation Example
Original Image Processed Image With Dilated Pixels

Structuring Element
Dilation Example

Original image Dilation by 3*3 Dilation by 5*5 square


square structuring structuring element
element

Watch out: In these examples a 1 refers to a black pixel!


Dilation Example
Original image After dilation

Structuring element
What Is Dilation For?
Dilation can repair breaks

Dilation can repair intrusions

Dilation enlarges objects


Compound Operations
More interesting morphological operations can
be performed by performing combinations of
erosions and dilations
The most widely used of these compound
operations are:
– Opening
– Closing
Opening
The opening of image f by structuring element s,
denoted f ○ s is simply an erosion followed by a
dilation
f ○ s = (f s)  s

Original shape After erosion After dilation


(opening)

Note a disc shaped structuring element is used


Opening Example

Original
Image

Image
After
Opening
Opening Example
Original Image Processed Image

Structuring Element
Closing
The closing of image f by structuring element s,
denoted f • s is simply a dilation followed by an
erosion
f • s = (f  s)s

Original shape After dilation After erosion


(closing)

Note a disc shaped structuring element is used


Closing Example

Original
Image

Image
After
Closing
Closing Example
Original Image Processed Image

Structuring Element
Morphological Processing Example
Morphological Algorithms:
applications
– Boundary extraction
– Region filling
– Extraction of connected components
– Thinning/thickening
– Skeletonisation
Boundary Extraction
Extracting the boundary (or outline) of an object
is often extremely useful
The boundary can be given simply as
β(A) = A – (AB)
Boundary Extraction Example
A simple image and the result of performing
boundary extraction using a square 3*3
structuring element

Original Image Extracted Boundary


Region Filling
Given a pixel inside a boundary, region filling
attempts to fill that boundary with object pixels
(1s)

Given a point inside


here, can we fill the
whole circle?
Region Filling (cont…)
The key equation for region filling is
c
X k  ( X k 1  B)  A k  1,2,3.....
Where X0 is simply the starting point inside the
boundary, B is a simple structuring element and Ac is
the complement of A
This equation is applied repeatedly until Xk is equal
to Xk-1
Finally the result is unioned with the original
boundary
Region Filling Step By Step
Region Filling Example

Original Image One Region All Regions Filled


Filled
Thinning using hit-or-miss
transform
Thickening using hit-or-miss
transform

The thickening operation is related to the hit-and-miss transform and can be expressed quite
simply in terms of it. The thickening of an image I by a structuring element J is:
Summary
The purpose of morphological processing is
primarily to remove imperfections added during
segmentation
The basic operations are erosion and dilation
Using the basic operations we can perform opening
and closing
More advanced morphological operation can then
be implemented using combinations of all of these
Edge detection
UNDERSTANDING HOUGH
TRANSFORM
• We transform the
image space into hough
space. By doing this we
convert a line in image
space to a point on
hough space.
UNDERSTANDING HOUGH
TRANSFORM
• But in this representation m goes to infinity for vertical lines. So
use the polar coordinates instead. The line is represented by the
length of that segment ρ , and the angle θ it makes with the x-
axis. This line will be transformed to a point of the form (ρ,θ) in
the hough space.
UNDERSTANDING HOUGH
TRANSFORM
• The Hough transform constructs a histogram
array representing the parameter space (i.e.,
an M x N matrix, for M different values of the
radius ρ and N different values of angle θ). For
each parameter combination,ρ and θ we then
find the number of non-zero pixels in the
input image that would fall close to the
corresponding line, and increment the array at
position (ρ,θ) appropriately.
UNDERSTANDING HOUGH
TRANSFORM
• The intersection of multiple lines in image space
represent corresponding multiple points in hough
space.
UNDERSTANDING HOUGH
TRANSFORM
Similarly the reverse i.e lines intersecting at a
point (m, c) in hough space can be transformed to a line
y = mx + c in image space.
UNDERSTANDING HOUGH
TRANSFORM
• If we have a line made up of many segments
or points close to the same line equation in
the image space, that turns into many
intersecting lines in hough space.
UNDERSTANDING HOUGH
TRANSFORM
• So, consider a line in the image space which is
an edge detected and has small discontinuities.
• To find the continous line in an image we can
transform this dicontinous line in image space
to hough space and look for intersection points
in hough space. This intersection point in
hough space will represent the continous line
in image space.
UNDERSTANDING HOUGH
TRANSFORM
• The Hough Transform is a method that is used
in image processing to detect any shape, if that
shape can be represented in mathematical
form. It can detect the shape even if it is
broken or distorted a little bit. 
• Hough transform works for line detection using
the HoughLine transform method. To apply the
Houghline method, first an edge detection of
the specific image is desirable.
• A line can be represented as
y = mx + c or in parametric
form, as r = xcosθ + ysinθ
where r is the perpendicular
distance from origin to the
line, and θ is the angle
formed by this
perpendicular line and
horizontal axis measured in
counter-clockwise
References
• R. C. Gonzalez and R. E. Woods, Digital Image Processing,
3rd edition, Prentice Hall, 2008
• Anil K.Jain, “Fundamentals of Digital Image Processing”,
Prentice-Hall of India, 9th Edition, Indian Reprint, 2002.
• B. Chanda and D. Dutta Majumdar, “Digital Image Processing
and Analysis” PHI,2003.
• R. C. Gonzalez, R. E. Woods and Steven L. Eddins, Digital
Image Processing Using MATLAB, 2ndedition, Prentice Hall,
2009.
• Jayaraman, S. Esakkirajan, and T. Veerakumar, Digital Image
Processing, Tata McGraw-Hill Education, 2011.
MORE REFENCES CAN BE FOUND
IN THE FOLLOWING LINK
• https://docs.google.com/document/d/1OB2gj
ForU2IJ8m3HmL7Y_pCZTt_aGfOL/edit?usp=sh
aring&ouid=105256823405385905184&rtpof=
true&sd=true

You might also like