Mathematical Morphology – Dilation in OpenCV

By | August 11, 2016

Mathematical Morphology – Dilation

Mathematical morphology is a technique that is used for object of having spatial nature such as images, graphs and meshes. It is a framework for describing image processing and analysis operations. Consider two things while working with morphology

  1. Image
  2. Structure Element (Smaller then image but can be of different block size e.g. 3 X 3, 5 X 5 which slides over image and transform it. )

In our tutorial, we will discuss limited set of morphological operation such as erosion, dilation and opening & closing. They can enhance binary image and can be applied on grey scale and color images if needed.


In this operation, small holes being filled and ills in narrow gaps between larger group of set points. It also increase the size of objects. As structuring element slides over the source image, new pixels marked as white.

Note: Normal dilation in an imaging context uses an isotropic structuring element.
Example 1 : Using default 3 X 3 isotropic structuring element

Example Code 1 :

Example 2 : Customizing Structuring element such as 5 X 5

Example 2 Code :

Results are shown in video given below