Everything you need to know about Morphology
Morphology applies classic image processing operations that expand or shrink bright/dark regions based on their neighborhood. Originally developed for binary images, these filters work on grayscale luminance to erode (shrink bright areas), dilate (expand bright areas), or find the midpoint between the two.
Operations
- Erode
Replaces each pixel with the minimum (darkest) value found in its neighborhood. This shrinks bright regions and expands dark regions – useful for removing small bright spots, thinning lines, or creating a darker, more recessed look. - Dilate
Replaces each pixel with the maximum (brightest) value found in its neighborhood. This expands bright regions and shrinks dark regions – useful for removing small dark spots, thickening lines, or creating a lighter, more prominent look. - Mid
Replaces each pixel with the average of the minimum and maximum values in its neighborhood. This creates a smoothing effect that reduces local contrast while preserving overall structure.
Parameters
- Radius
Sets the size of the neighborhood examined around each pixel (0–8 pixels). Larger radii create more dramatic effects – erosion eats further into bright areas, dilation expands them more. - Mix
Blends the morphological result with the original image. At 0, no change is visible. At 1.0, the full effect is applied.
How It Works
The filter examines a square neighborhood around each pixel (determined by radius), converts to luminance, and outputs the minimum (erode), maximum (dilate), or midpoint (mid) of all values found. The result is a grayscale image.
Tips
- Use Erode to clean up bright noise or thin white lines
- Use Dilate to fill small dark gaps or thicken dark features
- Mid creates an interesting smoothing effect different from blur
- Apply Erode then Dilate (or vice versa) for "opening" and "closing" operations