2.5.4 Closing

Closing is somewhat like Dilation in that it tends to enlarge the boundaries of foreground (bright) pixels at the edge of regions of foreground pixels. However it is less destructive than dilation in general. The effect of the operator is to preserve background regions that have a similar shape to the structuring element, or that can completely contain the structuring element, while eliminating all other regions of background pixels, especially regions smaller than the structuring element. Closing is the dual of opening.

Operation - How It Works

An opening is defined as a dilation followed by an erosion using the same structuring element for both operations. Sometimes multiple dilations are used followed by the same number of erosions.

It is very common to use a 3x3 square structuring element. Although a 5x5 is equivalent to using 3x3 twice, the former has 5*5=25 pixels to consider while the latter is more computationally efficient at 2*3*3=18 pixels.

One of the uses of closing is to fill in small background color holes in images, pepper noise. After the closing has been carried out beyond a limit, the new boundaries of foreground regions will be such that the structuring element fits inside them, and so farther closing with the same element have no effect. This operation is usefull for correcting when it is hard to pick a single threshold for an image. Careful choice of the structuring element can limit the regions to which the operation will make changes.

In the example below, note how both the smaller dark (background) circles are eliminated as well as the larger but thin dark circular ring:

Before

After

Diff(Before,After)
Abs(Before-After)