Thursday, June 19, 2008

Activity 2

Area Estimation of Images with Defined Edges (Regular Shapes)


*I used Scilab and its SIP toolbox to measure the areas of a circle, a rectangle and a square i have drawn using MS Paint.

The sample code used for the activity (square) is as follows:


-->[sqim] = imread ('C:\Documents and Settings\AP186user07\My Documents\My Pictures\sq.bmp'); //reads the binary image of a square

-->[x,y] = follow(sqim); //extracts parametric contours of the object and stores them as x and y vectors

-->length(x) //gives the length of array x which is the same as that of array y (returned 392)

-->
i = [1:391]; //index

-->
a(i) = ((x(i).*y(i+1))-(y(i).*x(i+1)))/2 //returns array of the areas of the pie-shaped finite partition

-->a(392) = ((x(392)*y(1))-(y(392)*x(1)))/2 //missing element disregarded earlier to avoid index error

-->
sum(a) //returns area of the object


The following results were obtained:

for this circle with radius of 100, the scilab program yielded an area with 3% error.

**Blogger (the site) refuses to upload both the rectangle and square pictures.

The 100x100 square (actual area 10000) when processed in the program yielded a 500 unit discrepancy, 5% error.
The actual area of the rectangle is 34000, the program gave 33120, yielding 2.6% error.

-i give myself a grade of 8 for this activity; not higher because even to me the program seems faulty, making up for missing elements at the end instead of a simple smooth program; and not lower because the resulting percentage errors were still below the acceptable 5% margin and i finished it quite quickly, it just took long to upload the report because of the problem with the internet connection.

-thank you to benj, mark, rica for their help with the program; and jeric for letting me use his pc.

No comments: