home left right up

---

Closing


Common Names: Closing

Brief Description

Closing is an important operator from the field of mathematical morphology. Like its dual operator opening, it can be derived from the fundamental operations of erosion and dilation. Like those operators it is normally applied to binary images, although there are graylevel versions. Closing is similar in some ways to dilation in that it tends to enlarge the boundaries of foreground (bright) regions in an image (and shrink background color holes in such regions), but it is less destructive of the original boundary shape. As with other morphological operators, the exact operation is determined by a structuring element. The effect of the operator is to preserve background regions that have a similar shape to this structuring element, or that can completely contain the structuring element, while eliminating all other regions of background pixels.

How It Works

Closing is opening performed in reverse. It is defined simply as a dilation followed by an erosion using the same structuring element for both operations. See the sections on erosion and dilation for details of the individual steps. The closing operator therefore requires two inputs: an image to be closed and a structuring element.

Graylevel closing consists straightforwardly of a graylevel dilation followed by a graylevel erosion.

Closing is the dual of opening, i.e. closing the foreground pixels with a particular structuring element, is equivalent to closing the background with the same element.

Guidelines for Use

One of the uses of dilation is to fill in small background color holes in images, e.g. `pepper noise'. One of the problems with doing this, however, is that the dilation will also distort all regions of pixels indiscriminately. By performing an erosion on the image after the dilation, i.e. a closing, we reduce some of this effect. The effect of closing can be quite easily visualized. Imagine taking the structuring element and sliding it around outside each foreground region, without changing its orientation. For any background boundary point, if the structuring element can be made to touch that point, without any part of the element being inside a foreground region, then that point remains background. If this is not possible, then the pixel is set to foreground. After the closing has been carried out the background region will be such that the structuring element can be made to cover any point in the background without any part of it also covering a foreground point, and so further closings will have no effect. This property is known as idempotence. The effect of a closing on a binary image using a 3×3 square structuring element is illustrated in Figure 1.




Figure 1 Effect of closing using a 3×3 square structuring element

As with erosion and dilation, this particular 3×3 structuring element is the most commonly used, and in fact many implementations will have it hardwired into their code, in which case it is obviously not necessary to specify a separate structuring element. To achieve the effect of a closing with a larger structuring element, it is possible to perform multiple dilations followed by the same number of erosions.

Closing can sometimes be used to selectively fill in particular background regions of an image. Whether or not this can be done depends upon whether a suitable structuring element can be found that fits well inside regions that are to be preserved, but doesn't fit inside regions that are to be removed.

The image

art4

is an image containing large holes and small holes. If it is desired to remove the small holes while retaining the large holes, then we can simply perform a closing with a disk-shaped structuring element with a diameter larger than the smaller holes, but smaller than the large holes.

The image

art4clo1

is the result of a closing with a 22 pixel diameter disk. Note that the thin black ring has also been filled in as a result of the closing operation.

In real world applications, closing can, for example, be used to enhance binary images of objects obtained from thresholding. Consider that we want compute the skeleton of

phn1

To do this we first need to transform the graylevel image into a binary image. Simply thresholding the image at a value of 100 yields

phn1thr1

We can see that the threshold classified some parts of the receiver as background. The image

phn1clo1

is the result of closing the thresholded, image with a circular structuring element of size 20. The merit of this operator becomes obvious when we compare the skeletons of the two binary images. The image

phn1ske1

is the skeleton of the image which was only thresholded and

phn1ske2

is the skeleton of the image produced by the closing operator. We can see that the latter skeleton is less complex and it better represents the shape of the object.

Unlike erosion and dilation, the position of the origin of the structuring element does not really matter for opening and closing. The result is independent of it.

Graylevel closing can similarly be used to select and preserve particular intensity patterns while attenuating others.

The image

ape1

is our starting point.

The result of graylevel closing with a flat 5×5 square structuring element is shown in

ape1clo1

Notice how the dark specks in between the bright spots in the hair have been largely filled in to the same color as the bright spots, while the more uniformly colored nose area is largely the same intensity as before. Similarly the gaps between the white whiskers have been filled in.

Closing can also be used to remove `pepper noise' in images.

The image

fce5noi2

is an image containing pepper noise.

The result of a closing with a 3×3 square structuring element is shown in

fce5clo1

The noise has been completely removed with only a little degradation to the underlying image. If, on the other hand, the noise consists of bright spots (i.e. `salt noise'), as can be seen in

fce5noi1

closing yields

fce5clo2

Here, no noise has been removed. The noise has even been increased at locations where two nearby noise pixels have merged together into one larger spot. Compare these results with the ones achieved on the same image using opening.

Although closing can sometimes be used to preserve particular intensity patterns in an image while attenuating others, this is not always the case. Some aspects of this problem are discussed under opening.

Common Variants

Opening and closing are themselves often used in combination to achieve more subtle results. If we represent the closing of an image f by C(f), and its opening by O(f), then some common combinations include:

Proper Opening

Min(f, /em{C}(O(C(f))))

Proper Closing

Max(f, O(C(O(f))))

Automedian Filter

Max(O(C(O(f))), Min(f, C(O(C(f)))))

These operators are commonly known as morphological filters.

Interactive Experimentation

You can interactively experiment with this operator by clicking here.

Exercises

  1. Use closing to remove the lines from
    pcb2

    whereas the circles should remain. Do you manage to remove all the lines?

    Now use closing to remove the circles while keeping the lines. Is it possible to achieve this with only one structuring element?

  2. Can you use closing to remove certain features (e.g. the diagonal lines) from
    shu2

    Try it out.

  3. Combine closing and opening to remove the `salt'n'pepper' noise from
    fce5noi3

References

R. Gonzalez and R. Woods Digital Image Processing, Addison-Wesley Publishing Company, 1992, pp 524, 552.

R. Haralick and L. Shapiro Computer and Robot Vision, Vol. 1, Addison-Wesley Publishing Company, 1992, pp 174 - 185.

A. Jain Fundamentals of Digital Image Processing, Prentice-Hall, 1986, p 387.

D. Vernon Machine Vision, Prentice-Hall, 1991, pp 78 - 79.

Local Information

Specific information about this operator may be found here.

More general advice about the local HIPR installation is available in the Local Information introductory section.

---

home left right up

©2003 R. Fisher, S. Perkins, A. Walker and E. Wolfart.

Valid HTML 4.0!