Image Processing Class #6 — Morphological Filter
This article is for sum up the lesson that I have learned in medical image processing class (EGBE443).
This article is about basic image processing. If you are new in this field, you can read my first post by clicking on the link below. :)
In the previous chapter, I’ve talked about a method to remove noise using median filter. Median filter makes image structure change a lot. A figure below shows the result of applying median filter to a binary image. The small structures, single line, and dot, are removed and small size holes are filled.
So in this chapter, I will introduce an idea which overcomes this problem. It is called “Morphological Filter”.
Morphological Filter
The idea of the morphological filter are shrink and let grow process. The word “shrink” means using median filter to round off the large structures and to remove the small structures and in grow process, remaining structures are grow back by the same amount.
The morphological operation of the binary image is described first and will talk in the following outline.
Outlines
- The structuring element of a binary filter
- Dilation and Erosion
- Composite Operation
The structuring element
In morphological filter, each element in the matrix is called “structuring element” instead of coefficient matrix in the linear filter. The structuring elements contain only value 0 and 1. And the hot spot of the filter is the dark shade element.
The binary image is described as sets of two-dimensional coordinate point. This is called “Point Set” Q and point set consist of the coordinate pair p = (u,v) of all foreground pixels. Some operations of point set are similar to the operation in others image. For inverting binary image is complement operation and combining two binary image use union operator. Shifting binary image I by some coordinate vector d by adding vector d to point p. Or reflection of binary image I by multiply -1 to point p.
Dilation and Erosion
- Dilation is a morphological operator which works for the grow process as I mentioned before. The equation of this operator is defined as
- Erosion is a morphological operator which works for the shrink process as I mentioned before as well and the equation is defined as
Properties of dilation and erosion
- Commutative: only in dilation
- Associative: only in dilation
Note that: in erosion is in contrast to dilation, not have commutative property.
Get Pitchaya Thipkham’s stories in your inbox
Join Medium for free to get updates from this writer.
In addition, erosion and dilation are duels, for a dilation of the foreground can be accomplished by an erosion of background and subsequent of the result in two different properties but work similarity
Composite Operation
In morphological process, dilation and erosion work together in composite operation. There are common way to represent the order of these two operations, opening and closing. Opening denotes an erosion followed by dilation and closing work in opposite way.
The opening and closing also are dual in sense that opening the foreground is equal to closing the background.
Morphological Filter can also apply to gray-scale image, but in the different definition. It is a generalization with MIN and MAX operators. I will describe in following outline.
Outlines
- Structuring Elements
- Dilation and Erosion
- Opening and Closing
Structuring Element
In gray-scale morphology, structuring elements are defined as real-value 2D functions instead of point sets
The value in H can be negative or zero value. But it contrast to linear convolution, zero elements are used to compute the result. And if you do not want to use the elements in some location, you can put no element in that location.
Dilation and Erosion
The result of dilation and erosion in gray-scale morphology is contributed from maximum and minimum operation.
For dilation, the result is the maximum value of the value in H add to the current sub-image.
For erosion, the result is the minimum value of the difference.
These operations can cause the negative value, so we need to clamping the result after calculation.
Opening and Closing
Opening and closing in gray-scale morphology work in the same way as in binary morphology. The difference is just the operator in dilation and erosion.
For implementation in Python 3 using OpenCV module, you can use the function cv2.erode(input,size) and cv2.dilate(input,size)
This is the result of the program, erosion and dilation, opening and closing.
This is my last article on image processing. Thanks for reading and following my post. Keep enjoying image processing! I’ll be back soon, Good luck. :)










