Friday, October 1, 2021

Extracting Connected Components

Introduction:

Extracting the connected components is a very common process done in Image processing. This can be done in various many ways, using many tools. Even though many tools like OpenCV and MATLAB provides us with predefined functions, It always gives us more understanding and freedom on the code, if we write it by our own. I have used Morphological Operations to be my basis and I have built my other functions over that base. A notebook can be found here, wherein I have used Python and OpenCV, to get the job done.

What are Morphological operations?

 Assuming that, one has an idea about, How images are manipulated in software, We can say that, Morphology is more like a study of structures. We Erode the borders, Dilate them, use simple boolean operations such as AND, OR, NOT to get through it, as the Image is already binarized (contains either 0 or 1, no other value.) More one Morphological operations and structuring elements can be read here .

How is it done?

The algorithm to find all the connected objects in a binarized image is as follows.


The way it works is explained in brief below
This process is based on iteration of the expression below,

Here, B is the Structuring element, A is the original thresholded image and Xk-1 refers to the matrix formed by first non-zero element for k=1, for rest of the ks, the expression takes care.
It is to be noted that the input image should be binarized before hand.

More on how it can be done can be seen in the IPython-Notebook which can be found here

 

 

No comments:

Post a Comment