 Hello everyone, my name is Mr. Sandesh Pare, I am currently working as an assistant professor in the department of computer science and engineering at Valtran Institute of Technology in Singapore. In this video, I am going to cover a concept called polygon filling. The main task in this is to correctly fill the polygon with the specified color. To add the very first, we will check the learning outcome. What happened at the end of this session is to, a student will be able to implement the program for filling the polygon with a particular color using the different techniques. Means the task is same, but there are various techniques to fill the polygon. So we will start the concept of the polygon filling. The basic method or we can say the simplest method to fill the polygon is to just check every pixel on the display that whether it is residing inside the polygon or not. If it is inside the polygon, we will mark it with the polygon color and if it is not, then we will color it with the background color. So it is the one simple method to fill the polygon. What happened? Suppose the polygon is very short, it is residing only within a short area of the display. And for that, we have to examine each and every pixel on the display. So it is not an efficient one. So this amount of work can be reduced by computing the bounding box. What is bounding box? So it is the smallest rectangle on the display which contains the polygon inside it. Means it is the smallest rectangle and within that box, there is a polygon. The polygon does not exceed the boundary of the bounding box. And that's why we need to examine the pixels within the bounding box only. And in this way, we can reduce the amount of work. And it can be found, the bounding box can be found by using the min-max test. Means minimum and maximum value of the x coordinate and minimum and maximum value of the y coordinate using the endpoints of the polygon. We can found the bounding box so that the number of pixels can be reduced. See, in this diagram, we can see the bounding box. You can see the whole square is the display. But inside that, the polygon is residing only within the short area. And for that, if we scan each and every line in each and every pixel on the display, then it will be not efficient. So for that, we have calculated the bounding box which is shown in the dashed line. And within that dashed box line, the polygon resets within that. So the pixels need to be examined as reduced and thus the computing time will be reduced. So we will start with the topic that is scan converting polygons. What I want that there are two concepts. This is the spatial currents and the scanline currents. What is spatial currents? It means except the boundary edges. All the adjacent pixels, if there is one image, what happens that the area, the certain area is having the same color. Each and every pixel residing within the certain area of that image is having the same color. So instead of saving the color value for each and every pixel, we can store it combined. And that concept we have already covered in the image compression type. So that in one more than scanline currents, means for raster scan graph, if the adjacent pixels on the scanline holds the same property, otherwise we can say the same color. At that time, the simplest method is to instead of marking it the pixel, we can directly draw the line from the starting point to the end point. And using that line function, we can reduce our work. So this is the two concept that is spatial currents and scanline currents are the two major concepts in this scan converting polygons. Let us see at this diagram. What is there? There is one polygon and we have to fill it. And suppose that x and y coordinate is the display, total display. And using the scanline conversion, what happens that suppose for the scanline 4, just look at the scanline 4. If we started the scanning from the value of the x is equal to 0 up to the maximum x value. And at that time, you can see there are two intersections at the p5 and p3. The polygon is having the 5 end points that is p1 to p5. And the scanline 4 is going through or passing through the polygon. Just take it into consideration, we will discuss in the next slide. The properties of the pixels of scanline change at every age intersect. As I have told earlier that there are two intersections at the very first intersection. After this intersection, we will change the color means at the very first we are marking the pixels with the background color. And whenever the first intersection is there after that we are going to color it with the every pixel with the polygon color until we reach to the second intersection. This algorithm will work to fill the polygon. And the next is the intersection divides the scanline into regions. Means what happened? There are on the scanline 4 as we have seen earlier, there are three regions up to the 0 to 2 value, 0 to 2 it is a means before any intersection and 2 to 6. That means the second region after first intersection and before second intersection. And the third region is the after second intersection. So in this way the area is divided into the regions. See that point is the same that is the scanline 4 in the figure intersect the polygon at the x is equal to 2 and 6. Because it is intersecting at the x is equal to 2 and 6 value. On that basis the region are founded that is the first one is the outside the polygon means within we reach to the first intersection that is the value of x is less than 2. And after the first intersection and up to the second intersection whatever the value of the x it is the x is equal to less than equal to 6 and greater than equal to 2. And it is marked as the inside the polygon between the pair of intersection whatever the region is there the that area is called as the inside the polygon. And we have to mark that pixels by the polygon color. And the third region is the x is greater than 6 it is means after the second intersection whatever until we get the next intersection that are the end of the scanline whatever the region is there that is outside the polygon. There is one question for you guys that is what is the difference between the spatial corons and the scanline corons see the difference is the adjacent pixels holding the same value in the particular image ok which except the boundary edges whatever the values are there it may be the multiple pixels and they are not belonging to the same row or the same column ok means but they are connected to each other. But they holding the same properties at that time it is called as the spatial corons. But in the raster scan device we are going to scan it by line by line ok at that time that whatever adjacent pixels on that scanline are ok that with the same value they are referred as the scanline corons. So, scanline converting polygons have some certain rules ok means whatever the intersection we are getting on the scanline ok we have to always sort them in the ascending order means the intersection of these suppose at the second sixth fourth and ninth position. But they should be first sort into the ascending order that is two four six and nine ok and after the sorting ok they have to make pairs ok means first and second third and fourth fifth and sixth in this way whatever the intersection values are there they should be merged into the pairs ok and after that whatever the interval between that end points ok means that end points of the pair ok and they belonging to the inside the polygon ok and the values which are not in their pairs ok means along sorry beyond that pairs ok that are the background pixels and for interval between the pairs of intersections ok background color will set because they are not belonging the area inside the polygon ok they are belonging to the outside the polygon. So, that is why background color will set and they will be marked by the background color and the pixel ok and before and before the first intersection and after the last intersection ok there is no any intersection before first and after last ok so that will be considered as the outside the polygon and so that they also may mark by the background color. And if suppose certain scan line value is having the three intersections of the polygon or the five it means odd values of the intersections are there then it is sure that particular intersection is one of the end point of the polygon ok means among that all odd values of the intersections there is one end point of the polygon so we have to ignore it. So, these are some references I used to make this video. Thank you.