CGMM | Boundary Fill and Flood Fill Algorithm | Exp - 6
Boundary Fill and Flood Fill
1. Boundary Fill
This is an area filling algorithm. This is used where we have to do an interactive painting in computer graphics, where interior points are easily selected. If we have a specified boundary in a single color, then the fill algorithm proceeds pixel by pixel until the boundary color is encountered. This method is called the boundary-fill algorithm.
In this, generally two methods are given that are:
4-connected:
In this firstly there is a selection of the interior pixel which is inside the boundary then in reference to that pixel, the adjacent pixel will be filled up that is top-bottom and left-right.
8-connected:
This is the best way of filling the color correctly in the interior of the area defined. This is used to fill in more complex figures. In this four diagonal pixel are also included with a reference interior pixel (including top-bottom and left right pixels).
For more info visit includehelp.com
2. Flood Fill
Sometimes we come across an object where we want to fill the area and its boundary with different colors. We can paint such objects with a specified interior color instead of searching for particular boundary color as in boundary filling algorithm.
Instead of relying on the boundary of the object, it relies on the fill color. In other words, it replaces the interior color of the object with the fill color. When no more pixels of the original interior color exist, the algorithm is completed.
Once again, this algorithm relies on the Four-connect or Eight-connect method of filling in the pixels. But instead of looking for the boundary color, it is looking for all adjacent pixels that are a part of the interior.
For more info visit Tutorialspoint
No comments: