Difference between Flood Fill and Boundary Fill Algorithm

Flood Fill Algorithm:

Algorithms used for filling interior-defined regions are generally known as Flood Fill Algorithm. Such an algorithm starts with a seed pixel by replacing its existing colour with the fill colour. Then using the 4-connected or 8-connected chain the algorithm sets fill colour to the other interior pixels. Assuming that all the pixels in an interior-defined region have the same colour, the flood fill algorithm terminates when no more connected pixel has the old colour.

Steps of Flood Fill Algorithm:

[c]Algorithm FloodFill4(x, y, original_Color, fill_Color)
SetPixel(x, y, fill_Color);
FloodFill4(x, y, boundary_Color, fill_Color);
FloodFill4(x, y+1, boundary_Color, fill_Color);
FloodFill4(x-1, y, boundary_Color, fill_Color);
FloodFill4(x+1, y, boundary_Color, fill_Color);

Boundary Fill Algorithm:

To fill a boundary-defined area is to start at a point (pixel) inside the area and paint the area progressively towards the boundary. This method is called Boundary Fill Algorithm. The Boundary Fill is a recursive procedure with a fill colour. It is specified by the parameter ‘fill‘ and boundary colour specified by parameter ‘boundary‘.

Steps of Boundary Fill Algorithm:

[c]Algorithm BoundaryFill4(x, y, boundary_Color, fill_Color)
if(Color<>boundary_Color and Color<>fill_Color)
SetPixel(x, y, fill_Color);
BoundaryFill4(x, y+1, boundary_Color, fill_Color);
BoundaryFill4(x-1, y, boundary_Color, fill_Color);
BoundaryFill4(x, y-1, boundary_Color, fill_Color);
BoundaryFill4(x+1, y, boundary_Color, fill_Color);

Flood Fill vs Boundary Fill Algorithm:

Flood Fill Algorithm
Boundary Fill Algorithm
1. It defines the area containing several colors1. It defines the area with a single color
2. It is slower than the Boundary-fill algorithm2. It is faster than the Flood-fill algorithm
3. In Flood-fill algorithm, a random colour can be used to paint the interior portion then the old one is replaced with a new one.3. In Boundary-fill algorithm, the Interior points are painted by continuously searching for the boundary color.
4. It requires high amount of memory consumption4. It requires low amount of memory consumption
5. The complexity of Flood-fill algorithm is simple5. The complexity of Boundary-fill algorithm is high