Report

1 A polyline is a chain of connected line segments. When starting point and terminal point of any polyline is same, i.e. when polyline is closed then it is called polygon. 2 The classification of polygons is based on where the line segment joining any two points within the polygon is going to lie. Convex : is a polygon in which the line segment joining any two points within the polygon lies completely inside the polygon. Concave: is a polygon in which the line segment joining any two points within the polygon may not lie completely inside the polygon. 3 To add polygon to a graphic system, we must first decide how to represent it. There are three approaches: 1. Polygon drawing primitive approach 2. Trapezoid primitive approach 3. Line and point Most of the graphic devices do not provide any polygon support at all. In such cases polygons are represented using lines and points. Display file 4 Filling the polygon means highlighting all the pixels which lie inside the polygon with any color other than background color. Seed Fill : point known to be inside the polygon and highlight the outward from this point i.e., neighboring pixels until we encounter the boundary pixels. Boundary fill algorithm and flood fill algorithms Scan – line algorithm fill : Avoid seed point but it is costly !!!! It checks whether pixels inside or outside the polygon. 5 6 Two difficulties with seed fill algorithms 1. If some inside pixels are already displayed in fill color then recursive branch terminates, leaving further internal pixels unfilled. Solution: change the color of any internal pixels that are initially set to the fill color before applying seed fill procedure. 2. It can not used for large polygons. Solution: more efficient method can be used.. Such method fills horizontal pixel spans across scan lines, instead of proceeding to 4-connected or 8- connected neighboring point. 7 8 Begins with the largest y value and scans down the polygon. For each y, it determines which sides can be intersected and finds the x values of these intersection points. It then sorted, pairs and passes these x values to a line drawing routine. 9 Real Time Scan Conversion The picture is randomly represented in terms of visual attributes and geometric properties. The color, shade and intensity (attributes), (x,y), slope and text (geometric) 1. Advantages: less memory, easy update the list, dynamic picture representation Disadvantages: Complexity of the picture is limited by speed of the display processor. 10 2. Run Length Encoding In many pictures, we observe that a large number of pixels in the picture have the same intensity or color. Advantages: picture is stored in compressed form 10:1, less memory, saves storage for animated sequences and films Disadvantages: since RLE is sequential, update is difficult and for short runs, expansion may result instead of compression. 11 12 1. 2. 3. 4. 5. What is polygon? Explain different types of polygons. Explain various approaches to represent polygons. Explain the polygon entering algorithm in the display file. Discuss the merits and demerits of real time scan conversion and RLE. For large polygons the flood fill algorithm may fail, why? What could be the method to avoid this? 13