Page 131 -
P. 131

Chapter 3 ■ Digital Morphology   105


                                 Most opening and closings use the simple structuring element in practice.
                               The traditional approach to computing an opening of depth N is to perform
                               N consecutive binary erosions followed by N binary dilations. This means
                               that computing all the openings of an image up to depth ten requires that 110
                               erosions or dilations be performed. If erosion and dilation are implemented in
                               a naive fashion, this will require 220 passes through the image. The alternative
                               is to save each of the ten erosions of the original image; each of these is then
                               dilated by the proper number of iterations to give the ten opened images. The
                               amount of storage required for this latter option can be prohibitive, and if file
                               storage is used the I/O time can be large also.
                                 A fast erosion method is based on the distance map of each object, where
                               the numerical value of each pixel is replaced by a new value representing the
                               distance of that pixel from the nearest background pixel. Pixels on a boundary
                               would have a value of 1, being that they are 1 pixel width from a background
                               pixel; pixels that are 2 widths from the background would be given a value
                               of 2, and so on. The result has the appearance of a contour map, where the
                               contours represent the distance from the boundary. For example, the object
                               shown in Figure 3.14a has the distance map shown in Figure 3.14b.


                                                        00000000000000000000000000000000  00000000000000000000000000000000
                                                        00000000000000000000000000000000  00000000000000000000000000000000
                                                        00000000000000000000000000100000  00000000000000000000000000 . 00000
                                                        00000000000000000000000001100000  0000000000000000000000000 . . 00000
                                                        00000000000000000000111111100000  00000000000000000000111111 . 00000
                                                        00000000000000000111122221000000  000000000000000001111222 . 1000000
                                                        00000111000000111122223211000000  00000 . . . 00000011112222 . 211000000
                                                        00000111111111122223333210000000  00000 . . 111111112222333 . 210000000
                                                        00000011222222223333433210000000  000000 . 1 . 2 2222223333 . 3 . 2 10000000
                                                        00000001123333333443332210000000  00000001 . 2 . 333333 . . 3332210000000
                                                        00000001123344444443222110000000  0000000112 . 3 444444 . 3 222110000000
                                                        00000000122345555433211100000000  00000000122345555433211100000000
                                                        00000000112345665432210000000000  00000000112345 . . 5432210000000000
                                                        00000000012345665432110000000000  00000000012345 . . 5432110000000000
                                                        00000000012345665432100000000000  00000000012345 . . 5432100000000000
                                                        00000000112345665432110000000000  00000000122345 . . 5432211000000000
                                                        00000000122345665432211000000000  00000000122345 . . 5432211000000000
                                                        00000011123345665433221100000000  00000011123345 . . 5433221100000000
                                                        00000112223445665443322110000000  00000112223445 . . 5443322110000000
                                                        00000122333455565544332211000000  000001223334 . 5 5 . 5544332211000000
                                                        00000123344444556554433221000000  0000012 . 3 . . 44455 . 5 . 4 433221000000
                                                        00000123333334455555443321000000  0000012 . 3333344555 . . 443321000000
                                                        00001122222233444555544321000000  00001122222233444 . . . . 4 . 321000000
                                                        00001221111223334455443321000000  00001 . . 11112233344 . . 443321000000
                                                        00001221001122233444433221000000  00001 . . 1001122233444433221000000
                                                        00001111000111223334332211000000  0000111100011122333 . 3 32211000000
                                                        00000000000001122233322110000000  00000000000001122233322110000000
                                                        00000000000000111222221100000000  00000000000000111222221100000000
                                                        00000000000000001111111000000000  00000000000000001111111000000000
                                                        00000000000000000000000000000000  00000000000000000000000000000000
                                                        00000000000000000000000000000000  00000000000000000000000000000000
                                                        00000000000000000000000000000000  00000000000000000000000000000000
                                          (a)                     (b)                     (c)
                               Figure 3.14: Erosion using a distance map. (a) A blob as an example of an image to be
                               eroded. (b) The distance map of the blob image. (c) Nodal pixels in this image are shown
                               as periods (.).
                                 The distance map contains enough information to perform an erosion by
                               any number of pixels in just one pass through the image; in other words,
                               all erosions have been encoded into one image. This globally eroded image
                               can be produced in just two passes through the original image, and a simple
                               thresholding operation will give any desired erosion.
   126   127   128   129   130   131   132   133   134   135   136