Image processing: Erosion, Dilation, Opening, Closing

Tram Ho

Theory

Today I would like to introduce some of the binary image processing methods that will be used during preprocessing or postprocessing. Depending on the data that we will apply the treatment method to match the appropriate filter it will help the image after processing to eliminate noise, light balance .. affect quality. of the photo. Today’s article I would like to introduce 4 methods:

  1. Erosion
  2. Dilation
  3. Opening
  4. Closing

Before going into learn we will look through the images below to get a glimpse of the processing of the above methods.

a-original image
b-dilation
c-erosion
e-opening
f-closing

We have the formula for determining erosion and dialation as follows:

With :

and

Where s is the pixel matrix of the image, f is a filter that can be an array or a binary matrix depending on the type of data we will choose the size of the fiter accordingly.

Erosion

Erosion, also known as erosion, is one of the two basic operators in mathematical morphology. It is often used in binary images but there are some versions that will be applied on gray images but for the purposes of my article today the focus is on binary images only.
The purpose of this method will help:

  1. Removes isolated noise pixels
  2. Removing noise pixels around the object helps make the edges (edges) of the object become smoother
  3. Removing the edge (edge) of an object helps the object become smaller and places those border pixels as the background layer of the object.
    We have the following example:

Dilation

Dilation, or expansion, is the remaining operator mentioned above, as opposed to erosion that is also applied in binary images. The purpose of this method will help:

  1. With out-of-focus images can help stitch photos together
  2. With noise around the object becomes the border of the object
  3. Help to stand out the object in the image more
    We have the following example:

Opening

Open = Erode next Dilate
With :

Closing

Close = Dilate next Erode With

We have the following visual image:

Depending on the data type and requirements of the problem, flexible methods will be applied.

Practice

Code come on, my most interesting part here ?

Erosion

Dilation

References:

The article above was summarized when I attended the class of Mr. Dinh Viet Sang – lecturer of Hanoi University of Technology and some of the documents I refer to below:

  • Library opencv
  • Computer Vision: Algorithms and Applications, 2010 by Richard Szelisk

Thank you for following up on my article ?

Share the news now

Source : Viblo