Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Mathematical morphology gathers several techniques based on set theory, lattice theory, and topology. It was initially dedicated to binary images but has now been extended to grayscale images. In this course, we limit the presentation to binary images, therefore we consider that the objects in the image define a set of pixels.

Set operations

Consider the two following sets AA and BB:

Set AA:

Set BB:

Then we have the following operations.

Complement
Union
Intersection
Difference

The complement of AA is denoted AcA^\mathrm{c} and is the set of pixels that are not in AA:

Ac={p∉A}A^\mathrm{c} = \{p \notin A \}

Structuring element

In addition to this, the operators of mathematical morphology need a so-called structuring element (french: élément structurant). A structuring element EE is a set of pixels (equivalent to a binary image) associated with an origin. Generally, the origin is located at the centre of the structuring element; but it may be elsewhere, even outside the pixels of the structuring element. In the sequel, we denote by EcE_c the structuring element centered on the pixel cc.

Basic operations

Dilation

Having an image II and a structuring element EcE_c, the dilation (french: dilatation) of II by EcE_c is noted I⊕EcI \oplus E_c. The result of the dilation is obtained by moving the origin of the structuring element onto the white pixels of the image and keeping the set of pixels of each displaced structuring element.

Mathematically speaking:

I⊕Ec={Ec∣c∈I}I \oplus E_c = \{ E_c \mid c \in I \}
Example of dilation on a small image I by the structuring element E_c
(with the origin c is at the centre and represented by the blue dot).

Figure 7:Example of dilation on a small image II by the structuring element EcE_c (with the origin cc is at the centre and represented by the blue dot).

The structuring element is often described with a matrix. So, the structuring element in Figure 7 is written as:

E=(010111010).E = \begin{pmatrix} 0 & 1 & 0 \\ 1 & 1 & 1 \\ 0 & 1 & 0 \\ \end{pmatrix}.

Note that the matrix does not consider the zero pixels surrounding the main part of EE.

Dilation has the following properties:

  • Dilation is a binary operation and is not linear. Therefore, it cannot be expressed as convolution which is a linear mathematical operator.

  • Dilation is associative, i.e. the application of two consecutive dilations can be done in any order:

    (I⊕E1)⊕E2=(I⊕E2)⊕E1=I⊕(E1⊕E2)(I \oplus E_1 ) \oplus E_2 = (I \oplus E_2) \oplus E_1 = I \oplus (E_1 \oplus E_2)

    (here, the subscripts 1 and 2 mean two different structuring elements.)

  • Dilation is a monotonous operation since the relations of inclusions are conserved:

    I1⊆I2⇒I1⊕Ec⊆I2⊕EcI_1 \subseteq I_2 \quad\Rightarrow\quad I_1 \oplus E_c \subseteq I_2 \oplus E_c

Erosion

The erosion (french: érosion) of II by EcE_c is noted I⊖EcI \ominus E_c. The result of the erosion is obtained by moving the structuring element into the white pixels of the image and keeping only the origin of each displaced structuring element.

I⊖Ec={c∣Ec⊆I}I \ominus E_c = \{ c \mid E_c \subseteq I\}

name: F:mm:erosion-toy

Example of erosion on a small image II by the structuring element EcE_c (with the origin cc is at the centre and represented by the blue dot).

Erosion has similar properties as dilation:

  • Erosion cannot be expressed as convolution.

  • Erosion is associative:

    (I⊖E1)⊖E2=(I⊖E2)⊖E1=I⊖(E1⊕E2)(I \ominus E_1 ) \ominus E_2 = (I \ominus E_2) \ominus E_1 = I \ominus (E_1 \oplus E_2)

    Note that the result of two successive erosions is equivalent to an erosion whose structuring element is the dilation of the two first structuring elements.

  • Erosion is a monotonous operation:

    I1⊆I2⇒I1⊖E⊆I2⊖EI_1 \subseteq I_2 \quad\Rightarrow\quad I_1 \ominus E \subseteq I_2 \ominus E

Duality

Dilation and erosion are dual operators. Considering the background as the object and the object as the background (i.e. by working with the complement of the image), the dilation is converted to erosion and vice versa:

Ic⊖E=(I⊕E)cIc⊕E=(I⊖E)cI^\mathrm{c} \ominus E = (I \oplus E)^\mathrm{c} \\ I^\mathrm{c} \oplus E = (I \ominus E)^\mathrm{c}

Composition of basic operators

Opening

Opening (french: ouverture) consists of an erosion followed by a dilation. The erosion removes small objects but also decreases the size of bigger objects. To avoid this, the result is dilated with the same structuring element.

I∘E=(I⊖Ec)⊕EcI \circ E = (I \ominus E_c) \oplus E_c
Example of an opening on a small image I by the structuring element E_c
(with the origin c is at the centre and represented by the blue dot).

Figure 9:Example of an opening on a small image II by the structuring element EcE_c (with the origin cc is at the centre and represented by the blue dot).

Opening is an idempotent operation, that is to say, applying twice the same opening gives the same result as only one opening:

(I∘E)∘E=I∘E(I \circ E) \circ E = I \circ E

Closing

Contrary to opening, closing (french: fermeture) is firstly a dilation, then an erosion. Indeed, expansion closes holes but enlarges objects. To avoid the widening of the objects, an erosion can be applied with the same structuring element.

I∙E=(I⊕E)⊖EI \bullet E = (I \oplus E) \ominus E
Example of closing on a small image I by the structuring element E_c
(with the origin c is at the centre and represented by the blue dot).

Figure 10:Example of closing on a small image II by the structuring element EcE_c (with the origin cc is at the centre and represented by the blue dot).

Similarly to opening, closing is an idempotent operation:

(I∙E)∙E=I∙E(I \bullet E) \bullet E = I \bullet E