# Difference between flood fill and boundary fill

Under the categorization of the area fill algorithm, the flood fill and boundary fill algorithm fall in it. First of all, checking if a random pixel possesses the region's original color or not is the crucial differing point in the algorithm list. On the other hand, the boundary pixel is examined by the boundary fill, and if it has also been filled or not is also examined by it.

The process of coloring a specific image region or area is called region filling or area. On the basis of geometrical levels or the pixel, these areas can be described.

## Flood fill algorithm definition:

The working mechanism of the flood fill algorithm is by recoloring or filing the mentioned area possessing the various colors on the boundary of the image and on the interior part. This algorithm can be illustrated by different distinct region colors having an area bordered. Rather than discovering a boundary color value, we can replace a particular interior color to paint such regions. This type of approach for the corresponding is called a flood fill algorithm.

From a certain point (x, y), the algorithm starts working, and with all the required filling colors, it reallots all the pixel values that are recently fixed at the specified interior color. The pixel values are reallocated in the condition of multiple colors of the interior. For this reason the same color is contained by all the interior points.

For the creation of the continuous boundary, there are two types of methods that can be used by the connection of the pixel - 4 connected and pixel - 4 connected approaches. At the maximum of four neighbors the pixel may have in the 4 - connected method, which is positioned at the left, right, and below and above the current pixel. On the other hand, it has eight, and the checking is made in the neighboring of the 8 - connected method against the four diagonal pixels. From that, to reprint the interior points, any of the two methods can be used.

## Boundary fill algorithm definition:

An approach followed by the boundary fill algorithm in which the region filling begins inside a region from a point, and towards the boundary, it paints the interior. The fill algorithm continues when the single color is contained by the boundary in the outward direction pixel by pixel is encountered until the boundary color. In the interactive painting packages, the boundary fill algorithm will be implemented mainly where the interior points are easily chosen.

By accepting the coordinates of an interior point (x, y), it starts the functioning of the boundary fill, a boundary color, and a fill color as input. The process checks neighboring locations from the beginning (x, y) to identify whether these are part of the boundary color or not. They will be painted with the fill color when they are not from the boundary color, and their side pixel is examined against the condition. The process ends at the time when the entire pixels are up with the boundary color for the area checked.

## Comparison of the flood fill algorithm and boundary fill algorithm:

Comparison on the basis of Flood fill algorithm Boundary fill algorithm
Basic Several colors can be contained in this area. A single color is defined by this area.
Consumption of memory Memory consumption in this algorithm is very high. Memory consumption in this algorithm is very low.
Process of painting For coloring the interior part a random color is used and after that the old color is updated with the new one. With the help of continuous searching for the boundary color, the interior part is color
The complexity of the algorithm In this algorithm, the complexity of the algorithm is relatively simple. In this algorithm, the complexity of the algorithm is relatively complicated.
Speed It is relatively slower than others. It is relatively faster than others.

## Conclusion

The flood-fill and boundary-fill algorithms are used for different purposes or in different scenarios. Flood-fill works better with the object having no uniformly colored boundaries. As against this, the boundary-fill can elegantly be operated on an arbitrarily shaped region having a single boundary color.

Next TopicDifference between