Skip to main content

Boundary fill vs flood fill

Short answer

Boundary fill fills until a specified boundary color is reached, requiring a uniformly colored border. Flood fill replaces all pixels of an old interior color with a new color, stopping at any boundary color regardless of its uniformity.

Differentiate between boundary fill and flood fill algorithm.

Both are area-filling algorithms that start from a seed pixel and spread to neighbouring pixels (4-connected or 8-connected).

PointBoundary fillFlood fill
Region defined byA closed boundary of a single colourAn interior area of one colour (any boundary colours)
Stop conditionStops when boundary colour is reachedStops when a pixel is not of the old (interior) colour
UseRegion has a uniformly coloured boundaryRegion has multi-coloured boundary or irregular interior
Testpixel ≠ boundary colour and ≠ fill colourpixel = old interior colour
ResultFills interior up to the boundaryReplaces the old colour by the new colour
ExampleColouring inside a drawn polygon outlinePaint-bucket tool of image editors

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Graphics chapter 2 questions →