Lec14 Morphological Lec
Lec14 Morphological Lec
• Dilation
1. growing features
7
• Erosion
1. shrinking features
8
Structuring Elements
box
hexagon disk
something
box(length,width) disk(diameter)
9
Dilation with Structuring Elements
origin
0 0 1 1 0 0 0 0 0 0
1 erode
0 0 1 1 0 0 0 1 1 0
1
0 0 1 1 0 0 0 1 1 0
1
1 1 1 1 1 0 0 0 0 0
B S B S
11
Opening and Closing
12
13
Application:
Gear Tooth Inspection
original
binary
image
detected
defects
14
Connected Components Labeling
Once you have a binary image, you can identify and
then analyze each connected set of pixels.
15
EROSION
10/26/24 16
A first Example: Erosion
• Erosion is an important morphological
operation
Structuring Element 1 1 1
Output Image 0
Structuring Element 1 1 1
Output Image 0 0
Structuring Element 1 1 1
Output Image 0 0 0
Structuring Element 1 1 1
Output Image 0 0 0 0
Structuring Element 1 1 1
Output Image 0 0 0 0 1
Structuring Element 1 1 1
Output Image 0 0 0 0 1 0
Structuring Element 1 1 1
Output Image 0 0 0 0 1 0 0
Structuring Element 1 1 1
Output Image 0 0 0 0 1 0 0 0
Box
Disc
10/26/24 33
Example: Dilation
• Dilation is an important morphological
operation
Structuring Element 1 1 1
Output Image 1
Structuring Element 1 1 1
Output Image 1 0
Structuring Element 1 1 1
Output Image 1 0 1
Structuring Element 1 1 1
Output Image 1 0 1 1
Structuring Element 1 1 1
Output Image 1 0 1 1 1
Structuring Element 1 1 1
Output Image 1 0 1 1 1 1
Structuring Element 1 1 1
Output Image 1 0 1 1 1 1 1
Structuring Element 1 1 1
Output Image 1 0 1 1 1 1 1 1
10/26/24 49
Opening
• Similar to Erosion
– Spot and noise removal
– Less destructive
• Erosion next dilation
• the same structuring element for both operations.
• Input:
– Binary Image
– Structuring Element, containing only 1s!
3*9
9*3
10/26/24 57
Closing
• Similar to Dilation
– Removal of holes
– Tends to enlarge regions, shrink background
• Closing is defined as a Dilatation, followed by an
Erosion using the same structuring element for
both operations.
• Dilation next erosion!
• Input:
– Binary Image
– Structuring Element, containing only 1s!
Oct 26, 2024 58
Closing
• Take the structuring element (SE) and slide it
around outside each foreground region.
– All background pixels which can be covered by the SE
with the SE being entirely within the background
region will be preserved.
– All background pixels which can not be reached by the
structuring element without lapping over the edge of
the foreground object will be turned into a foreground.
• Opening is idempotent: Repeated application has
no further effects!
skeleton of Thresholded
skeleton of Thresholded and next closed
63
Closing Gray Value Images
• 5x5 square structuring element
thin I , K I HitAndMiss I , K
with 0-1=0!!
• If foreground and background fit the structuring
element exactly, then the pixel at the origin of the SE
is set to 0
thicken I , K I HitAndMiss I , K
with 1+1=1
• If foreground and background match exactly the
SE, then set the pixel at its origin to 1!
• Note that the value of the SE at the origin is 0 or
don’t care!
Oct 26, 2024 78
Example Thickening