Skip to content

Granulometry and Pattern Spectra

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.

From a Binary Object to a Morphological Descriptor
Binary object \(X\)
↓
Open \(X\) using increasing scales
↓
Measure what disappears at each scale
↓
Describe or compare the object’s shape
\[ \text{Openings} \rightarrow U(r) \rightarrow f(r) \rightarrow H \rightarrow d \]

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

Connected-component labeling separates the foreground into individual objects:

\[ X_1,\; X_2,\; \ldots,\; X_N \]

Each connected object can then be analyzed independently.

\(X_1\)
\(X_2\)
\(X_3\)
\(X_4\)

After one object is selected, the following granulometry calculations are performed on that object rather than on all of the objects at once.

For the rest of this lesson: \(X\) represents one connected foreground object being analyzed.

3. Opening with Increasing Structuring Elements

Instead of opening the object only once, we repeat the operation using structuring elements whose scale increases.

\[ B_0,\; B_1,\; B_2,\; B_3,\; \ldots \]
\(X\circ B_r\) means: open object \(X\) using the structuring element at scale \(r\).
The Structuring Element Grows as \(r\) Increases
\(r=0\)
1 × 1
\(r=1\)
3 × 3
\(r=2\)
5 × 5
\(r=3\)
7 × 7
Original
\(r=0\)
Small Opening
\(r=1\)
Larger Opening
\(r=2\)
Large Enough
∅
Object disappears
Large structures survive longer. Smaller structures disappear at smaller opening scales.

4. Size Distribution

At each scale, we count the number of foreground pixels that remain after opening.

\[ U(r)=|X\circ B_r| \]

At scale zero:

\[ U(0)=|X|. \]
\(U(r)\) answers: How much of the original object still survives at scale \(r\)?
Scale \(r\) Remaining Area \(U(r)\)
0 120
1 110
2 82
3 35
4 0
Example Size Distribution
120 90 60 30 0 0 1 2 3 4 Scale r

Measuring the remaining area across a sequence of openings is the central idea behind morphological granulometry.

5. Pattern Spectrum

The size distribution asks:

How much remains?

The pattern spectrum asks:

How much disappears at each scale?
\[ f(r) = \frac{ U(r-1)-U(r) }{ U(0) }, \qquad r\ge 1 \]
\(f(r)\) is the fraction of the original object’s area that is lost when the scale changes from \(r-1\) to \(r\).

For example:

\[ f(1) = \frac{120-110}{120} \approx 0.083 \]
\[ f(2) = \frac{110-82}{120} \approx 0.233 \]
Example Pattern Spectrum
0.083 0.233 0.392 0.292 1 2 3 4 Scale r
The sequence \(f(1),f(2),f(3),\ldots\) is called the pattern spectrum.

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.

A large peak at scale \(r\) means that a relatively large fraction of the object’s area disappears at that scale.

7. Morphological Entropy

We can summarize how spread out the pattern spectrum is using a single value.

Concentrated Spectrum

Lower \(H\)

Spread-Out Spectrum

Higher \(H\)

\[ H(X|B) = -\sum_r f(r)\log_2 f(r) \]
Morphological entropy summarizes how the object’s scale information is distributed across the pattern spectrum.

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.

Object \(A\)
Connected binary object
Object \(B\)
Similar scale, different local geometry
If two objects respond similarly to the same sequence of openings, their pattern spectra will also tend to be similar.

9. Shape-Matching Distance

We can measure the difference between two pattern spectra using a distance.

\[ d(A,B) = \left( \sum_r \left[ f_A(r)-f_B(r) \right]^2 \right)^{1/2} \]

A weighted version can give some scales more importance than others:

\[ d(A,B) = \left( \sum_r w_r \left[ f_A(r)-f_B(r) \right]^2 \right)^{1/2} \]

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.
How to read the distance:

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.

Original
↻
Rotated
A morphological descriptor depends not only on the object, but also on the structuring element used to probe it.

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.

What you can explore

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.


Interactive Granulometry & Pattern Spectrum
Connected Objects
Binary Image X
Select one connected foreground object above. Increasing openings are then applied to that object to calculate its size distribution U(r), pattern spectrum f(r), and morphological entropy H.
Original Binary Image
Click cells to edit. Orange shows the selected connected object.
Opened Object
X ◦ B0
Current Structuring Element
Scale r
0
Original Area
0
U(r)
0
f(r)
—
Entropy So Far
0
Size Distribution U(r)
Pattern Spectrum f(r)
Reference A
Reference orientation
Test B
Rotation: 0°
H(A)
0
H(B)
0
Spectrum Length
0
Pattern Spectrum Comparison
Blue = reference, orange = test.
Shape-Matching Distance
0.000

12. What Can Affect the Descriptor?

A pattern spectrum is not determined by the object alone. Several choices can change the result.

B
Structuring Element

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.

r
Scale and Resolution

Pixel resolution affects which physical object sizes correspond to each morphological scale.

↻
Rotation

Rotating an object may change its interaction with a structuring element that is not rotationally symmetric.

•
Noise

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.

X
Segmentation

If two objects are accidentally joined, or one object is split into multiple components, the descriptor is no longer describing the same shape.

w
Distance Weights

In weighted matching, changing \(w_r\) changes how much each morphological scale contributes to the final distance.

A Morphological Descriptor Comes from a Complete Analysis Pipeline
Binary Image
↓
Segmentation and Connected Components
↓
Choose a Structuring Element
↓
Granulometry and Pattern Spectrum
↓
Entropy and Shape Comparison
A pattern spectrum should therefore be interpreted together with the preprocessing, segmentation, structuring element, scale definition, and comparison method used to produce it.
An important limitation:

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
The Whole Idea in One Chain
Opening tells us what survives.
↓
Size distribution \(U(r)\) tells us how much survives.
↓
Pattern spectrum \(f(r)\) tells us where the area disappears.
↓
Morphological entropy \(H\) summarizes how the spectrum is distributed across scales.
↓
Distance \(d\) lets us compare two pattern spectra.
Big picture: granulometry describes an object indirectly by observing how the object responds to morphology at different scales.
Published inDigital Image Processing

Be First to Comment

Leave a Reply

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