Difference between flood fill and boundary fill algorithm

Boundary fill and Flood fill are two algorithms that lie under the Seed Fill method. In this, a seed point is selected and begins to fill until it reaches the object’s boundary.

Flood-fill algorithm

The flood fill algorithm works on targeting at the interior portion by recolouring and even filling a specific area having distinct colours.

This algorithm also pays attention to the boundary of the image, but as the limit of the operation. In this algorithm, all the focus is on the interior colour value and not the boundary colour value.

flood fill

Boundary-fill algorithm

The boundary fill algorithm works by initiating the filling process from a point which already inside (interior point) and continue to paint till the boundary value is reached. If this happens that boundary has a single colour then the algorithm fill process still continues pixel by pixel till boundary value is secured.

The approach is followed by this algorithm is the single colour driven.

Boundary fill algorithm

Difference between Flood-fill and Boundary-fill algorithms is as follows:

BasisFlood-fill algorithmBoundary-fill algorithm
ApproachIt works on targeting at the interior portion by recoloring and even filling a specific area having distinct colorsIt works by initiating the filling process from a point which already inside (interior point) and continue to paint till the boundary value is reached
NatureIt can be applied to figures having several boundary coloursIt can be applied to figures having a single boundary colour only
Memory UsageHigherLesser
SpeedSlowerFaster
ComplexityLowHigh

Key differences

  • NATURE

When we talk about the flood fill algorithm, the specific area in this can have more than one colour or even several colours; whereas; when we talk about the boundary fill algorithm then, this kind of algorithm always defines one colour for the specific area.

  • FILLING /PAINTING PROCESS

In case of flood fill algorithm, the approach is such that firstly a random colour can be used to paint/fill the interior part (portion) and then afterwards the old one gets replaced by the new one; whereas; in case of boundary fill algorithm, the interior points are coloured by pixel by pixel approach while continuously searching for the boundary colour.

  • SPACE/MEMORY USAGE

In flood fill algorithm, space or memory usage by this algorithm is more than the boundary fill algorithm; whereas; in the boundary fill algorithm, space or memory usage by this algorithm is lesser than the flood fill algorithm.

  • SPEED OF ALGORITHM

To give you a fair idea about the flood fill algorithm, the speed of this algorithm is relatively slower than the boundary fill algorithm; whereas; to give you a fair idea about the boundary fill algorithm, the speed of this algorithm is quite faster than the flood fill algorithm.

  • COMPLEXITY OF ALGORITHM

In the case of the flood fill algorithm, as we know that a random colour is chosen in this approach. This completely indicates that this algorithm quite simpler in terms of complexity; whereas; in the case of a boundary fill algorithm, as we know that pixel by pixel approach is followed. This completely indicates that this algorithm is quite complicated.

Leave a Reply