Thursday, August 6, 2009

Activity 8 Morphological Operations




Our previous activities dwelled on operations, enhancements, and other image processing techniques done in the Fourier space. This time our activity involves morphological operations to augment or distort binary images. In this activity we will be 'eroding' and 'dilating' binary images of a square, triangle, circle, hollow square, and a cross using different structuring elements. But before we do this operations in Scilab we will first do some manual, 'pen and paper', predictions.

A structuring element (SE) can be thought of as the distorting pattern used in morphological operations. The dilate operation results in an increase in the size of the dilated object whereas the erode operation decreases the its size. Both operations follow the shape of the structuring element. The result of a dilation can be thought of as the collection of points that the center of the SE can occupy such that the SE and the dilated object intersects. On the other hand the result of an erosion is the collection of points the center of the SE can occupy such that the whole SE is inside the object.

The structuring elements we use in this activity are a 4x4 square, 2x4 and 4x2 rectangles, and a cross 1pixel thick and 5 pixels long per arm. We apply the morphological operations to five shapes namely: 50x50 square, 50x30 triangle (base x height), radius 25 circle, 60x60 hollow square with 4 pixel thick arms, and a large cross 8 pixels thick and 50 pixels long per arm.

Figure 1 shows the result of the dilation of these shapes. My predictions for the square, circle, hollow square, and cross were all correct. I was able to predict both the shape and the actual size (pixel counts) perfectly. The square SE increased the sizes of these four shapes along the horizontal and vertical uniformly. Hence all retained their general shape except for the circle which became slightly squarish. As for the rectangle SE's they distorted the shapes more along their dominant axis. Finally, the cross SE caused the shapes to have a hole on the corners similar to the cross whereas the circle slightly had a greater increase along the horizontal and vertical.

I only made a mistake in predicting the result of the triangle. I got the proper shape right but the actual dimensions were off. I was confused on how the edges and the corners of the triangle would result. Compared to the results my predictions were slightly smaller.


Figure 1. Result of the dilation of five shapes (left column)
with four different structuring elements (top row).

Next, figure 2 shows the result when the shapes are eroded. Again my predictions were mostly correct but this time I was only wrong for the circle eroded with the cross SE. The results for erosion using the square and rectangle SE were simply the opposite of their dilation. The interesting result here is for the cross SE on the hollow square and cross. As I predicted only the corners of the hollow square can fit the cross SE, hence its edges would vanish upon erosion. As for the cross SE on cross it is interesting to see that near the center the resulting shape is thicker. This is because near the intersection of the cross there are more points where the cross SE can fit.


Figure 2. Result of the erosion of five shapes (left column)
with four different structuring elements (top row).

The last part of this activity involves exploring the thin and skel functions of Scilab. Figure 3 shows an image included in the SIP package which we chose to apply thin and skel on. Figure 4 shows the result of thin, just like in its description thin removes the edges of a figure until it becomes a skeleton of the original image. But the result seen in figure 4 is not actually a good skeleton of figure 3, which is part of the limitations of thin. Finally figure 5 shows the result of using the skel function on figure 3. skel is a better function that thin because (1) you can controll what type of algorithm is used and (2) both exterior and interior skeletons can be obtained. The output of skel is also in gray-scale which means we can controll the sensitivity of the resulting skeleton using im2bw() with variable threshold. Further more skel is an actual function designed to take the skeleton of an image not like thin.


Figure 3. Image of Birds (Escher)


Figure 4. Result of applying thin on figure 4.

Figure 5. Result of applying skel on figure 4, taking both
exterior and interior skeletons and using exact euclidian algorithm.

Information on the functions skel and thin is included in the help and documentation of Scilab.

I give my self a grade of 10 in this activity.

No comments:

Post a Comment