MC0072-Computer Graphics
1.) Describe the theory of Polygon and Pattern filling along with their corresponding algorithms.
Ans.)
Polygon Filling
Filling the polygon means highlighting all the pixels which lie inside the polygon with any color other than background color. Polygons are easier to fill since they have linear boundaries.
There are 2 basic approaches used to fill the polygon. One way to fill a polygon is to start from a given “seed point” known to be inside the polygon and highlight outward from this point i.e neighboring pixels until we encounter the boundary pixel. This approach is called seed fill because color flows from the seed pixel until reaching the polygon boundary. Another approach to fill the polygon is to apply the inside test i.e to check whether pixel is inside the polygon or outside the polygon and then highlight pixels which lie inside the polygon. This approach is known as scan line algorithm. Seed fill
This seed fill algorithm is further classified as flood-fill algorithm and boundary fill algorithm. Algorithms that fill interior defines regions are called flood-fill algorithms, those that fill boundary-defined regions are called boundary-fill algorithms or edge-fill algorithms. Boundary Fill algorithm
In this method edges of a polygon are drawn. Then starting with some seed (point) , any point inside the polygon we examine the neighboring pixels to check whether the boundary pixel is reached. If boundary pixels are not reached, pixels are highlighted and the process is continued until boundary pixels are reached.
Boundary defined regions may be either 4-connected or 8-connected as shown in the fig if a region is 4-connected, then every pixel in the region may be reached by a combination of moves in only 4 directions: left, right, up and down. For an 8-connected region every pixel in the region may be reached by a combination of moves in the 2 horizontal, 2 vertical and 4