🟠 Image Erosion
Function Description
This operator performs morphological erosion operations on input grayscale or binary images. Erosion is a basic morphological operation opposite to dilation, whose core effect is to make bright regions (such as white pixels) in images "shrink" or "become thinner". It achieves the shrinkage effect of bright areas by sliding a structural "kernel" over the image and assigning the minimum pixel value within the kernel-covered area to the center pixel.
Usage Scenarios
-
Remove noise: Effectively removes isolated small bright spots or patches in images (commonly called "salt" noise).
-
Separate objects: When two or more objects are slightly adhered, erosion operation can break thin connections between them, thus separating them.
-
Thin contours: Can make object contours thinner, remove edge burrs, making shapes smoother.
-
Combined operations: Serves as a basic step for more complex morphological operations (such as "opening operation").
Input Output
Input |
Image: Single-channel grayscale or binary image to be processed. |
Output |
Eroded image: Image after erosion processing. |
Parameter Description
Erosion Kernel Size
Parameter Description |
Side length of the square structural kernel used for erosion operation. For example, a value of 3 means using a 3x3 kernel. |
Parameter Adjustment |
When adjusting, choose appropriate kernel size based on the noise point size to be removed or connection thickness to be broken. Generally, the kernel size should be slightly larger than the feature size to be processed. Generally use odd numbers like 1, 3, 5, etc. |
Parameter Range |
[1,50], default value: 3 |
Iteration Count
Parameter Description |
Sets the number of consecutive executions of erosion operation. |
Parameter Adjustment |
Increase iteration count: Equivalent to repeatedly applying the same size kernel to the image, making bright areas continuously shrink. For example, 2 iterations of 3x3 erosion will produce stronger effects than 1 iteration. When fine control of erosion degree is needed, you can maintain a smaller kernel size and gradually enhance effects by increasing iteration count. |
Parameter Range |
[1, 100], default value: 1 |