Dilation Corrosion Opening Operation Closing Operation Gradient Top Hat Black Hat
1: Morphology operators - expansion D ilate
Similar to the convolution operation, assuming that there is an image A and a structural element B , the structural element B moves on top of A , where B defines its center as the anchor point, and calculates the maximum pixel value of A covered by B to replace the pixel of the anchor point, where B as a structure can be any shape
2: Morphology operators - Corrosion Erode
Corrosion is similar to dilation, the only difference is to replace the pixel value of the image under the anchor point overlap with the minimum value
Related APIs:
getStructuringElement(int shape, Size ksize, Point anchor)
- shape (MORPH_RECT \MORPH_CROSS \MORPH_ELLIPSE)
- size
- The anchor point is Point(-1, -1) by default , which means the center pixel
dilate(src, dst, kernel)
erode(src, dst, kernel)
3: Morphology operators - open operation Open
corrosion first expansion
Small objects can be removed, assuming the object is the foreground color and the background is black
4: Morphology operators - close operation Close
dilation followed by corrosion
Can fill small holes (fill hole) , assuming the object is the foreground color and the background is black
5: Morphology operators - gradient Gradient
expansion minus corrosion
Also known as basic gradient (others include - internal gradient, directional gradient)
6: Morphology operators - top hat TopHat
The top hat is the difference image between the original image and the opening operation
7: Morphology operators (morphology operators) - Black Hat BlackHat
The black hat is the difference image between the closed operation image and the source image
Related APIs
morphologyEx(src, dest, CV_MOP_BLACKHAT, kernel);
- Mat src – input image
- Mat dest – output result
- int OPT – CV_MOP_OPEN/ CV_MOP_CLOSE/ CV_MOP_GRADIENT / CV_MOP_TOPHAT/ CV_MOP_BLACKHAT morphological operation type
- Mat kernel structure element
- int Iteration The number of iterations, the default is 1