Activity 07: Morphological Operation
Morphology refers to shape. This is usually done to images with blobs that form a specific shape. What it can usually do is eliminated few pixels, fill gaps in between or even connect separate blobs of pixels to improve its shape. The background is of the value zero, and the foreground is 1.
Dilation and erosion are morphological operations to used in this activity.
Dilation of A by B is given by the equation:
B is the structuring element such that the effect of dilating is to EXPAND or ELONGATE A in the shape of B. This is illustrated in the figure below.
![]() |
Dilation by structuring element B on A, and the result of expansion of A. |
and is illustrated in the figure below.
![]() |
Erosion be structuring element B on A, and the result of reduction of A. |
The following shapes considered are as follows:
- 5 x 5 square
- a triangle, base=4 boxes, height = 3 boxes
- A hollow 10 by 10 square, 2 boxes thick
- A plus sign, one box thick, 5 boxes along each line.
Now, the structuring elements to be used are:
- 2 x 2 ones
- 2 x 1 ones
- 1 x 2 ones
- cross, 3 pixels long, one pixel thick
- a diagonal line, two boxes long, i.e. [0 1; 1 0]
The first part of the activity was to predict the resulting image if the structuring elements were used to erode and dilate the shapes.
Note that the shapes are shown below.
![]() |
5 by 5 square, cross, hollow square, and a triangle shapes to be dilated and eroded. |
![]() |
Structuring elements to be used for dilation and erosion on the shapes above. |
Predictions
The prediction was done using a graphing paper, a pencil, and a pentel pen. My prediction are shown on the next figure.![]() |
Predictions for the possible outputs in dilating and eroding the shapes with the structuring elements. |
Then I reloaded the siptoolbox, and YEY! It was successfully loaded. Now I used erode(), and dilate() functions to the shapes and structuring elements and saved it as an image. The syntax is given by:
erode(shape, structuring_element)
dilate(shape, structuring_element).
Results
The next problem was that Scilab 4.1.2 siptoolbox does not have any imresize() function. This therefore comes as an issue in displaying the results since it would be too small. So I used Scilab 5.3.3 to resize all my results to 200 by 200 pixel size.The results are are as below.
![]() |
Dilation and erosion by the various structuring elements on a 5 by 5 square. |
![]() |
Dilation and erosion by the various structuring elements on the cross. |
![]() |
Dilation and erosion by the various structuring elements on the hollow box. |
![]() |
Dilation and erosion by the various structuring elements on the triangle. |
On different shape..
I also tried it on a figure that I created as shown in the figure below. This shows that the morphological operations can either join parts or even eliminates small parts which can be useful in image processing if you wish to account only big blobs or such.![]() |
Erosion and dilation on a single image with various structuring elements. |
Reference:
"AP186 A7 - Morphological Operations", Dr. Maricor Soriano, 2012
Comments
Post a Comment