Page 126 -
P. 126

100   Chapter 3 ■ Digital Morphology


                           (Figure 3.9e). There are now gaps in the image where the lines used to be,
                           but otherwise the music symbols are free of the lines. A further morphological
                           step can fill in some of the gaps (Figure 3.9f).






                                                                 (c)                   (d)





                                     (a)

                                                                 (e)                   (f)
                                              (b)
                           Figure 3.9: Morphological removal of staff lines from printed music. (a) The original
                           image. (b) The structuring element. (c) Result of the erosion of (a) by (b). (d) Result of
                           dilating again by the same structuring element. (e) Subtract (d) from (a). (f) Use a simple
                           morphological operator to fill in the gaps.



                           3.3.4    Implementation of Binary Erosion
                           As was done previously in the case of dilation, the implementation will consist
                           of a program that creates an eroded image given an input image and a
                           structuring element, and a function that does the actual work. The program is
                           in the same style as BinDil, and is called BinErode:

                             BinErode
                             Enter input image file name:               squares.pbm
                             Enter structuring element file name:       simple.pbm
                             Enter output filename:                     xx.pbm
                             The PBM file for the structuring element of Figure 3.9b would be:

                             P1
                             #origin 1 0
                             316
                             11 1
                             00 0
                             00 0
                             00 0
                             11 1
                             00 0
                             00 0
                             00 0
                             11 1
                             00 0
   121   122   123   124   125   126   127   128   129   130   131