Morphological Opening Explained
Opening erodes first to delete specks, then dilates to regrow the survivors. Noise leaves while true objects return to full size.
Why Does This Exist?
Erosion alone removes specks but also shrinks everything worth keeping. You want the cleanup without the shrinkage. Opening solves it by following erosion with dilation: the first pass kills structures smaller than the probe, the second regrows survivors to their original outlines.
It is the standard denoiser in morphological operations. When the defects are holes rather than specks, use its mirror, closing.
Think of It Like This
Sieving then reflating
Shake mixed gravel through a sieve: pebbles fall through and boulders stay, which is erosion deleting the small. Then pump each surviving boulder back to full size, which is dilation regrowing them. The pebbles never return because nothing of them survived the sieve. Order matters: sieve first, then reflate, or the pebbles grow into boulders too.
How It Actually Works
Opening with structuring element applies erosion then dilation to image , written . The erosion pass deletes every foreground structure the probe cannot fit inside. The dilation pass expands each survivor by the same probe, restoring outlines that the erosion pulled inward. Large objects return to nearly their original size and shape, while deleted specks stay gone because dilation cannot invent foreground from nothing.
Worked example
A lone 1 sits in a zero field. Erosion with a probe: the zeros overlap the probe, so the center becomes 0. Dilation of that all-zero field stays 0. Final result 0, speck gone. A solid block under the same probe loses its border in erosion but regrows it in dilation, ending at nearly full size. Same operations, opposite fates, decided purely by size.
Watch Out For
Oversized probes eat real objects
Opening deletes everything smaller than the probe, including legitimate small targets. The symptom is missing dots, thin strokes, or small cells after cleanup. Measure your smallest keeper first and size the probe below it, or run connected-component filtering with an explicit area threshold instead.
The Quick Version
- Opening is erosion followed by dilation with the same probe.
- Specks smaller than the probe vanish permanently in the first pass.
- Survivors regrow to nearly original size in the second pass.
- It removes outside noise but cannot fill interior holes; that is closing.
- Size the probe between the noise scale and the smallest kept object.