Saturday, July 25, 2009

ACTIVITY 8 Morphological Operations



This activity was done to illustrate what the two common morphological operations, erosion and dilation, do when applied on an image of shapes or patterns. Figure 1 shows the image of shapes used in the activity. Before using the available functions in Scilab, the resulting images after applying erosion and dilation using the structuring elements (SE) in Figure 2 were first predicted. Theoretically, the resulting image after dilation is the set of all possible translations of the reflected SE such that when it is intersected with the image/shape, it is not an empty set. In the case of erosion, it contains all the possible translations of SE such that it is still contained in the shape. Given the definitions above, using dilation increases the size of the shape while using erosion reduces its size.

Figure 1. The shapes used to illustrate the effect of the morphological operations/functions, dilation and erosion, on binary images.

Figure 2. Structuring elements used to dilate and erode the images of shapes above: (4 x 4 ones), (2 x 4 ones), (4 x 2 ones) and a cross of length 5 and thickness 1.


Predictions:
For dilation, I just placed the SE at the corners of the shape such that at least 1 pixel is left contained in the shape. After which, I traced the corners of the SE located at the corners of the shape. My predictions show that the dimension of the shape is, indeed, increased by twice the (width/length -1) of the SE. Also, the resulting shape has curves similar to the SE.
For erosion, I translated the SE at the corners of the shape such that the edge of the SE and the shape coincide. Then, I chose the edges of the resulting shape such that at least one pixel of the SE is contained in that new shape. My predictions show that the dimension of the shape is reduced by twice the (width/length -1) of the SE. The resulting shape has also curves similar to the shape of the SE.
For a clearer visualization of what I meant above, look at the figures for my predictions.

Simulation using SciLab:
Figures 3 to 7 show the resulting images after applying the erosion and dilation functions available in SciLab on the images in Figure 1 using the stucturing elements in Figure 2. The gray portion is the original size while the white portion is new size (erosion) or increase in size (dilation). A detailed list of the dimensions of the resulting shapes can be found in the table below. The outline/curves of the resulting shapes match my predictions. However, only or some shapes and some SEs were my predictions able to match the simulation results. The following are the reasons for the disagreement of the results with my predictions:
1. The original size in my predictions is wrong. The shapes I created are smaller than my expected original size.
2. I forgot that the set of translations must be positive.
After realizing the those two things, I was able to correct my predictions and get the same results as the simulation results. Instead of the twice the (length/width of the SE- 1) increase or decrease in the dimension that I have predicted earlier, the change in dimension must only be by (length/width of the SE- 1) .


Figure 3. First row: dilation of square; second row: erosion of square.

Figure 4. First row: dilation of circle; second row: erosion of circle.

Figure 5. First row: dilation of triangle; second row: erosion of triangle.

Figure 6. First row: dilation of hollow square; second row: erosion of hollow square.

Figure 7. First row: dilation of plus sign; second row: erosion of plus sign.


Figures 8 and 9 are illustrations of the morphological operations, thin and skeleton, that are also available in SciLab. The thin function, basically, makes the images/shapes/patterns one-pixel thick. On the other hand, the skeleton function traces the interior/exterior skeleton of the images/shapes/patterns. It is dependent on the number of sides of the shape.

Figure 8. Results after applying the thin function on the images.

Figure 9. Results after applying the skel function on the images. First row: using the interior side; second row: using the exterior side.


I would give myself a grade of 9 for this activity. My predictions did not match the simulation results but I have explained above the reasons why it didn't.
Thank you to all those who have helped me in this activity.


No comments:

Post a Comment