Digital Image Processing - Lecture-10
Digital Image Processing - Lecture-10
Teams Link
https://teams.microsoft.com/l/team/19%3aV89kJ8amsbE3ssF9V0x
mGOukoYKvZIwPVey1-
EUiL4Y1%40thread.tacv2/conversations?groupId=47e1fe88-6e6b-
433e-b771-94c21eeb96c6&tenantId=ff4a48d6-4b5e-4fd3-8266-
7eafc3e6e23e
Text Book
R. Gonzalez, R. Woods.
Digital Ιmage Processing,
Prentice Hall, 2008.
Third Edition .
Lecture 10
Morphological Image Processing
Morphology
Morphology is a tool for extracting image
components.
Morphology removes unwanted elements from binary
images.
Morphological operations are intended to affect the
shape of the object.
Morphological operations are typically applied
to remove imperfections introduced during
segmentation, and so typically operate on bi-level
images.
– Hit – Fit
– Dilation – Erosion
– Opening – Closing
Morphology
Morphological image processing is used to extract
image components for representation and description
of region shape, such as:
– Boundaries Extraction
– Convex Hull
– Morphological Filtering
– Thinning
– Skeletons
– Pruning
Grayscale image
Preprocessing
– Inversion
Threshold => Binary image
Morphology
origin
Structure Elements
Structuring elements can be any size and make
any shape.
However, for simplicity we will use rectangular
structuring elements with their origin at the middle
pixel.
22
Morphology : The fit operation
23
A S2 No Yes
B S1 No Yes
B S2 No No
C S1 Yes Yes
C S2 Yes Yes
D S1 No No
No No
D S2
24
Simple Morphological Operations
Fundamentally morphological image processing is very
like spatial filtering.
Dilation
Dilate : To make wider or larger
Applying Hit to an entire image is denoted
Dilation
26
Simple Morphological Operations (cont.)
Dilation
Dilation of image 𝑓 by structuring element 𝑠 is
given by
𝒇⊕𝒔
The structuring element 𝑠 is positioned with its
origin at (𝑥, 𝑦) and the new pixel value is
determined using the rule:
Dilation Example1
H H H
H H H H H
Structuring
H H H H H H
Element
H H H H H H
H H H H H
H H H H H
H H H
Dilation Example2
Dilation Example3
Erosion
Erode : To wear down (Waves eroded the shore)
Applying Fit to an entire image is denoted Erosion
33
Simple Morphological Operations (cont.)
Erosion
Erosion of image 𝑓 by structuring element 𝑠 is
given by
𝒇⊝𝒔
The structuring element 𝑠 is positioned with its
origin at (𝑥, 𝑦) and the new pixel value is
determined using the rule:
Erosion Example1
Structuring
F F Element
F F
F
Erosion Example2
29/29
Erosion Example3
Erosion Example5
40
Compound Operations
– Opening
– Closing
Compound Operations
Combining Erosion
and Dilation into more
advanced operations
– Finding the outline
– Opening
• Isolate objects and
remove small objects
(better than Erosion)
– Closing
• Fill holes (better than
Dilation)
43
Opening
Objects decrease when we use erosion to erase
small noisy objects or fractured parts of bigger
objects.
Enlarge the object by following the erosion by
dilation. This operation is denoted Opening.
Motivation: Remove small objects BUT keep
original size (and shape)
Opening = Erosion + Dilation
– Use the same structuring element!
44
Opening
The opening of image 𝑓 by structuring element 𝑠,
denoted
𝒇 ○ 𝒔 is simply an erosion followed by a dilation
𝒇 ○ 𝒔 = (𝒇 ⊝ 𝒔) ⊕ s
Opening Example2
H
F Structuring H F H
Element H
Opening Example3
Structuring
Element
erosion dilation
F H
48
erosion dilation
50
Closing
The closing of image 𝑓 by structuring element 𝑠,
denoted 𝒇•𝒔 is simply a dilation followed by an
erosion
𝒇 • 𝒔 = (𝒇 ⊕ 𝒔) ⊝s
52
dilation erosion
55
Hit-or-Miss Transform
1. Boundary Extraction
Extracting the boundary (or outline) of an object is often
extremely useful
The boundary can be given simply as
𝜷(𝑨) = 𝑨 – (𝑨 ⊝ 𝑩)
2. Region Filling
Given a pixel inside a boundary, region filling
attempts to fill that boundary with object pixels (1s)
How?
Idea: place a given point 𝒑 (initial point) inside the region,
then dilate that point iteratively.
29/29
Result: If 𝑿𝒌 = 𝑿𝒌−𝟏, the algorithm has converged and the result is 𝑿𝒌 that contains
all the connected components of the input image. 26/34
Morphological Algorithms (cont.)
29/29
4. Convex Hull
𝐴 is said to be convex if a straight line segment joining any two points in 𝐴 lies
entirely within 𝐴.
29/29
Morphological Algorithms (cont.)
We present simple algorithm for obtaining the convex hull 𝐶(𝐴) of a set 𝐴.
This algorithm iteratively applying the hit-or-miss transform to 𝐴 with the first of 𝐵
element, unions it with 𝐴, and repeated with second element of 𝐵.
Let 𝐵𝑖 , 𝑖=1,2,3,4 represent the four structuring elements. The procedure consists
of implementing the equation:
29/34
29/29
Morphological Algorithms (cont.)
Thinning
5. Thinning
Thinning is the transformation of a digital image into a simplified.
The thinning of a set 𝐴 by a structuring element 𝐵, can be defined by terms of the
hit-and-miss transform:
Thinning Example
29/29
Morphological Algorithms (cont.)
Thickening
6. Thickening
Thickening is the morphological dual of thinning and is defined by the expression
33/34
34/34
Dr Mai Kamal DIP 2022