Erosion and dilation are the basic building blocks of mathematical morphology. By combining or repeating them, we can clean images, detect shapes, and simplify objects.
1. Opening
Opening performs erosion first, then dilation.
Shrink the foreground, then grow it back.
Small foreground objects may disappear during erosion. If they disappear completely, the following dilation cannot restore them.
2. Closing
Closing performs dilation first, then erosion.
Grow the foreground, then shrink it back.
Dilation can fill small gaps and holes. The following erosion restores much of the original object size.
3. Opening vs. Closing
Opening
Erode → Dilate
Mainly removes small foreground details.
Closing
Dilate → Erode
Mainly fills small background gaps.
4. Denoising with Opening and Closing
Opening and closing can be applied one after another to clean different kinds of small image artifacts.
5. Hit-or-Miss Transform
The hit-or-miss transform finds a specific pattern in a binary image.
It uses two structuring elements:
- \(A\) describes where foreground pixels are required.
- \(B\) describes where background pixels are required.
A match occurs only when the required foreground and required background both fit.
6. Example: Circle Detection
Hit-or-miss can be used to detect a circular foreground region surrounded by background.
Foreground \(A\)
A circular structuring element with radius \(r\) describes the region that should be foreground.
Background \(B\)
The background structuring element describes the region outside an expanded circle.
Here, \(t\) is a tolerance. The band between the original circle and the expanded circle is not required to be either foreground or background.
7. Thinning with Hit-or-Miss
Thinning gradually removes selected boundary pixels while preserving the important structure of an object.
Hit-or-miss identifies boundary pixels that match a thinning pattern. Those matched pixels are then removed.
Find pixels that match the thinning pattern, then remove them.
The symbol \(\otimes\) represents thinning here.
A single thinning pattern examines only certain boundary directions. Several related patterns are therefore applied in sequence.
8. Eight Directional Thinning Patterns
One thinning round uses eight 3×3 patterns. Together, they examine the object’s boundary from different directions.
In these patterns: \(1\) means foreground is required, \(0\) means background is required, and \(-1\) means that location is ignored.
9. One Complete Thinning Round
The eight patterns are applied one after another.
After each pattern, the matched pixels are removed. The next pattern therefore works on the updated image.
Using the hit-or-miss definition of thinning:
10. Skeletonization by Repeated Thinning
One thinning round usually does not make the object thin enough.
The complete thinning round is therefore repeated.
After every round, compare the new result with the previous result.
11. Why Use a Thinning Skeleton?
Original Object
- contains the full filled region,
- contains object thickness,
- may contain many foreground pixels.
Skeleton
- uses a much thinner representation,
- makes branches easier to examine,
- helps reveal connectivity and structure.
Skeletonization is useful when the structure of an object matters more than its thickness.
12. Summary
| Operation | How It Works | Main Purpose |
|---|---|---|
| Opening | Erosion → Dilation | Remove small foreground details |
| Closing | Dilation → Erosion | Fill small background gaps |
| Denoising | Opening → Closing | Clean multiple kinds of small artifacts |
| Hit-or-Miss | Match required foreground and background | Detect a specific binary pattern |
| Thinning | Hit-or-Miss → remove matched pixels | Reduce object thickness |
| Skeletonization | Repeat thinning until convergence | Produce a thin structural representation |
Opening and closing combine erosion and dilation.
Hit-or-miss detects a specific local pattern.
Thinning uses hit-or-miss to identify boundary pixels that can be removed.
Repeating thinning until the image stops changing produces the skeleton.
Be First to Comment