Thursday, August 2, 2012

Morphological Operations: Erosion and Dilation

Morphological operations are used to smoothen boundaries, and remove noise and aritfacts. Morphology means shape. So, basically,  the shape of the object in an image changes depending on the type of operation used.

Morphological operations use binary operations. Two of the common morphological operations are dilation and erosion.

Erosion is an operation defined by the equation below.

where A is the image and B is the structuring element. The shape of the image, after the implementing erosion, is defined by the structuring element used. The origin of the structuring element moves across each pixel of the image, turning white pixels into black along the boundaries and holes of the image, thus, resulting to a reduced version of the original image.

The image below is a prediction of the output image if erosion is applied in an image.


Hand-drawn Predictions of Output image using erosion
To check if my predictions are correct, I used the erode function in the SIP toolbox of Scilab 4.1.2. It can be observed that most of my predictions do not match the generated output. There could be something wrong with my code. Looks like the output for the hollow box should not have such images upon applying erosion.


Output Image using Erosion


On the other hand, dilation is defined by the following equation:

 Dilation causes the image to appear bigger or larger than the original. In order to predict what happens to the image after applying dilation, one has to imagine overlapping the center of the structuring element at each pixel of the image. Shown below is my predicted final output upon applying dilation. The topmost row shapes are the structuring element while the leftmost column are the images to be dilated.


Hand-drawn predictions of output image using dilation


 Unlike my predictions when I used erosion, I was able to accurately predict the output when I predicted in the output image for the dialtion. The only output I failed to correctly predict is when the image of a hollow box.

Output Image using Dilation

I really had a hard time predicting the output. It was really quite confusing. So happy I finally understood the concept, not perfectly though. I still have to practice. But, at least. :)

For this activity, I give myself a 10 since accomplishing the tasks at hand and for understanding the concept. :)

thanks to Izay and Mabes for helping me understand the concepts and debugging the code. :)

Personal note:

This activity is really the most stressful one. It was not because of the activity itself but the fact that my Scilab 4.1.2 is not working well. I can't remember how many times I had to restart my laptop because the Scilab console says, "NOT RESPONDING". It's just so weird then that my Scilab was not working well. Only in this activity. Maybe I was just hexed. :|



Reference:
1. Soriano, M. Morphological Operations.

No comments:

Post a Comment