Monday, June 22, 2009

Activity 2:Area estimation for images with defined edges

Objective: Use image processing software and Green's Theorem to compute the area of a regular polygon and compare this with the analytically computed area.

Tools: Scilab specifically the Image Processing Toolbox, MS Paint

Procedure: We use four different regular shapes drawn in black and white using MS paint.
These have areas of 10285, 6545, 5676 and 42121 square units respectively. Using the "follow" command in Scilab, we can get the x and y coordinates of the contour forming the border of the black and white regions. This creates two arrays of numbers called X and Y.

We then use a "for" loop to substitute these values of X and Y into the equation:where x and y are the coordinate arrays and the index i is the length of the array. This code is implemeted as follows:
______________________________________________________________
clc
clf

fig=imread('C:\Documents and Settings\2005-09860\Desktop\circ.bmp');
fig=im2bw(fig,0.5);
imshow(fig);

[x,y]=follow(fig);

i=length(x);
a=[];

for j=1:i-1
a(j)=x(j)*(y(j+1))-y(j)*x(j+1);
end

Area=sum(a)/2

______________________________________________________________

This code outputs a number which corresponds to the are of the polygon.

Results:


The following results were obtained using the shapes above:


These results correspond closely with the computed values. With the exception of the triangle, the deviations were all below 5% which indicates consistency. The triangle area may have a larger difference due to the manner in which a diagonal line is drawn in MSPaint. The line is drawn as a series of steps instead of a straight line.

Acknowledgements: I would like to thank the usual people for their help.

Refernces:
AP 186 Activity 2 Manual.

Rating: For this Activity, the acceptable correlation of the results with the actual values allow for a rating of 10.

No comments:

Post a Comment

Followers