Wednesday, June 18, 2008
Area Measurement I
June 19, 2008 11:21 am
Grade: 10/10
The goal for today is to determine the area of a regular shape saved as a binary image, which is created in Paint.
Area is computed for using Green's Theorem, an approximation for contour integration.
My code, which has been written for scilab is as follows.
A = imread('C:\Documents and Settings\AP186User20\Desktop\circ4.bmp');
[x,y] = follow(A);
length_x = size(x,1);
length_x_minus1 = length_x-1;
x_(2:length_x) = x(1:length_x_minus1);
length_y = size(y,1);
length_y_minus1 = length_y-1;
y_(2:length_y) = y(1:length_y_minus1);
Area =(sum( x.*y_ - y.*x_))/2
theo = sum(sum(A))
error = 100*((theo - abs(Area))/theo)
The pixel count of the binary image is taken to be the theoretical area.
There were three shapes investigated: triangle, rectangle and circle. For the circle, the effect of radius on the error is investigated. Error has been found to be decreasing with increasing radius.
Triangle
Area calculated: 3162
Theoretical area = 3326
%error = 4.93%
Rectangle
Area calculated: 2517.5
Theoretical area: 2652
%error: 5.07%
Circle (radius = 15)
Area calculated: 600.5
Theoretical area: 649
%error: 7.47%
Circle (radius = 25)
Area calculated: 1707
Theoretical area: 1788
%error : 4.53%
Circle (radius = 35)
Area calculated :3509.5
Theoretical area: 3625
%error: 3.19%
Credits:
Thanks to Beth Prieto for helping me with scilab; Rica for loading ImageMagick; Aiyin for a pdf copy of the emailed attachment; Paul & JC for letting me use their internet; and to Ma'am Jing for pinpointing that scilab can have memory problems.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment