Wednesday, June 24, 2009

Activity 2 - Area Estimation of Images with Defined Edges

Using Paint, a simple shape was created (in this case, a 30x30 square). The background is black (0), and the object is white (1).
The area of this shape is to be estimated by implementing Green's Theorem in Scilab. The contour of the object is traced by the command
follow in SIP toolbox.

Once the contour is known, the area can now be calculated using Green's Theorem. The discrete form of Green's theorem is given by [1]

where x and y are the coordinates of the contour, and Nb is the number of pixels of the contour.

Outright implementation of the above formula resulted in an error in the calculated area. It was observed that the
follow command gets the inner contour for the upper right side of the image, and the outer contour for the lower left side of the image. The inner contour is closer to the center by a pixel, so a correction factor is necessary. Since it affects only half of the contour of the area, half of the perimeter of the contour is added to the calculated area.

The calculated area of the program was
841 pixels. This may seem wrong, because since the image created in Paint is 30x30, the area should be 900 pixels. However, it was observed that the pixel coordinates shown in the lower right area in Paint are off by a pixel (for example, if it shows that the pixel coordinates are (10,10), the true pixel coordinates are (9,9)). This means that the image made is actually 29x29, and the area is exactly 841 pixels.

Next, the method was tested using other shapes. Shown below are four other images with which the method was tested, and their corresponding percent errors in area estimation.


(a) (b) (c) (d)
Figure 1. Other shapes, not to scale. (a) Square: 39x39 pixels, 0% error. (b) Circle: radius = 75 pixels, 0.648% error. (c) Flower: middle square = 97x97 pixels, 0.745% error. (d) Puzzle piece: middle square = 193x193 pixels, 0.098% error.

With the correction factor, the method is 100% accurate for square and rectangular shapes. For other shapes, there are errors but only very minimal, usually less than 1%.


For this activity, I give myself 10 points. I was able to use Green's theorem to estimate the areas of objects with defined edges with less than 1% error.

Credits: Miguel Sison, Martin Tensuan.


[1] A2- Area estimation of images with defined edges.pdf (from Dr. Maricor Soriano)

0 comments:

Post a Comment