Morphological Operations
Description
This operator performs a series of shape-based image processing operations on the input image. Morphological operations modify pixel values by sliding a small window called a "structuring element" or "kernel" over the image, thereby achieving the purpose of modifying image geometric features (such as contours, holes, connections, etc.). It is mainly used for preprocessing and feature extraction of binary and grayscale images.
Overview
Performs preprocessing and feature extraction on binary and grayscale images through various morphological operations.
Scenarios
Denoising:
-
Use the OPEN operation to remove small, isolated bright spots ("salt" in salt-and-pepper noise).
-
Use the CLOSE operation to fill small black holes inside objects ("pepper" in salt-and-pepper noise).
Object Connection and Separation:
-
Use DILATE to connect broken contours or merge adjacent objects.
-
Use ERODE to separate slightly adhering objects or thin object contours.
Edge and Contour Extraction:
-
Use the GRADIENT operation to effectively extract object edge contours.
Specific Feature Extraction:
-
Use the TOPHAT operation to extract tiny details or spots brighter than the surrounding area.
-
Use the BLACKHAT operation to extract tiny details or scratches darker than the surrounding area.
-
Use HITMISS for specific pattern matching, used to refine or find specific pixel arrangement patterns (advanced application).
Inputs and Outputs
Inputs |
Image: The image to be processed. Usually a binarized image, but most operations also support grayscale or even color images. |
Outputs |
Morphology Image: The image obtained after performing morphological operations. |
Parameters
Operation Type
Description |
Selects the specific morphological algorithm to perform. |
Tuning Instructions |
Erosion: The effect is to make bright areas (white) "thinner" and dark areas (black) "fatter" in the image. It can break small connections and remove burrs on object boundaries. Dilation: Opposite to erosion, it makes bright areas "fatter" and dark areas "thinner". It can fill holes inside objects and connect broken contours. Opening: Erosion followed by dilation. Its main role is to eliminate small bright spots and thin bright lines while keeping the overall contour size unchanged. Very suitable for removing discrete noise points. Closing: Dilation followed by erosion. Its main role is to fill small holes inside objects and close small cracks on object contours while keeping the overall contour size unchanged. Gradient: Calculates the difference between image dilation and erosion. The result looks like the contour lines of the object. Top Hat: Calculates the difference between the original image and the "Opening" result. It can separate lines or noise points brighter than neighbors, suitable for extracting bright details on a bright background. Black Hat: Calculates the difference between the "Closing" result and the original image. It can extract tiny dark objects or scratches on a bright background. Hit-or-Miss Transform: A special pattern matching operation requiring a single-channel grayscale image (usually binary), used to find specific pixel neighborhood patterns. |
Parameter Range |
Values/Range:
Default: Opening |
Kernel Size
Description |
Defines the size of the structuring element (kernel) used in the morphological operation, in the format [width, height]. |
Tuning Instructions |
When adjusting, the size of the kernel should be slightly larger than the size of the image features you want to remove (or connect). |
Parameter Range |
|
Parameter Range |
Default: [3, 3] |
Kernel Shape
Description |
Defines the shape of the structuring element. |
Tuning Instructions |
The shape of the kernel affects the directionality of morphological operations.
|
Parameter Range |
Values/Range:
Default: Rectangle |
Iterations
Description |
Sets the number of times the erosion or dilation operation is applied consecutively. |
Tuning Instructions |
Increasing the number of iterations is equivalent to applying the same operation multiple times. Its effect is similar to using a larger kernel but not exactly the same.
|
Parameter Range |
[1,100], Default value: 1 |
Parameter Range |
Values/Range: [1, 100] Default: 1 |