Mathematical morphology is not only useful for changing shapes. It can also be used to measure, describe, and compare them. In this lesson, we repeatedly open an object with larger structuring elements and observe what disappears at each scale.
1. From Changing Shapes to Measuring Shapes
So far, morphological operations have mainly been used to modify binary objects. Erosion shrinks them, dilation grows them, opening removes small structures, and thinning gradually reduces objects toward their skeletons.
Morphology can also be used in another way: the way an object responds to morphology can itself become a description of the object.
2. Analyzing Individual Objects
A binary image may contain several separate foreground objects. Before describing their shapes, we can identify the connected objects and analyze each one separately.
Connected-component labeling separates the foreground into individual objects:
Each connected object can then be analyzed independently.
After one object is selected, the following granulometry calculations are performed on that object rather than on all of the objects at once.
3. Opening with Increasing Structuring Elements
Instead of opening the object only once, we repeat the operation using structuring elements whose scale increases.
4. Size Distribution
At each scale, we count the number of foreground pixels that remain after opening.
At scale zero:
| Scale \(r\) | Remaining Area \(U(r)\) |
|---|---|
| 0 | 120 |
| 1 | 110 |
| 2 | 82 |
| 3 | 35 |
| 4 | 0 |
Measuring the remaining area across a sequence of openings is the central idea behind morphological granulometry.
5. Pattern Spectrum
The size distribution asks:
The pattern spectrum asks:
For example:
6. Reading a Pattern Spectrum
The shape of the spectrum tells us how the object’s area is distributed across morphological scales.
Concentrated at One Scale
Most of the object’s area disappears around one particular scale.
Spread Across Several Scales
Significant parts of the object disappear at several different scales.
7. Morphological Entropy
We can summarize how spread out the pattern spectrum is using a single value.
Lower \(H\)
Higher \(H\)
For a fixed structuring element, a spectrum distributed over more scales generally gives a larger entropy value.
8. Comparing Two Shapes
Once a pattern spectrum has been calculated, it can act as a descriptor of the object’s morphological scale structure.
9. Shape-Matching Distance
We can measure the difference between two pattern spectra using a distance.
A weighted version can give some scales more importance than others:
Here:
- \(f_A(r)\) is the pattern spectrum of object \(A\).
- \(f_B(r)\) is the pattern spectrum of object \(B\).
- \(w_r\) controls the importance of scale \(r\).
- \(d(A,B)\) measures the difference between the two descriptors.
A smaller distance means the two pattern spectra are more similar.
A larger distance means the two pattern spectra are more different.
This compares the objects’ morphological scale distributions. It does not prove that two objects have exactly the same geometric shape.
10. What Happens When a Shape Rotates?
Another useful experiment is to compare an object with a rotated version of itself.
A structuring element with rotational symmetry may respond similarly to certain rotations, while another structuring element may produce a different descriptor after the object is rotated.
11. Interactive Granulometry Example
The interactive visualizer below lets you build the descriptor instead of only looking at a finished result.
Choose or edit a binary image and select one of its connected components. You can then increase the opening scale one step at a time.
As the structuring element grows, the visualizer shows the opened object together with the remaining area \(U(r)\). The successive losses in area are used to build the pattern spectrum \(f(r)\).
In comparison mode, you can choose two shapes, rotate the test object, change the structuring element, and compare their pattern spectra using a shape-matching distance.
12. What Can Affect the Descriptor?
A pattern spectrum is not determined by the object alone. Several choices can change the result.
Different structuring-element shapes probe different geometric structures.
Two objects that produce the same spectrum with one structuring element may produce different spectra with another.
Pixel resolution affects which physical object sizes correspond to each morphological scale.
Rotating an object may change its interaction with a structuring element that is not rotationally symmetric.
Small foreground or background defects can change the object’s behavior at the smallest scales.
This can alter the first few values of the pattern spectrum.
If two objects are accidentally joined, or one object is split into multiple components, the descriptor is no longer describing the same shape.
In weighted matching, changing \(w_r\) changes how much each morphological scale contributes to the final distance.
Two visibly different objects can sometimes have the same pattern spectrum.
For example, if two objects lose exactly the same fraction of their area at every tested scale, their pattern-spectrum distance can be zero even though their pixel arrangements are different. The interactive visualizer demonstrates this by letting you change the structuring element.
13. Summary
| Concept | Meaning |
|---|---|
| \(X\circ B_r\) | Open object \(X\) using the structuring element at scale \(r\) |
| \(U(r)\) | Foreground area remaining after the opening |
| \(f(r)\) | Fraction of the original area lost at scale \(r\) |
| Pattern Spectrum | Distribution of the object’s structure across morphological scales |
| \(H(X|B)\) | A summary of how the pattern spectrum is distributed across scales |
| \(d(A,B)\) | Difference between two pattern-spectrum descriptors |
Be First to Comment