1. Square2. Rectangle
3. Circle
4. Triangle

All images are 500x500 pixels and are originally in bitmap (.bmp) format. I compressed them to jpeg (.jpg) format to make uploading easier.
In order to find the area of the shapes, Green's function was to be used:
To implement Green's function computationally, the following Scilab 4 code was used:
[fig, figmap] = imread('F:/Applied Physics 186/Activity 02/shape.bmp');The function follow gives the coordinates of the contour of the figure, while the for loop basically implements the above equation using the contour obtained from follow. B simply displays the output of the summation, or rather, the total area of the figures.
[x, y] = follow(fig);
n=length(x);
B=0;
for i=1:n-1,
A = (0.5*(x(i)*y(i+1)-x(i+1)*y(i)));,
B = B+A;,
end;
B
The output of the code, as well as the percent error compared to the manually calculated area is tabulated below:

For this activity, I will grade myself 10/10 for having % error values less than 1%, which means that the Green's function is highly accurate, and is suitable for finding the area of irregular shapes, so long as it has a definite and continuous contour.
I would like to acknowledge Earl and Gary for their insightful discussions with me regarding this activity.
No comments:
Post a Comment