Understanding Morphological Image Processing and Its Operations

This article illustrates Morphological Image Processing in more straightforward terms; readers can understand how Morphology works in Digital Image Processing

Prateek Chhikara
Towards Data Science

--

Figure 1. Boundary Extraction using Morphological Image Processing operations. (Source: Image by the author)

The word ‘Morphology’ generally represents a branch of biology that deals with the form and structure of animals and plants. However, we use the same term in ‘mathematical morphology’ to extract image components useful in representing region shape, boundaries, etc.

Morphology is a comprehensive set of image processing operations that process images based on shapes [1]. Morphological operations apply a structuring element to an input image, creating an output image of the same size. In a morphological operation, the value of each pixel in the output image is based on a comparison of the corresponding pixel in the input image with its neighbors.

There is a slight overlap between Morphology and Image Segmentation. Morphology consists of methods that can be used to pre-process the input data of Image Segmentation or to post-process the output of the Image Segmentation stage. In other words, once the segmentation is complete, morphological operations can be used to remove imperfections in the segmented image and deliver information on the shape and structure of the image as shown in Figure 2.

Figure 2. Example of Morphological Processing [2].

This article focuses majorly on binary images, just for simplicity and understanding.

Terminologies in Morphological Image Processing

All morphological processing operations are based on mentioned terms.

Structuring Element: It is a matrix or a small-sized template that is used to traverse an image. The structuring element is positioned at all possible locations in the image, and it is compared with the connected pixels. It can be of any shape.
Fit: When all the pixels in the structuring element cover the pixels of the object, we call it Fit.
Hit: When at least one of the pixels in the structuring element cover the pixels of the object, we call it Hit.
Miss: When no pixel in the structuring element cover the pixels of the object, we call it miss.

Figure 3 shows the visualization of terminologies used in morphological image processing.

Figure 3. Morphology terminologies explained. (Source: Image by the author)

Morphological Operations

Fundamentally morphological image processing is similar to spatial filtering. The structuring element is moved across every pixel in the original image to give a pixel in a new processed image. The value of this new pixel depends on the morphological operation performed. The two most widely used operations are Erosion and Dilation.

1. Erosion

Erosion shrinks the image pixels, or erosion removes pixels on object boundaries. First, we traverse the structuring element over the image object to perform an erosion operation, as shown in Figure 4. The output pixel values are calculated using the following equation.
Pixel (output) = 1 {if FIT}
Pixel (output) = 0 {otherwise}

Figure 4. Erosion operation on an input image using a structuring element. (Source: Image by the author)

An example of Erosion is shown in Figure 5. Figure 5(a) represents original image, 5(b) and 5(c) shows processed images after erosion using 3x3 and 5x5 structuring elements respectively.

Figure 5. Results of structuring element size in erosion. (Source: Image by the author)

Properties:

  1. It can split apart joint objects (Figure 6).
  2. It can strip away extrusions (Figure 6).
Figure 6. Example use-cases of Erosion. (Source: Image by the author)

2. Dilation

Dilation expands the image pixels, or it adds pixels on object boundaries. First, we traverse the structuring element over the image object to perform an dilation operation, as shown in Figure 7. The output pixel values are calculated using the following equation.
Pixel (output) = 1 {if HIT}
Pixel (output) = 0 {otherwise}

Figure 7. Dilation operation on an input image using a structuring element. (Source: Image by the author)

An example of Dilation is shown in Figure 8. Figure 8(a) represents original image, 8(b) and 8(c) shows processed images after dilation using 3x3 and 5x5 structuring elements respectively.

Figure 8. Results of structuring element size in dilation. (Source: Image by the author)

Properties:

  1. It can repair breaks (Figure 9).
  2. It can repair intrusions (Figure 9).
Figure 9. Example use-cases of DIlation. (Source: Image by the author)

Compound Operations

Most morphological operations are not performed using either dilation or erosion; instead, they are performed by using both. Two most widely used compound operations are: (a) Closing (by first performing dilation and then erosion), and (b) Opening (by first performing erosion and then dilation). Figure 10 shows both compound operations on a single object.

Figure 10. Output of Compound operations on an input object. (Source: Image by the author)

Application: Edge Extraction of an Object

Extracting the boundary is an important process to gain information and understand the feature of an image. It is the first process in preprocessing to present the image’s characteristics. This process can help the researcher to acquire data from the image. We can perform boundary extraction of an object by following the below steps.

Step 1. Create an image (E) by erosion process; this will shrink the image slightly. The kernel size of the structuring element can be varied accordingly.

Step 2. Subtract image E from the original image. By performing this step, we get the boundary of our object.

For illustration, please refer to Cover Art or Figure 1.

Conclusion

This article explains the morphology topic in digital image processing. Further, we discuss with examples the two most famous approaches in morphology: dilation and erosion. We then see how these two approaches can be combined to solve other use-cases. Finally, we explain one application of morphological image processing.

References

[1] P Soille. “Morphological Image Analysis, Principles and Applications”, 1999.

[2] R. C. Gonzalez, R. E. Woods, “Digital image processing”, 2nd ed. Upper Saddle River, N.J. Prentice Hall, 2002.

--

--