Mathematical Morphology
• used to extract image components that are
useful in the representation and description of
region shape, such as
– boundaries extraction
– skeletons
– convex hull
– morphological filtering
– thinning
– pruning
1
Basic Set Theory
2
Example
3
Basic morphological operations
• Erosion
• Dilation
keep general shape but
• combine to smooth with respect to
– Opening object
– Closening background
4
Erosion
The basic effect of the operator on a binary image is to erode
away the boundaries of regions of foreground pixels (i.e.
white pixels, typically). Thus areas of foreground pixels shrink
in size, and holes within those areas become larger
Figure 2 Effect of erosion using a 3×3 square structuring element
Strip away a layer of pixels from an object, shrinking it in the
process.
Dilation
The basic effect of the operator on a binary image is to gradually
enlarge the boundaries of regions of foreground pixels (i.e. white
pixels, typically). Thus areas of foreground pixels grow in size while
holes within those regions become smaller.
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
7
Guidelines for Use
Dilation can also be used for edge detection by taking the
dilation of an image and then subtracting away the
original image, thus highlighting just those new pixels at the
edges of objects that were added by the dilation. For
example, starting with
Effect of Dilation and Erosion
•Original Binary Image: Black
•Structure Element: Red
•Resultant Image: White
a)Dilation b)Erosion
B) We must imagine that we are sliding the structuring
element around the boundary on the inside of the object
Opening - Guidelines for Use
Figure : Effect of opening using a 3×3 square structuring element
As with erosion and dilation, it is very common to use this 3×3
structuring element. The effect in the above figure is rather subtle since
the structuring element is quite compact and so it fits into the foreground
boundaries quite well even before the opening operation
To increase the effect, multiple erosions are often performed with this
element followed by the same number of dilations. This effectively
performs an opening with a larger square structuring element.
Closing - Guidelines for Use
Figure: Effect of closing using a 3×3 square structuring element
Summary (2)
10/08/20 12
10/08/20 13
10/08/20 14
Gray-Scale Morphology
f ( x, y ) : gray-scale image
b( x, y ): structuring element
10/08/20 15
Gray-Scale Morphology: Erosion and
Dilation by Flat Structuring
f b ( x, y) (min
s ,t )b
f ( x s, y t )
f b ( x, y ) (max
s ,t )b
f ( x s, y t )
10/08/20 16
10/08/20 17
Morphological Gradient
10/08/20 18
Application: filtering
19
Boundary Extraction
( A) A ( A B )
20
Example
21
Thinning
A B A ( A B)
A ( A B) c
22
Thickening
A B A ( A B)
23
K
S ( A) S k ( A)
Skeletons
k 0
S k ( A) ( A kB) ( A kB) B
K max{k | ( A kB) }
K
A ( S k ( A) kB)
k 0
24
25
H = 3x3 structuring element of 1’s X 1 A {B}
Pruning 8
X 2 ( X1 B )
k
k 1
X3 (X2 H ) A
X 4 X1 X 3
26
27
28
29
30
31
Steps in the Example
1. Opening by reconstruction of the original image using a horizontal
line of size 1x71 pixels in the erosion operation
OR( n ) ( f ) R Df f nb
2. Subtract the opening by reconstruction from original image
f ' f OR( n ) ( f )
3. Opening by reconstruction of the f’ using a vertical line of size
11x1 pixels
f 1 OR( n ) ( f ') R Df f ' nb '
4. Dilate f1 with a line SE of size 1x21, get f2.
32
Steps in the Example
5. Calculate the minimum between the dilated image f2
and and f’, get f3.
6. By using f3 as a marker and the dilated image f2 as
the mask,
R Df 2 ( f 3) D (f k2) f 3
with k such that D (f k2) f 3 D (f k21) f 3
10/08/20 33