Page 105 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 105

Unit 6: Implementing Polygon Filling Algorithm



                     BFill8 (x + 1, y);                                                           Notes
                     BFill8 (x – 1, y);
                     BFill8 (x, y + 1);
                     BFill8 (x, y – 1);
                     BFill8 (x + 1, y + 1);
                     BFill8 (x + 1, y – 1);
                     BFill8 (x – 1, y + 1);
                     BFill8 (x – 1, y – 1)
                     End;
                          Care must be taken to ensure that the boundary does not contain holes, which
                          will cause the fill to ‘leak’.

            Self Assessment Questions
               1.  ……………….. is a not algorithm present for polygon filling.

                 (  a)  Scan-line fill algorithm   (b)  Boundary-fill algorithm
                 (  c)  Flood fill algorithm     (d)  Bucket sort algorithm
               2.  Scan line fill algorithm is two special cases that are solved by this algorithm.

                 (  a)  two                      (b)  three
                 (  c)  four                     (d)  five
               3.  The ………………. step accepts a sorted list of points and connects them according to the
                 odd-party rule.
                 (  a)  first                    (b)  second
                 (  c)  third                    (d)  forth

               4.  The ………………..algorithm is particularly vulnerable.
                 (  a)  2-connected              (b)  4-connected

                 (  c)  6-connected              (d)  8-connected
               5.  Apply a bucket sort algorithm to sort the edges using the yl as the primary key, and xl
                 as the secondary, and w as the tertiary.

                 (  a)  True                     (b)  False

            6.3 Flood Fill Algorithm

            Flood fill, also named seed fill, is an algorithm that decides the area attached to a given node in
            a multi-dimensional array. The flood-fill algorithm is used to fill a region which has the same
            color and whose boundary may have extra one color.
            The seed fill or flood fill algorithm needs one of the pixel positions within the polygon or region
            to be filled. This pixel is inside the region and set to polygon value. This pixel is referred as seed
            pixel. The algorithm continues to search the pixels which are adjacent to the current seed pixel
            to see whether they are boundary pixels or the pixels inside the region. All the pixels interior
            to the region and are adjacent to the seed pixel are set to the polygon value.

            The purpose of Flood Fill is to colour an entire area of connected pixels with the same colour.
            It is the bucket tool in many painting programs. Here is an example: the original image is on



                                             LOVELY PROFESSIONAL UNIVERSITY                                    99
   100   101   102   103   104   105   106   107   108   109   110