Wednesday, June 18, 2008

Activity 2

For this activity, I will give myself a grade of 9.
I was able to Implement Green's Theorem on a square, circle and rectangle image shown belowI was able to obtain the following Areas and computed for the percentage errors:
Image // Computed // Actual // Error(%)
square 4536 4900 8
circle 3422 3525 3
rectangle 3318 3526 6

I used the following code in scilab to obtain the area
-----------------------------------------------------------
I = imread("100rectangle.png"); //filename
i = im2bw(I,1); //convert to binary

[x,y] = follow(i);
sizex = size(x); //obtain matrix size
sizey = size(y);

x1 = x; //define new variables x1 and y1
y1 = y;

x1(2:sizex(1)) = x(1:sizex(1)-1); //shift x1
x1(1) = x(sizex(1));
y1(2:sizey(1)) = y(1:sizey(1)-1); //shift y1
y1(1) = y(sizey(1));

dif = x.*y1-y.*x1; //green's theorem
A = 0.5*sum(dif)
-----------------------------------------------------------

Abraham Latimer Camba and Eduardo David Helped me in this activity.

No comments: