Thursday, August 6, 2009

Activity 8 - Morphological Operations

In image processing, morphological operations are applied for altering the shape or structure of the objects in an image. These are usually done for binarized images. In this activity, dilation and erosion morphological operations were analyzed. These operations require structuring elements, which acts as basis for which the objects in the image would be dilated or eroded. Dilation basically results to an expansion of the object while erosion, to contraction of the object, based on the structuring elements used. Thinning and skeletonization operations (functions in Scilab, thin() and skel()) were also examined.

The objects used in this activity were a square (50x50 pixels), a triangle (base = 50 pixels, height = 30 pixels), a circle (radius = 25 pixels), a hollow square (60x60 pixels, 4-pixels thick edges) and a plus sign (line lengths = 50 pixels, 8 pixels thick). Dilation and erosion operations were applied to these shapes using the following structuring elements: 4x4, 2x4, 4x2 and a cross (5 pixels long, 1 pixel thick).

First, the results of dilation and erosion were predicted to check understanding of how these morphological operations work. The predictions were verified by using the Scilab functions erode() and dilate().

***The results presented below are in the following order: square, triangle, circle, hollow square and plus sign. For each shape result, the original image is shown at the top row, the dilation result at the second row, and the erosion at the third row. The dilation and erosion results for structuring elements 4x4, 2x4, 4x2, and cross are the top left, top right, bottom left, and bottom right, respectively.

Square
Original

Dilation


Erosion

Predicting the results of the morphological operations for square is easy because it has the same form as the structuring elements. The predictions were fairly accurate.

Dilation expanded the dimensions of the square by the same amount of pixels along that dimension (vertical or horizontal) as the structuring element. The 4x4, of course, expanded the square equally resulting into square shape of sides increased by 4 pixels. The 2x4 and 4x2 structuring elements resulted into a rectangular shape with the longer axis of the rectangle the same as the longer axis of the structuring element used. The cross structuring element resulted into a more complex shape. The sides expanded more than the corners. This is caused by the extensions from the arms of the cross.

On the other hand, erosion decreased the dimensions of the square by the same amount of pixels as the structuring element along the same dimension. The 2x4 and 4x2 structuring elements also showed the longer axis of the resulting rectangle perpendicular to the longer axis of the structuring element used. There were no longer extensions of the sides from the cross. This contrasting results from dilation and erosion is due to the fact that the two provides opposite restructuring. Dilation gets the points at which the center of the structuring element is still inside the object while erosion only at points where the whole structuring element is inside the object.


Triangle

Original


Dilation


Erosion

For the triangle, the predicted results using the cross structuring element were not correct. In general, the expansion of the base of the triangle were the same as that observed for a side of the square upon dilation. Erosion along the base was also the same. The resulting changes in the dimension was also similar to how much the length of the sides of the square changed. The base changed (decrease or increased) by the amount of pixels of the structuring element (erosion or dilation, respectively) along the horizontal, while for the height, along the vertical. The cross produced a more pointed tip of the triangle upon erosion, as expected.

Circle

Original


Dilation


Erosion

The results for the circle verified the correctness of the predictions. The shape change were basically the same as that for the square, however, the elongations resulted into ellipse. The orientation of the major axes of the ellipses have the same relationship as the longer axis of the square. The curved part of the ellipses were also deformed because the structuring elements are not curved.

Hollow square

Original


Dilation


Erosion

The morphological changes of the outer part of the hollow square are the same as results for the square. For the inner part, the morphological change is actually occurring for the black inner square. The change of the inner square is the same as that of the square with the opposite operation. For example, the dilation produces the same changes in the inner black square as that of the previous results for square upon erosion.
The results for the cross structuring element was again inconsistent with the prediction. The dots at the corners was not expected because it was hard to visualize the cross fitting inside that region.

Plus sign

Original


Dilation

Erosion

For the plus sign results, dimension changes were all, basically, the same as the changes for the square, either along the horizontal or the vertical. Again, this depends on the pixel size of the structuring elements along the specific dimension. Extensions at the tips of the plus sign were also observed, similar to the extensions of the sides of the square, using the dilation operation. However, the erosion of the plus sign with the cross produced a square at the center of the plus sign. This was not predicted. Intuitively, it makes sense because the cross would still fit inside the plus sign at the corners of the intersection of the vertical and horizontal lines. However, if the cross was moved further along the arms of the plus sign, it no longer fits making the arms thinner upon erosion.


(original image from http://www.nba.com)

Thinning and skeletonization operations were performed for the binarized sample image shown above.

Thinning

Thinning obviously results into thinning of the body and branches of objects in the image. The body branches of a blob in an image is reduced to a single pixel.

Skeletonization

Skeletonization of the interior, exterior and both

The skel() operation in Scilab provides the skeletonization for the interior, exterior and for both, for all the objects in the binary image. It outputs the basic structures that support the "bodies" in the image. As the name suggests, the skeleton or the foundation that would build the objects in the image (supporting it from the interior and the exterior) is the result obtained in this morphological operation.

For this activity, I would like to give myself a grade of 9 because I believe I rushed the predictions for the morphological operation results, making them more inaccurate. Actually, I intended to rush the predictions so that, somehow, some of the results will surprise me. Although, I think I should not have done that because I did not analyzed first how the operations work.

I would like to thank our professor, Dr. Maricor Soriano for the discussions and guidance in this activity.

No comments:

Post a Comment