p5 Notes Flood Fill Algorithm For Polygon Filling
p5 Notes Flood Fill Algorithm For Polygon Filling
Theory:
Polygon Filling:
Filling a polygon means highlighting all the pixels which lie inside the polygon with any
color other than the background color.
One way to fill the polygon is to start from given seed point known to be inside the
polygon and highlighting out word from this point, i.e. neighboring pixels until we
encounter the boundary pixels.
This approach is called Flood Fill because color flows from the seed pixel until reaching
the polygon boundary
In this method the edges of the polygon are drawn then starting with some seed at any
point inside polygon, we examine neighboring pixels to check whether the boundary
pixel is reached.
If the boundary pixels are not reached, pixels are highlighted and the process is
continued until boundary pixels are not reached. Since this process involves checking of
the boundaries this method is called boundary fill method.
4-connected region
8-connected region
By- Prof.U.N.Abhonkar,Sandip Polytechnic
If region is 4-connected then every pixel in the region may be reached by combination
moves in 4 directions: Left, Right, Up, Down
If region is 8-connected then every pixel in the region may be reached by combination
moves in 2 horizontal, 2 vertical and 4 diagonal directions.
In some cases 8-connected flood fill algorithm is more accurate than 4-connected flood fill
algorithm
The following procedure illustrates the recursive method for filling a 4-connected region
with color specified in parameter fill color up to a boundary color