Page 142 -
P. 142

116   Chapter 3 ■ Digital Morphology


                           3.3.8    Identifying Region Boundaries
                           The pixels on the boundary of an object are those that have at least one
                           neighbor that belongs to the background. Because any background neighbor
                           is involved it cannot be known in advance which neighbor to look for, and a
                           single structuring element that would allow an erosion or dilation to detect
                           the boundary can’t be constructed. This is in spite of the fact that an erosion
                           by the simple structuring element removes exactly these pixels!
                             On the other hand, this fact can be used to design a morphological boundary
                           detector. The boundary can be stripped away using an erosion and the eroded
                           image can then be subtracted from the original. This should leave only those
                           pixels that were eroded — that is, the boundary.
                             A MAX program for this is:

                             // Boundary extraction
                             image a, b, c;
                             begin
                                    doa<<   ˝ $1˝;
                                    b := {[3,3], [1,1],  ˝ 111111111˝};  // Simple structuring element
                                    c := (a - (a--b));
                                    message c;
                                    doc>>   ˝ boundary.pbm˝;
                             end;
                             Figure 3.19 shows this method used to extract the boundaries of the
                           ‘‘squares’’ image of Figure 3.18a. A larger example, that of a quarter rest
                           scanned from a page of sheet music, also appears in the figure.













                                     (a)             (b)              (c)          (d)      (e)
                           Figure 3.19: Morphological boundary extraction. (a) The squares image. (b) The squares
                           image after an erosion by the simple structuring element. (c) Difference between the
                           squares image and the eroded image: the boundary. (d) A musical quarter rest, scanned
                           from a document. (e) The boundary of the quarter rest as found by this algorithm.

                           3.3.9    Conditional Dilation

                           There are occasions when it is desirable to dilate an object in such a way that
                           certain pixels remain immune. If, for example, an object cannot occupy certain
   137   138   139   140   141   142   143   144   145   146   147