4 14755 CS213 20172018 1 2 1 Lecture 5
4 14755 CS213 20172018 1 2 1 Lecture 5
Lecture 5
Morphological Image
Processing
Remember
GRAY LEVEL THRESHOLDING
Objects
Set threshold
here
BINARY IMAGE
Problem here
5
Basic Set Theory
6
Reflection and Translation
Bˆ {w | w b, for b B}
( A) z {c | c a z , for a A}
7
Example
8
Structuring element (SE)
9
Examples: Structuring Elements
origin
10
Basic idea
• in parallel for each pixel in binary image:
– check if SE is ”satisfied”
– output pixel is set to 0 or 1 depending on used
operation
11
Example
Origin of B visits
every element of A
12
Basic morphological operations
• Erosion
• Dilation
– Opening object
– Closening background
13
Erosion
14
Erosion
15
Erosion
16
Erosion
17
Erosion
A B {z|(B)z A}
18
Dilation
A B {z|(Bˆ )z A Φ}
• grow the object
19
Dilation
20
Dilation
21
Dilation
22
Dilation
B = structuring element
A B {z|(Bˆ )z A Φ}
23
Dilation : Bridging gaps
24
25
26
27
28
useful
• erosion
– removal of structures of certain shape and size,
given by SE
• Dilation
– filling of holes of certain shape and size, given by
SE
29
Combining erosion and dilation
• WANTED:
– remove structures / fill holes
– without affecting remaining parts
• SOLUTION:
• combine erosion and dilation
• (using same SE)
30
Erosion : eliminating irrelevant detail
A B ( A B ) B
• eliminates protrusions
• breaks necks
• smoothes contour
32
Opening
33
Opening
34
Opening
A B ( A B ) B
A B {( B ) z | ( B ) z A} 35
Opening example
Opening with a 11 pixel diameter disc:
A B ( A B ) B
• smooth contour
• fuse narrow breaks and long thin gulfs
• eliminate small holes
• fill gaps in the contour
37
Closing
38
Closing
39
Closing
A B ( A B ) B
40
Another closing example
Closing operation with a 22 pixel disc, closes small holes in
the foreground.
And another…
Threshold, closing with disc of size 20.
Opening
(i) AB is a subset (subimage) of A
(ii) If C is a subset of D, then C B is a subset of D B
(iii) (A B) B = A B
Closing
(i) A is a subset (subimage) of AB
(ii) If C is a subset of D, then C B is a subset of D B
(iii) (A B) B = A B
47
APPLICATIONS
48
Application: filtering
49
Hit-and-miss transform *
Used to look for particular patterns of foreground and
background pixels
Very simple object recognition
Example for a Hit-and-miss Structuring Element: Contains
0s, 1s and don’t care’s.
( A) A ( A B)
52
Example
53
Region Filling
c
X k ( X k 1 B ) A k 1,2,3,...
54
Region Filling Algorithm
55
Example
56
Thinning
A B A ( A B)
A ( A B)c
57
Thickening
•The thickening operation is calculated by translating the origin of the structuring element to each
possible pixel position in the image, and at each such position comparing it with the underlying
image pixels. If the foreground and background pixels in the structuring element exactly match
foreground and background pixels in the image, then the image pixel underneath the origin of the
structuring element is set to foreground (one). Otherwise it is left unchanged. Note that the
structuring element must always have a zero or a blank at its origin if it is to have any effect.
A B A ( A B)
Alternativel
y, based
on Thining
58