Skip to content
ExtendedSource checked

Morphological Erosion

Shrinks bright or foreground regions using a local structuring element.

Quick Facts

Compact metadata for implementation and discovery.

Category
Image Processing
Difficulty
Beginner
Family
Morphology
Tier
Extended
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
2
Code example
Ready
Visualization
Ready
Aliases
Erosion

Overview

Morphological Erosion keeps a foreground pixel only when the structuring element fits inside the foreground around it.

Core Concepts

pixel operationstructuring elementregion separationmorphologypixel neighborhoodlocal operationimage transform

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(w h k)

Average

O(w h k)

Worst

O(w h k)

Space

O(w h)

When to Use

  • Use Morphological Erosion when you need to check a local structuring element.
  • Use it for noise removal with inputs like binary or grayscale image.
  • Use it when pixel-level transformation or region analysis is the main task.
  • Use it when the Morphology tradeoff is acceptable for the problem size.

When Not to Use

  • Avoid it when lighting, noise, or color space changes make a fixed rule unreliable.
  • Avoid it when the required output is not eroded image.

What It Does

  • Checks a local structuring element
  • Removes foreground pixels near boundaries

Use Cases

  • Noise removal
  • Separating touching regions
  • Shape analysis

Inputs

  • Binary or grayscale image
  • Structuring element

Outputs

  • Eroded image

Key Formulas (1)

Erosion rule

output[p] = min(image[p + offset] for offset in structuringelement)
output[p] = min(image[p + offset] for offset in structuring_element)

Shrinks bright or foreground regions by taking the local minimum under the structuring element.

Pseudocode

  1. 1.Place the structuring element over each pixel
  2. 2.Check whether all required foreground positions match
  3. 3.Keep the pixel only if the element fits
  4. 4.Otherwise set it to background
  5. 5.Move to the next pixel

Canonical Example

Input
image = 3x3 grayscale pixels
Output
processed 3x3 image or mask
Explanation
Morphological Erosion: The algorithm transforms local pixel values into a clearer feature, mask, or image.

Implementation Notes

  • Keep the input contract explicit: Binary or grayscale image; Structuring element.
  • Use this step as the implementation spine: Place the structuring element over each pixel.
  • Then preserve the next state change: Check whether all required foreground positions match.
  • Test on tiny images where each expected output pixel can be inspected by hand.

Common Pitfalls

  • Erosion is often paired with dilation for opening and closing operations.
  • Choosing the wrong structuring element can erase the feature you wanted to keep.
  • Processing color, alpha, and boundary pixels inconsistently.
  • Returning eroded image without handling empty, invalid, or boundary inputs.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show foreground shapes shrinking at their edges.

Morphological Erosion mechanism walkthrough step 1 of 5
Step 1 of 5: Place the structuring element over each pixel
shape-erosion

Notes

Morphological Erosion operates in O(w h k) time and O(w h) space within the Morphology family. Key governing relation: output[p] = min(image[p + offset] for offset in structuring_element). Often compared with Thresholding and Histogram Equalization.

Sources (1)

What each reference supports for this entry.

Digital Image Processing

Book

Image-processing textbook support for Morphological Erosion filtering, morphology, segmentation, restoration, or connected-component behavior.

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Erosion shrinks foreground regions, while dilation expands them with the structuring element.

Tags

Image ProcessingMorphologySegmentation