Skip to content

Derived Morphological Operations

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.

Original
→
Erosion
→
Dilation
\[ X\circ B = (X\ominus B)\oplus B \]
Plain English:
Shrink the foreground, then grow it back.

Small foreground objects may disappear during erosion. If they disappear completely, the following dilation cannot restore them.

Opening is useful for removing small foreground details, thin protrusions, and narrow connections.

2. Closing

Closing performs dilation first, then erosion.

Original
→
Dilation
→
Erosion
\[ X\bullet B = (X\oplus B)\ominus B \]
Plain English:
Grow the foreground, then shrink it back.

Dilation can fill small gaps and holes. The following erosion restores much of the original object size.

Closing is useful for filling small gaps and connecting nearby foreground regions.

3. Opening vs. Closing

Opening

\[ (X\ominus B)\oplus B \]

Erode → Dilate

Mainly removes small foreground details.

Closing

\[ (X\oplus B)\ominus B \]

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.

Original
→
Opening
→
Closing
\[ X_{\mathrm{denoised}} = (X\circ B)\bullet B \]
Opening removes small foreground details. Closing then fills small gaps in the opened result.

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.
\[ \operatorname{HMT}(X;A,B) = (X\ominus A) \cap (X^c\ominus B) \]
Plain English:
A match occurs only when the required foreground and required background both fit.
Hit-or-miss is a pattern detector. It asks whether a particular local shape is present.

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.

\[ d\le r \]

Background \(B\)

The background structuring element describes the region outside an expanded circle.

\[ d\gt r+t \]

Here, \(t\) is a tolerance. The band between the original circle and the expanded circle is not required to be either foreground or background.

\[ r\lt d\le r+t \]
This tolerance band allows the detected boundary to vary slightly.
Required Foreground
→
Tolerance
→
Required 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.

\[ X\otimes B = X \setminus \operatorname{HMT}(X;B) \]
Plain English:
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.

\[ \operatorname{HMT}(X;B_i) = (X\ominus A_i) \cap (X^c\ominus C_i) \]
\(A_i\) contains the locations marked \(1\), \(C_i\) contains the locations marked \(0\), and locations marked \(-1\) are not tested.
\(B_1\)
0
0
0
−1
1
−1
1
1
1
\(B_2\)
−1
0
0
1
1
0
1
1
−1
\(B_3\)
1
−1
0
1
1
0
1
−1
0
\(B_4\)
1
1
−1
1
1
0
−1
0
0
\(B_5\)
1
1
1
−1
1
−1
0
0
0
\(B_6\)
−1
1
1
0
1
1
0
0
−1
\(B_7\)
0
−1
1
0
1
1
0
−1
1
\(B_8\)
0
0
−1
0
1
1
−1
1
1

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.

\[ X_0=X \] \[ X_i = X_{i-1} \otimes B_i, \qquad i=1,\ldots,8 \]

Using the hit-or-miss definition of thinning:

\[ X_i = X_{i-1} \setminus \operatorname{HMT} \left( X_{i-1};B_i \right) \]
\(X_0\)
→
\(B_1\)
→
\(X_1\)
→
\(B_2\)
→
\(X_2\)
→
\(\cdots\)
→
\(X_8\)
\[ \operatorname{Thin}(X) = X_8 \]
One complete thinning round ends after all eight directional patterns have been applied.

10. Skeletonization by Repeated Thinning

One thinning round usually does not make the object thin enough.

The complete thinning round is therefore repeated.

Original
→
Thin
→
Thin
→
…
→
No Change
\[ X^{(0)} = X \] \[ X^{(k+1)} = \operatorname{Thin} \left( X^{(k)} \right) \]

After every round, compare the new result with the previous result.

\[ X^{(k+1)} = X^{(k)} \]
When another thinning round produces no change, the process has converged.
The final result is a thin representation of the object that preserves important information about its shape and connectivity.

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
Big picture:

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.
Want to understand a symbol in more detail?

See Symbols & Definitions for explanations.


Interactive Derived Morphology Visualizer
Noisy / Denoised Input \(X\)
Contains small, medium, and large circles.
Detection Result
Green cells mark detected circle centers.
Hit-or-Miss SE Window
Foreground \(A\) Tolerance Background \(B\)
1 Use the current thinning pattern B1
→
2 Hit-or-Miss finds pixels matching the current pattern
→
3 Remove the matched pixels, then move to the next pattern
Current Pattern
B1
Pattern Meaning
1 = foreground required
0 = background required
−1 = ignored
Orange = anchor / HMT match
Current State
Current Binary Object
Click cells to customize the object. Orange cells are the current Hit-or-Miss matches waiting to be removed.
Foreground Hit-or-Miss match Background

Published inDigital Image Processing

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *