Page 63 - DCAP504_Computer Graphics
P. 63

Computer Graphics



                          5.2   Region Filling

                          The process of coloring the object or image area or region is called  region filling. The region of the
                          image or the object is defined at the pixel level. At pixel level, the region is defined in terms of bounding
                          pixels that outline the entire image or interior pixels that define the object on the screen. Based on this,
                          two algorithms are defined for filling the object. They are:
                          1.  Boundary-Defined Region: Figure 5.3 (a) shows the boundary defined region of a polygon. The
                              algorithm used to define this is called the boundary-fill algorithm. This algorithm begins with a
                              starting pixel or seed from which the filling starts in side the region. The algorithm continuously
                              checks for the image’s boundary. The boundary acts as the end of filling. All the pixels that lie
                              within the boundary are filled. The algorithm works on an arbitrary region by checking and filling
                              the non-boundary pixels. All the pixels that are not the part of the boundary are filled. The filling
                              seed is considered as the reference point or start pixel, then the neighboring pixel is processed by
                              the algorithm to check whether it is the boundary pixel or not. If the neighboring pixel is a non-
                              boundary pixel it is filled and acts as the seed for next filling. If it is the boundary then filling stops
                              for the current pixel. Thus, the algorithm processes and checks for non-boundary pixels and fills
                              them.

                                                     Figure 5.3 (a): Boundary-Defined Region

























                                      When the filling of the pixel takes place the pixel acquires a color that is defined by the
                                      algorithm.


                          2.  Interior-defined Region:  Figure  5.3(b) shows the interior-defined region of a polygon. The
                              algorithm used to define this is called flood-fill algorithm. Even this algorithm begins with a seed
                              inside the polygon. The pixel inside  the polygon region has the region's original color  i.e., the
                              interior-deigned  region of the polygon has a pre-defined color, when the algorithm finds the
                              original color then the pixel is changed to a new color. This pixel acts as the seed for the next pixel
                              and processes it. If the pixel does not has the region's color then that pixel is consider as the end of
                              the polygon. The process continues till the colors of all the pixels are changed from the original to
                              the new color. Thus, in a flood-fill algorithm the filling is done by chaining the original color to the
                              new color.













                          56                      LOVELY PROFESSIONAL UNIVERSITY
   58   59   60   61   62   63   64   65   66   67   68