I made four different shapes:
1. Square
2. Circle
3. Triangle
4. Irregular shape
Using scilab, I made a program to get the area for each of the shapes I made. I posted the source code below:
a = imread("C:\Documents and Settings\AP186user15\Desktop\ryt.bmp");//command line for opening image file
b= im2bw(a,1);
[x,y] = follow(b);
c = size(x);
d = size(y);
c1 = c(1);
d1 = d(1);
x_1 = x;
y_1 = y;
x_1(2:c1) = x(1:c1-1);
x_1(1) = x(d1);
y_1(2:d1) = y(1:d1-1);
y_1(1) = y(d1);
initial = x.*y_1 - y.*x_1;
area = (0.5*(sum(initial)));
absolute_area = (area^2)^0.5;
//Getting the percent error //
Error = ((sum(b)-absolute_area)/sum(b))*100;
The resulting areas and the actual area:
Area | Pixel Count Area | Percent Error | |
Square | 88209 | 88804 | 0.67 |
Circle | 71552 | 71981 | 0.6 |
Triangle | 44999.5 | 45450 | 0.99 |
Irregular Shape | 48780 | 49383 | 1.22 |
For this program, Ed helped me in identifying errors in my program and Raf helped me understand the equation I used in obtaining the area of the image.
For this activity, I will give myself a grade of 9.5 / 10. It's not 10 because others helped me do this program.
1 comment:
Come on Jorge, that's a 10 you deserve there. Sure you got help from others, but that's the idea of this class - learn from each other. I hope you too will help your classmates when, in the course of the class, you know something they don't.
Post a Comment