Morphological Operations: An Overview

Mathematical morphology is a tool for extracting image components useful in the represation and description of region shape, such as boundaries, skeletons and convex hulls. The language of mathematical morphology is set theory, and as such it can apply directly to binary (two-level) images: a point is either in the set (a pixel is set, or put to foreground) or it isn't (a pixel is reset, or put to background), and the usual set operators (intersection, union, inclusion, complement) can be applied to them.

Basic operations in mathematical morphology operate on two sets: the first one is the image, and the second one is the structuring element (sometimes also called the kernel, although this terminology is generaly reserved for convolutions). The structuring element used in practice is generally much smaller than the image, often a 3x3 matrix.

It is possible, however, to make a generalization to greylevel images.


Morphological Operations on Binarized Images

Erosion and Dilation

Erosion and dilation are two basic operators in mathematical morphology. The basic effect of erosion operator on a binary image is to erode away the boundaries of foreground pixels (usually the white pixels). Thus areas of foreground pixels shrink in size, and "holes" within those areas become larger.

Mathematically, erosion of set A by set B is a set of all points x such that B translated by x is still contained in A.

Let foreground pixels be represented by logical 1's, and background pixels by logical 0's. As a practical example, we take a 3x3 matrix of logical 1's, with the middle point chosen as the origin of the set is used as the structuring element B (see the picture).

To compute the erosion of a binary input image by this structuring element, we consider each of the foreground pixels in the input image in turn. For each input pixel we superimpose the structuring element on top of the input image so that the origin of the structuring element coincides with the input pixel coordinates.

  1. If the input pixel is set to foreground and all its 8 neighbours are also set to foreground, then the pixel remains set to foreground.
  2. If the input pixel is set to foreground, but at least one of its 8 neighbours is not, the pixel is set to background.
  3. Input pixels set to background remain such.

With the structuring element chosen as above, the effect of this operation is to remove any foreground pixel that is not completely surrounded by other foreground pixels, assuming 8-connectedness. We can also see that this operation can be performed on binary images simply by applying a logical AND function.

[Illustration of image erosion]

Here is an example of image erosion:

[Original binary picture] [Eroded binary picture]

On the left side there is the original image, on the right side is the eroded image.

The dilation is the other of the two basic operators in mathematical morphology, the first one being erosion. The basic effect of dilation on binary images is to enlarge the areas of foreground pixels (i.e. white pixels) at their borders. The areas of foreground pixels thus grow in size, while the background "holes" within them shrink.

Mathematically, erosion of A by B is the set of all x displacement such that B and A overlap by at least one non-zero element.

Again let us take a 3x3 matrix for the structuring element, with the center pixel used as the origin of the set. B, then the dilation can be performed using the logical OR function:

  1. If the pixel is set to foreground, it remains such.
  2. If the pixel is set to background, but at least one of its eight neighbours is set to foreground, the pixel is converted to foreground.
  3. If the pixel is set to background and none of its eight neighbours is set to foreground, the pixel remains set to background.
[Illustration of image dilation]

An illustration of binary image dilation:

[Original binary picture] [Dilated binary picture]

On the left side there is the original image, on the right side is the dilated image.

Opening and Closing

The opening is a composite operator, constructed from the two basic operators described above. Opening of set A by set B is achieved by first the eroding set A by B, then dilating the resulting set by B.

[Illustration of image opening]

Here is an example of binary image closing:

[Original binary picture] [Opened binary picture]

On the left side there is the original image, on the right side is the opened image.

The closing, like opening, is also a composite operator. The closing of set A by set B is achieved by first dilating of set A by B, then eroding the resulting set by B.

[Illustration of image closing]

Here is an example of binary image closing:

[Original binary picture] [Closed binary picture]

On the left side there is the original image, on the right side is the closed image.

Boundary Extraction

The boundary of set A can be found by first eroding A by B, then taking the set difference between the original A and the eroded A.

[Illustration of image outlining]

Here is an example of binary image outlining:

[Original binary picture] [Outlined binary picture]

On the left side there is the original image, on the right side is the outlined image.


Generalization to Greyscale Images

The ideas above can be extended to greyscale images as well. In greyscale images, each pixel can have the value in a certain range, i.e. 0 to 255, with 0 representing black and 255 representing white.

Greyscale Erosion and Dilation

Greyscale erosion is analogous to its binary counterpart. Greyscale erosion darkens small bright areas, and very small bright areas like noise spikes or small spurs might be totally removed.

Working with a 3x3 structuring element as above, greyscale erosion is implemented as follows:

[Original greyscale image] [Eroded greyscale picture]

On the left side there is the original image, on the right side is the eroded image.

Greyscale dilation is analogous to its binary counterpart. Greyscale dilation brightens small dark areas, and very small dark "holes" might be totally removed.

Working with a 3x3 structuring element as above, greyscale dilation is implemented as follows:

[Original greyscale image] [Dilated greyscale picture]

On the left side there is the original image, on the right side is the dilated image.

Greyscale Opening and Closing

Greyscale opening is, like its binary counterpart, achieved by first eroding the image with the structuring element, and then dilating the resulting image by the structuring element. The process darkens small bright areas, and may entirely remove very small bright spots like noise spikes.

[Original greyscale image] [Opened greyscale picture]

On the left side there is the original image, on the right side is the opened image.

Greyscale closing is, like its binary counterpart, achieved by first dilating the image with the structuring element, and then eroding the resulting image by the structuring element. The process brightenes small dark areas, and may entirely remove very small dark "holes".

[Original greyscale image] [Closed greyscale image]

On the left side there is the original image, on the right side is the closed image.

Top-Hat and Well Transformations

The Top-Hat Transform or peak detector is another composite operation: the image opened by the structuring element is subtracted from the original image. The brightest spots on the original image are highlighted using this transformation.

[Original greyscale image] [Greyscale image after tophat
transform]

On the left side there is the original image, on the right side is the image after top-hat transform.

The Well Transform or valley detector is another composite operation: the image closed by the structuring element is subtracted from the original image. The darkest areas on the original image are highlighted using this transformation.

[Original greyscale image] [Greyscale image after tophat
transform]

On the left side there is the original image, on the right side is the image after well transform.

Morphological gradient

The morphological gradient of an image is computed by subtracting the image eroded by the structuring element from the image dilated by the structuring element. The areas with the steepest bright-to-dark or dark-to-bright transitions are highlighted using this operation.

[Original greyscale image] [Morphological gradient of 
greyscale image]

On the left side there is the original image, on the right side is its morphological gradient.

References

  1. R.C. Gonzalez, R.E. Woods, Digital Image Processing, Addison-Wesley, Reading (Mass) 1992. ISBN 0-201-50803-6
  2. G.A. Baxes, Digital Image Processing, Principles and Application, John Wiley & Sons, 1994. ISBN 0-471-00949-0
  3. R. Fisher, S. Perkins, A. Walker, E. Wolfart, Hypermedia Image Processing Reference, John Wiley & Sons, 1996.

Created 17 Jul 1996 (P. Peterlin)
Last revision 19 Jul 1996 (P. Peterlin)