# Erosion (morphology)

The erosion of the dark-blue square by a disk, resulting in the light-blue square.

Erosion (usually represented by ) is one of two fundamental operations (the other being dilation) in morphological image processing from which all other morphological operations are based. It was originally defined for binary images, later being extended to grayscale images, and subsequently to complete lattices. The erosion operation usually uses a structuring element for probing and reducing the shapes contained in the input image.

## Binary erosion

In binary morphology, an image is viewed as a subset of a Euclidean space ${\displaystyle \mathbb {R} ^{d}}$ or the integer grid ${\displaystyle \mathbb {Z} ^{d}}$, for some dimension d.

The basic idea in binary morphology is to probe an image with a simple, pre-defined shape, drawing conclusions on how this shape fits or misses the shapes in the image. This simple "probe" is called structuring element, and is itself a binary image (i.e., a subset of the space or grid).

Let E be a Euclidean space or an integer grid, and A a binary image in E. The erosion of the binary image A by the structuring element B is defined by:

${\displaystyle A\ominus B=\{z\in E|B_{z}\subseteq A\}}$,

where Bz is the translation of B by the vector z, i.e., ${\displaystyle B_{z}=\{b+z|b\in B\}}$, ${\displaystyle \forall z\in E}$.

When the structuring element B has a center (e.g., a disk or a square), and this center is located on the origin of E, then the erosion of A by B can be understood as the locus of points reached by the center of B when B moves inside A. For example, the erosion of a square of side 10, centered at the origin, by a disc of radius 2, also centered at the origin, is a square of side 6 centered at the origin.

The erosion of A by B is also given by the expression: ${\displaystyle A\ominus B=\bigcap _{b\in B}A_{-b}}$, where A−b denotes the translation of A by -b.

### Example

Suppose A is a 13 x 13 matrix and B is a 3 x 3 matrix:

    1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 0 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1               1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1               1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1               1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1


Assuming that the origin B is at its center, for each pixel in A superimpose the origin of B, if B is completely contained by A the pixel is retained, else deleted.

Therefore the Erosion of A by B is given by this 13 x 13 matrix.

    0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 0 0 0 1 1 1 1 0
0 1 1 1 1 0 0 0 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0


This means that only when B is completely contained inside A that the pixels values are retained, otherwise it gets deleted or eroded.

### Properties

• The erosion is translation invariant.
• It is increasing, that is, if ${\displaystyle A\subseteq C}$, then ${\displaystyle A\ominus B\subseteq C\ominus B}$.
• If the origin of E belongs to the structuring element B, then the erosion is anti-extensive, i.e., ${\displaystyle A\ominus B\subseteq A}$.
• The erosion satisfies ${\displaystyle (A\ominus B)\oplus C=A\ominus (B\oplus C)}$, where ${\displaystyle \oplus }$ denotes the morphological dilation.
• The erosion is distributive over set intersection

## Grayscale erosion

Example of erosion on a grayscale image using a 5x5 flat structuring element. The top figure demonstrates the application of the structuring element window to the individual pixels of the original image. The bottom figure shows the resulting eroded image.

In grayscale morphology, images are functions mapping a Euclidean space or grid E into ${\displaystyle \mathbb {R} \cup \{\infty ,-\infty \}}$, where ${\displaystyle \mathbb {R} }$ is the set of reals, ${\displaystyle \infty }$ is an element larger than any real number, and ${\displaystyle -\infty }$ is an element smaller than any real number.

Denoting an image by f(x) and the grayscale structuring element by b(x), where B is the space that b(x) is defined, the grayscale erosion of f by b is given by

${\displaystyle (f\ominus b)(x)=\inf _{y\in B}[f(x+y)-b(y)]}$,

where "inf" denotes the infimum.

In other words the erosion of a point is the minimum of the points in its neighborhood, with that neighborhood defined by the structuring element. In this way it is similar to many other kinds of image filters like the median filter and the gaussian filter.

## Erosions on complete lattices

Complete lattices are partially ordered sets, where every subset has an infimum and a supremum. In particular, it contains a least element and a greatest element (also denoted "universe").

Let ${\displaystyle (L,\leq )}$ be a complete lattice, with infimum and supremum symbolized by ${\displaystyle \wedge }$ and ${\displaystyle \vee }$, respectively. Its universe and least element are symbolized by U and ${\displaystyle \emptyset }$, respectively. Moreover, let ${\displaystyle \{X_{i}\}}$ be a collection of elements from L.

An erosion in ${\displaystyle (L,\leq )}$ is any operator ${\displaystyle \varepsilon :L\rightarrow L}$ that distributes over the infimum, and preserves the universe. I.e.:

• ${\displaystyle \bigwedge _{i}\varepsilon (X_{i})=\varepsilon \left(\bigwedge _{i}X_{i}\right)}$,
• ${\displaystyle \varepsilon (U)=U}$.