In mathematical morphology, erosion and dilation are the two fundamental operations upon which most morphological algorithms are built. These operations are based on set theory and apply to binary as well as grayscale images.
1. Erosion
Let A and B be sets in the 2D integer space Z², where:
- A = set of foreground (object) pixels
- B = structuring element (SE)
Then, erosion of A by B, denoted as:


Figure Reference: Fig. 9.4
- Fig. 9.4(a): Binary image I containing object A
- Fig. 9.4(b): Square structuring element B
- Fig. 9.4(c): Result of erosion using B
- Fig. 9.4(d–e): Elongated SE and its erosion result
The solid line in (c) and (e) shows the erosion result; the dashed line is the original object boundary (reference only).
Observations from Erosion:
- Erosion shrinks or thins the object A
- The result depends on the shape and size of the structuring element
- Erosion removes boundary pixels and breaks narrow connections
2. Dilation
Let A and B be sets in Z². Then, dilation of A by B, denoted by


Figure Reference: Fig. 9.6
- Fig. 9.6(a): Binary object A with larger background
- Fig. 9.6(b): Structuring element B
- Fig. 9.6(c): Dilation of A by B
- Fig. 9.6(d–e): Asymmetric SE and its dilation result
Solid boundary shows dilation result; dashed boundary is original object.
Observations from Dilation:
- Dilation grows or thickens object A
- Useful for connecting broken parts and filling small holes
- The shape and size of SE control the amount of expansion

Summary
