Monday, June 22, 2009

Area Estimation for Images with Defined Edges


Figure 1. Binary Image of a rectangle


Figure 2. Binary Image of a Circle


Figure 3. Binary image of a triangle

In this activity, the first thing I did was draw a rectangle, circle and triangle using Paint. These figures shown above are saved in JPG format. Next, I opened Scilab 4.1.2 and imported all these images. The image type of the figures is true color, so I converted them to binary type using the command “im2bw”. From the SIP toolbox downloaded and installed, I utilized “follow” command in order to generate the contour and obtain the pixel values of the edges. The figures below are the generated contours of the images.








Using Green’s Theorem, the area was computed. This was done by following the formula:


The corresponding code I made for this equation is:

image1=imread('binary image.jpg');
bw1=im2bw(image1,0.5);
[x1,y1]=follow(bw1);
Al=[];
for i=1:length(x1)-1;
A1(i)=(x1(i)*y1(i+1))-(y1(i)*x1(i+1));
end
area1=(sum(A1)*0.5)

Basically, I sum up all the values generated from the distance between two contour points and divide them by 2. The value in “area1” shows the area of the polygon. To check if the measured area was reliable, I compared it with the theoretical value which was generated by counting all the 1’s in the binary type image. Since the corresponding value of each pixel in the images are just 1 and zero, with 1 corresponding to the area polygon, by summing all 1’s, we can get the area. The table below shows the theoretical and calculated values of the areas of each polygon and the % error.



The deviation of the calculated area from the theoretical value is small and is ~2%, which means that Green’s Theorem is accurate and precise in area measurement. The errors are attributed to the boundary of the figures (contour lines) which are not considered in the formula I used. The computation can be made more accurate by considering this boundary. Either add the contour line in the Green's formula or subtract it from the pixel count of the image.


I would like to acknowledge Mr. Gilbert Gubatan, Gary Garcia and Orly Tarun for giving wonderful insights regarding this activity. And of course, to Dr. Soriano for assisting us and giving us some tips on area calculation. Thank you!
In this activity, I give myself a 9 to account for the % error.

No comments:

Post a Comment