Chapter M Misc. Contents Mathematical morphology.............................................. M.1 Introduction................................................... M.1 Dilation..................................................... M.3 Erosion..................................................... M.3 Closing..................................................... M. Opening..................................................... M.5 Summary.................................................... M. Mathematical morphology Introduction The set of methods called mathematical morphology was founded by two researchers in Paris, Georges Matheron and Jean Serra, who were characterizing the geometrical structure of materials such as porous rocks. The techniques blossomed, and now there are several books on the topic [1, ] and review papers [3, ]. These methods are useful for a variety of image processing tasks (e.g., shape and size extraction, noise removal, skeletonization), and is particularly appropriate for real time machine vision applications (e.g., parts inspection, robotics, military systems). They are also useful for medical image analysis e.g. [5, ]. Both binary and gray-scale morphology algorithms have been developed. This summary will focus on the simpler binary case. To describe a LSI system that operates on grayscale images, it suffices to specify the impulse response h[n,m] of that system, and then the input-output relationship is given by the convolution sum: h[n,m] x[n,m] = k= l= We specify binary morphological operations by describing the structuring element. h[k,l] x[n k,m l]. The computation requirement for the dilation and erosion morphology algorithms is O(M N I J) with an M N image and an I J structuring element, which poses a challenge to implement on microprocessors in real time, especially for large structuring elements. One can implement these methods efficiently in hardware, e.g., a VLIW mediaprocessor [7]. In particular, one can implement binary morphology algorithms using a look up table (LUT), which is the essence of MATLAB s approach as well. M.1
M. c J. Fessler, April 1, 005, 11:1 (student version) MATLAB s image processing toolbox has the following binary image operations. applylut bwarea bweuler bwfill bwlabel bwmorph bwperim bwselect dilate erode makelut - Perform neighborhood operations using lookup tables. - Compute area of objects in binary image. - Compute Euler number of binary image. - Fill background regions in binary image. - Label connected components in binary image. - Perform morphological operations on binary image. - Determine perimeter of objects in binary image. - Select objects in binary image. - Perform dilation on binary image. - Perform erosion on binary image. - Construct lookup table for use with applylut. Of these, bwmorph has the following options: BWMORPH Perform morphological operations on binary image. BW = BWMORPH(BW1,OPERATION) applies a specific morphological operation to the binary image BW1. BW = BWMORPH(BW1,OPERATION,N) applies the operation N times. N can be Inf, in which case the operation is repeated until the image no longer changes. OPERATION is a string that can have one of these values: bothat Subtract the input image from its closing bridge Bridge previously unconnected pixels clean Remove isolated pixels (1 s surrounded by 0 s) close Perform binary closure (dilation followed by erosion) diag Diagonal fill to eliminate -connectivity of background dilate Perform dilation using the structuring element ones(3) erode Perform erosion using the structuring element ones(3) fill Fill isolated interior pixels (0 s surrounded by 1 s) hbreak Remove H-connected pixels majority Set a pixel to 1 if five or more pixels in its 3-by-3 neighborhood are 1 s open Perform binary opening (erosion followed by dilation) remove Set a pixel to 0 if its -connected neighbors are all 1 s, thus leaving only boundary pixels shrink With N = Inf, shrink objects to points; shrink objects with holes to connected rings skel With N = Inf, remove pixels on the boundaries of objects without allowing objects to break apart spur Remove end points of lines without removing small objects completely. thicken With N = Inf, thicken objects by adding pixels to the exterior of objects without connected previously unconnected objects thin With N = Inf, remove pixels so that an object without holes shrinks to a minimally connected stroke, and an object with holes shrinks to a ring halfway between the hold and outer boundary tophat Subtract the opening from the input image
c J. Fessler, April 1, 005, 11:1 (student version) M.3 Dilation The dilation operation is akin to convolution but with a logical OR replacing the usual multiply and add. 0 1 0 Example. Using the cross structuring element 1 1 1, we can write dilation as follows: 0 1 0 { 1, if any of {x[n,m],x[n 1,m],x[n + 1,m],x[n,m 1],x[n,m + 1]} are 1 { 1, x[n,m] +x[n 1,m] +x[n + 1,m] +x[n,m 1] +x[n,m + 1] 1 where h[n,m] is the structuring element defined above. We also write: { 1, (x h)[n,m] 1 x[n,m] h[n,m]. The convolution form is not computationally efficient, but is convenient when working with a software package that includes convolution but not binary morphology methods (e.g., if you do not have MATLAB s image processing toolbox). Explain lookup table approach. Easy to implement using PLA s for example. Example. For the above example, how many entries in table??? Erosion The erosion operation is akin to convolution but with a logical AND replacing the usual multiply and add. 0 1 0 Example. Using the cross structuring element 1 1 1, we can write erosion as follows: 0 1 0 { 1, if all of {x[n,m],x[n 1,m],x[n + 1,m],x[n,m 1],x[n,m + 1]} are 1 { 1, x[n,m] +x[n 1,m] +x[n + 1,m] +x[n,m 1] +x[n,m + 1] == 5 where h[n,m] is the structuring element defined above. We also write: { 1, (x h)[n,m] == 5 x[n,m] h[n,m].
M. c J. Fessler, April 1, 005, 11:1 (student version) Closing A closing is a dilation followed by an erosion: close(x) = erode(dilate(x)) Example. Suppose we are developing an image processing method to inspect a part such as a circuit board for defects consisting of holes (of single-pixel size for example). First dilate then erode the following image, and then look for places where they differ (XOR). Original image After dilation After erosion (closed) Difference
c J. Fessler, April 1, 005, 11:1 (student version) M.5 Opening A opening is an erosion followed by a dilation: open(x) = dilate(erode(x)). Example. Looking for extra solder spots on a circuit board (features that are smaller than a certain structuring element). First erode then dilate the following image, and then look for places where they differ (XOR). Original image After erosion 1 1 After dilation (opened) 1 1 Difference 1 1 1 1
M. c J. Fessler, April 1, 005, 11:1 (student version) Summary This is a rich field, with many interesting properties of the operators. Here are a few. First, and are shift invariant (but nonlinear), and associative: (X A) B = X (A B) (X A) B = X (A B) These properties spawned considerable work in decomposing large structuring elements into an equivalent sequence of smaller elements to save computation / lookup table size. (The motivation is similar to row-column decomposition for the FFT, or the use of separable filters.) Closing X A (X A) A (X A) A = (X A). Opening X A (X A) A (X A) A = (X A). Thus, closing and opening are idempotent operations. What LSI systems are idempotent??? Bibliography [1] J. Serra. Image analysis and mathematical morphology. Academic, London, 19. [] H. J. A. M. Heijmans. Morphological image operators. Academic Press, New York, 199. [3] H. J. A. M. Heijmans. Mathematical morphology: a modern approach in image processing based on algebra and geometry. SIAM Review, 37(1):1 3, March 1995. [] R. M. Haralick, S. R. Sternberg, and X. Zhuang. Image analysis using mathematical morphology. IEEE Trans. Patt. Anal. Mach. Int., 9():53 50, 197. [5] J. G. Thomas, R. A. Peters, and P. Jeanty. Automatic segmentation of ultrasound images using morphological operators. IEEE Trans. Med. Imag., ():, June 1991. [] B. D. Thackray and A. C. Nelson. Semi-automatic segmentation of vascular network images using a rotating structuring element (ROSE) with mathematical morphology and dual feature thresholding. IEEE Trans. Med. Imag., 1(3):35, September 1993. [7] G. York, R. Managuli, and Y. Kim. Fast binary and gray-scale mathematical morphology on VLIW media processors. In spie-35, pages 5 55, 1999.