Image Processing & Correction

Fill holes

If a background region can't reach the image edge, it gets filled — regardless of size

Definition
Fill Holes is an operation on a binary maskLoading... that converts every fully-enclosed background region into foreground. A background region is fully enclosed if you can't trace a path from any pixel in it to the image edge without crossing foreground. The engine identifies these regions by flood-filling from the image boundary inward — any background pixel reachable from the boundary stays background; everything else becomes foreground. Unlike CloseLoading..., which fills gaps smaller than its structuring elementLoading..., Fill Holes is unconcerned with size. A one-pixel hole and a thousand-pixel cavity are equally targeted, as long as both are completely surrounded.
Supporting
H&EDSPTCH
Video · Supporting
Topological, not morphological
Asks about reachability, not neighborhood
Size doesn't matter; enclosure does
A 1-pixel hole and a 1000-pixel cavity are both filled
Holes touching the image edge stay open
Reachable from the boundary = not a hole
Where it sits in the workflow
After detection, before measurement

How the engine actually does it

The mechanical answer: Fill Holes flood-fills the background from the image border inward, marking every background pixel it can reach. When the flood is done, anything not marked is — by definition — unreachable from the border, which means it's enclosed by foreground. Those unmarked pixels are converted to foreground.

This is conceptually simple and computationally fast (one pass over the image). It's also why edge-touching holes stay open: the flood reaches them on its first move, and once they're marked as reachable, the engine has no further interest in them.

Share This Term
Term Connections