Mathematical morphology is a way to study and modify shapes in an image.
We will start with binary images, where every pixel is either foreground or background.
You can continue reading without knowing set theory. The Symbols & Definitions page explains the notation used here.
1. Binary Images
A binary image contains only two pixel values:
- 1 = foreground
- 0 = background
The blue pixels form the foreground object.
Instead of listing every 0 and 1, morphology often describes an image by storing only the locations of its foreground pixels. We call this collection of foreground locations \(X\).
2. Matrix View and Location View
The same binary image can be described in two ways.
Matrix View
Store every pixel as a 0 or 1.
Location View
Store only the locations where the image contains a 1.
3. The Structuring Element
Morphology uses a small pattern called a structuring element.
We call the structuring element \(B\).
The structuring element acts like a small probe that moves across the image.
The locations containing a 1 are the active parts of the structuring element.
4. Moving the Structuring Element
To perform morphology, we move the structuring element across the image one location at a time.
We use \(z\) to represent the current location of the anchor.
5. Reflection
Dilation uses a reflected version of the structuring element.
On a 2D grid, this can be viewed as rotating the structuring element by \(180^\circ\).
6. Dilation
Dilation usually makes foreground objects larger.
At each location \(z\), ask:
If yes, the output at that location becomes 1.
Keep \(z\) if the reflected structuring element overlaps the foreground at least once.
7. Erosion
Erosion usually makes foreground objects smaller.
At each location \(z\), ask:
If yes, the output at that location becomes 1.
Keep \(z\) only if the entire active structuring element fits inside the foreground.
8. Dilation vs. Erosion
| Operation | Question | Output = 1 When | Typical Effect |
|---|---|---|---|
| Dilation | Does anything overlap? | At least one active structuring-element point overlaps \(X\). | Expands foreground objects. |
| Erosion | Does everything fit? | Every active structuring-element point lies inside \(X\). | Shrinks foreground objects. |
Dilation: one overlap is enough.
Erosion: everything must fit.
9. Interactive Example
Move the structuring element across the image and watch how the condition changes at each location.
Green = condition satisfied
Red = condition not satisfied
Purple = anchor position
Interactive Morphology Visualizer
10. What Do These Operations Do?
Dilation
Dilation can:
- make objects larger,
- fill small gaps,
- connect nearby regions,
- make thin foreground regions thicker.
Erosion
Erosion can:
- make objects smaller,
- remove small foreground regions,
- break narrow connections,
- separate nearby objects.
11. Summary
A binary image contains foreground pixels and background pixels.
We call the collection of foreground locations \(X\).
A structuring element, \(B\), is a small pattern used to examine the shape of \(X\).
The anchor tells us where the structuring element is currently positioned.
Dilation produces an output of 1 when at least one active point overlaps the foreground.
Erosion produces an output of 1 only when every active point fits inside the foreground.
Be First to Comment