0
22kviews
Explain 8 connected flood fill algorithm in detail.What are its advantages over Boundary fill algorithm?
1 Answer
1
1.1kviews
  1. The limitations of boundary fill algorithm like if the polygon is having boundaries with different colors then boundary fill algorithm fails.

  2. This limitation of boundary fill algorithm is overcome in flood fill algorithm.

  3. The flood fill algorithm is also called as seed fill algorithm.

  4. This algorithm begins with seed point.

  5. Instead of checking boundary color this algorithm checks whether the pixel is having the polygon’s original color i.e. previous or old color.

  6. If the answer is yes then fills that pixel with new color and use each of the pixels neighboring pixel as a new seed in a recursive call.

  7. If the answer is no i.e. the color of pixel is already changed then return to its caller.

enter image description here

  1. Sometimes we want to fill an area that is not defined within a single color boundary as shown in figure 15.

  2. Here edges AB, BC, CD and DA are having red, blue, green and pink color, respectively.

  3. This figure shows an area bordered by several color regions.

  4. We can paint such areas by replacing a specified interior color instead of searching for a boundary color value.

  5. Here we are setting empty pixel with new color till we get any colored pixel.

  6. Flood fill and boundary fill algorithms are somewhat similar.

  7. A flood fill algorithm is particular used when the region or polygon has no uniformed colored boundaries.

Recursive method for flood fill algorithm by using 8 – connected method:

enter image description here

Please log in to add an answer.