Binary images may contain numerous imperfections. In particular, the binary regions produced by simple thresholding are distorted by noise and texture. Morphological image processing pursues the goals of removing these imperfections by accounting for the form and structure of the image. These techniques can be extended to greyscale images.
Morphological image processing is a collection of non-linear operations related to the shape or morphology of features in an image. According to Wikipedia, morphological operations rely only on the relative ordering of pixel values, not on their numerical values, and therefore are especially suited to the processing of binary images. Morphological operations can also be applied to greyscale images such that their light transfer functions are unknown and therefore their absolute pixel values are of no or minor interest.
Morphological techniques probe an image with a small shape or template
called a structuring element. The structuring element is positioned at all
possible locations in the image and it is compared with the corresponding
neighbourhood of pixels. Some operations test whether the element "fits"
within the neighbourhood, while others test whether it "hits" or
intersects the neighbourhood:
The structuring element is a small binary image, i.e. a small matrix of pixels, each with a value of zero or one:
When a structuring element is placed in a binary image, each of its pixels is
associated with the corresponding pixel of the neighbourhood under the
structuring element. The structuring element is said to fit the image
if, for each of its pixels set to 1, the corresponding image pixel is also 1.
Similarly, a structuring element is said to hit,
or intersect, an image if, at least for one of its pixels set to 1 the corresponding
image pixel is also 1.
The erosion of a binary image f by a structuring element s (denoted
f s) produces a new binary
image g = f s
with ones in all locations (x,y) of a structuring element's origin
at which that structuring element
s fits the input image f, i.e. g(x,y) = 1 is s fits f and
0 otherwise, repeating for all pixel coordinates (x,y).
Greyscale image | Binary image by thresholding | Erosion: a 2×2 square structuring element |
http://documents.wolfram.com/applications/digitalimage/UsersGuide/Morphology/ImageProcessing6.3.html |
The dilation of an image f by a structuring element s (denoted f s) produces a new binary image g = f s with ones in all locations (x,y) of a structuring element's orogin at which that structuring element s hits the the input image f, i.e. g(x,y) = 1 if s hits f and 0 otherwise, repeating for all pixel coordinates (x,y). Dilation has the opposite effect to erosion -- it adds a layer of pixels to both the inner and outer boundaries of regions.
Binary image | Dilation: a 2×2 square structuring element | |
http://documents.wolfram.com/applications/digitalimage/UsersGuide/Morphology/ImageProcessing6.3.html |
Many morphological operations are represented as combinations of erosion, dilation, and
simple set-theoretic operations such as the complement of a binary image:
Binary image | Opening: a 2×2 square structuring element | |
http://documents.wolfram.com/applications/digitalimage/UsersGuide/Morphology/ImageProcessing6.3.html |
Binary image f | f s (5×5 square) | f s
(9×9 square)
Results of opening with a square structuring
element (www.mmorph.com/html/morph/mmopen.html/).
| |
Opening is an idempotent operation: once an image has been opened,
subsequent openings with the same structuring element have no further effect
on that image:
The closing of an image f by a structuring element s (denoted by
f • s) is a dilation followed by an erosion:
Binary image | Closing: a 2×2 square structuring element | |
http://documents.wolfram.com/applications/digitalimage/UsersGuide/Morphology/ImageProcessing6.3.html |
Closing is so called because it can fill holes in the regions while
keeping the initial region sizes. Like opening, closing is idempotent:
(f • s) • s = f • s, and it is dual operation of
opening (just as opening is the dual operation of closing):
The hit and miss transform (see also
HIPS2 web page)
allows to derive information on how objects in
a binary image are related to their surroundings. The operation requires a matched pair of
structuring elements, {s1, s2}, that probe the
inside and outside, respectively, of objects in the image:
Binary image | Hit and miss transform: an elongated 2×5 structuring element | |
http://documents.wolfram.com/applications/digitalimage/UsersGuide/Morphology/ImageProcessing6.3.html |
It is easier to describe it by considering s1 and s2 as a single structuring element with 1s for pixels of s1 and 0s for pixels of s2; in this case the hit-and-miss transform assigns 1 to an output pixel only if the object (with the value of 1) and background (with the value of 0) pixels in the structuring element exactly match object (1) and background (0) pixels in the input image. Oterwise that pixel is set to the background value (0).
The hit and miss transform can be used for detecting specific shapes (spatial arrangements of object and background pixel values) if the two structuring elements present the desired shape, as well as for thinning or thickening of object linear elements.
Morphological filtering
of a binary image is conducted by considering compound operations like opening and closing as filters. They may act as filters of shape. For example, opening with a disc structuring element smooths corners from the inside, and closing with a disc smooths corners from the outside. But also these operations can filter out from an image any details that are smaller in size than the structuring element, e.g. opening is filtering the binary image at a scale defined by the size of the structuring element. Only those portions of the image that fit the structuring element are passed by the filter; smaller structures are blocked and excluded from the output image. The size of the structuring element is most important to eliminate noisy details but not to damage objects of interest.
These lecture notes follow Chapter 11 "Morphological image processing" of the textbook