ImageDev

Erosion And Dilation

Morphological erosion and dilation algorithms.
For an introduction: section Mathematical Morphology.

Introduction to Erosion

In an erosion, pixel values within the structuring element are set to the minimum value of the element. In a binary image, an erosion removes isolated points and small particles, shrinks other particles, discards peaks at the object boundaries, and disconnects some particles.

Erosion operations are reiterative: repeating an erosion or dilation of size 1 N times has the same effect as performing a single erosion with a structuring element of size N.

In Figure 1 the binary image is $I$, and $X$ denotes the set of points with a value of 1. The erosion of $I$ by the structuring element $B$ results in the set of points $x$, where the disk representing $B$ and centered on $x$ is totally included in the set of points $X$. The erosion of $I$ can be denoted as $E_B(I)$ or $E(I)$.

<b> Figure 1.</b> Erosion applied to a binary image
Figure 1. Erosion applied to a binary image

The eroded set of $X$ by the structuring element $B$ is: $E(X)=\left\{ x ~; ~ B_x \subset X \right\}$
It may also be written as: $E(X)=X \ominus B$
The value of the structuring element $B$ varies depending on the type of erosion.
On a gray level image, the erosion by the structuring element $B$ is the search for the minimal value of intensities within $B$. When the point hits the edge of the image, the structuring element is composed of the intersection of $B$ with the points of the structuring element totally within the image, and not the points outside the image.

Introduction to Dilation

A dilation is the opposite of an erosion. In a dilation, pixel values within the structuring element are set to the maximum value of the pixel neighborhood. In a binary image, a dilation fills the small holes inside particles and gulfs at the object boundaries, enlarges the size of the particles, and may connect neighboring particles.

Dilation operations are reiterative: repeating a dilation of size 1 N times has the same effect as performing a single dilation with a structuring element of size N.

In Figure 2, the binary image is $I$, and $X$ denotes the set of points with a value of 1. The dilation of $I$ by the structuring element $B$ results in the set of points $x$, where the disk representing $B$ and centered on $x$ has a non-empty intersection with the set of points $X$. The dilation of $I$ can be denoted as $D_B(I)$ or $D(I)$.

<b> Figure 2.</b> Dilation applied to a binary image
Figure 2. Dilation applied to a binary image

The dilated set of X by the structuring element B is: $D(X)=\left\{ x ~; ~ B_x \cap X \neq \varnothing \right\}$
It may also be expressed as: $D(X)=X \oplus B$
The value of the structuring element $B$ varies depending on the type of dilation.
On a gray level image, the dilation by the structuring element B is the search for the maximum value of intensities within $B$: When the point hits the edge of the image, the structuring element is composed of the intersection of B with the points of the structuring element totally within the image, and not the points outside the image.