Page 145 -
P. 145

Chapter 3 ■ Digital Morphology   119









                                       (a)           (b)           (c)           (d)           (e)








                                            (f)            (g)            (h)            (i)
                               Figure 3.21: Filling a region using conditional dilation. (a) The boundary of the region to
                               be filled. This is the boundary found in Figure 3.19. (b) The structuring element. (c) The
                               seed pixel, and iteration 0 of the process. (d) After iteration 1. (e) After iteration 2. (f) After
                               iteration 3. (g) After iteration 4. (h) After iteration 5 the dilation is complete. (i) Union of
                               (h) with (a) is the result.


                                 A MAX program for region filling requires the input of the coordinates of
                               the seed pixel, which is the first time that integer input has been performed in
                               aMAX program. It is:

                                 // Fill a region with 1 pixels - Conditional Dilation
                                 pixel p;
                                 int i,j;
                                 image a, b, c, d;
                                 begin
                                        do a << “$1“;
                                        message “FILL: Enter the coordinates of the seed pixel “;
                                        doi<<““;         do j<<““;
                                        p := [i, j];      // SEED pixel.
                                        b := {[3,3], [1,1], “010111010“};
                                        c:=!a+ p;
                                        a:=~a;
                                        loop
                                               d:=(c++b) * a;
                                               exit when d=c;
                                               c:=d;
                                        end;
                                        do c + ~a >> “$2“;
                                 end;


                               3.3.10 Counting Regions

                               As a final example of the uses of morphology in binary images, it is possible to
                               count the number of regions in an image using morphological operators. This
   140   141   142   143   144   145   146   147   148   149   150