BOM Operation

Fill holes

Background that can't reach the image edge gets filled

Definition
Fill Holes works on a binary maskLoading... and converts every fully enclosed background region into foreground. A region is fully enclosed if no path leads from any of its pixels to the image edge without crossing foreground. Unlike CloseLoading..., which fills only gaps smaller than its structuring elementLoading..., Fill Holes fills enclosed regions of any size.
Supporting
H&EDSPTCH
Video · Supporting
Reachability, not neighborhood
Tests reachability, not neighborhood
Every enclosed hole is filled
1-pixel hole or 1000-pixel cavity: both filled
Edge-touching holes: your choice
Set by Allow fill on border
Its place in the workflow
After thresholding, before measurement

How the engine does it

Fill Holes floods the background from the image border inward, marking every background pixel the flood can reach. When the flood stops, any background pixel left unmarked is unreachable from the border by definition, which means foreground encloses it. The engine converts those pixels to foreground.

The method also explains why, with Allow fill on border off, edge-touching holes stay open. The flood reaches them on its first move, and once they are marked reachable, the engine leaves them as they are.

Share This Term
Term Connections