Archive for June 29, 2010

Area estimation of images with defined edges

AREA OF REGULAR SHAPES

For this activity, the goal is to investigate the accuracy of Green’s theorem in estimating the area of images. It is given by

The images tested were of regularly shaped objects created in Paint. Then using the  follow command in Scilab’s SIP toolbox,  the pixel locations of the object’s edge were determined. Take note that there should only be one object in the image and it must be in binary (object is white, background is black). Green’s theorem was then implemented as follows.

image = imread('<image file>');
[x,y] = follow(image); 
lx = length(x);
ly = length(y);
xnew(1) = x(lx);  
ynew(1) = y(ly);  
xnew(2:lx) = x(1:lx - 1);
ynew(2:ly) = y(1:ly - 1);
//area using Green's theorem
A = 0.5*abs(sum((x.*ynew)-(y.*xnew)))

The pixel values of the contour were then used to compute the area of each shape analytically.

//theoretical area of rectangle
 TA = (max(x)-min(x))*(max(y)-min(y)) 
//theoretical area of circle
TA = %pi*(((max(x)-min(x))/2)^2) 
//theoretical area of triangle
TA = (1/2)*(max(x)-min(x))*(max(y)-min(y)) 

Results:

LARGE RECTANGLE
A = TA = 22785
% error = 0

SMALL RECTANGLE
A = TA = 2256
% error = 0

LARGE CIRCLE
A = 27044
TA = 26880.252
% error = 0.61%
MEDIUM CIRCLE
A = 7738
TA = 7853.9816
% error = 1.48%

SMALL CIRCLE
A  = 970
TA = 1017.876
% error = 4.70%

LARGE TRIANGLE
A = 16418.
theoretical  = 16284.
%error = 0.82%

SMALL TRIANGLE
A = 3583.5
theoretical = 3483.
% error = 2.88%

Upon comparing the results, I must say that Green’s theorem is not always accurate. It is only favorable for shapes with smooth and straight edges such as squares and rectangles. The differences between the values for each method can be duly observed in shapes with curved or diagonal edges. Zooming in the image of the circle and triangle, it can be seen that their edges are not smooth. As the object becomes smaller, the accuracy of the Green’s theorem also decreases.

—————————————————————————————————————————————————

AREA OF IRREGULAR SHAPES

Here is an image from Google Maps showing the location of SM Clark. I estimated its area in square meters by applying Green’s theorem and the technique used in the first activity.

Dimensions: 488 x 704

A. Estimation of the area using Green’s theorem

1. Unnecessary details in the background of the image were eliminated to estimate the area of the object easily.

2. The histogram of the grayscale version of the image was then plotted. By examining the histogram, the threshold value was estimated at 225 to separate the background from the region of interest.

image = imread('<image file>');
histplot(0:255, image);

3. The image was converted to binary using the threshold value obtained, which is 0.88.

bw = im2bw(image, 0.88);

imshow(bw, []);

4. The colors of the image were inverted to enable application of follow function. The code for Green’s theorem shown above was again used to compute for the area.

image = 1-image;
imshow(image,[]);

Result:

Area = 178758 pixels

B. Estimation of the area using analytic method

1. The pixel locations of the endpoints of the object were determined using Paint.

2. Since the object is an irregular polygon, the object was divided into two triangles.

3. The obtained pixel locations were substituted in the distance formula to find the height and base of each triangle.

4. The universally accepted formula for the area of a triangle was used.

5. The two areas were added to get the total area of the lot in pixels.

Result:

Area = 178927.9 pixels

C. Conversion to square meters

1. The scale in the map was used as a basis for converting area from pixels to square meters. The pixel locations of its tick marks were determined.

2. The pixel locations of tick marks were subtracted.

3. The number of physical values (100 m) was divided by the number of pixels between the tick marks (88 pixels).

4. The result was multiplied to the areas acquired from A and B.

Results:

TOTAL AREA USING GREEN’S THEOREM: 207858.1 square meters

TOTAL AREA USING ANALYTIC METHOD: 208055.7 square meters

% ERROR = 0.09%

—————————————————————————————————————————————————

Self Evaluation: I give myself a 10 since the percent deviations of the results were reasonably small.

—————————————————————————————————————————————————

Reference:

Soriano, M. Area estimation of images with defined edges. 2010



Design a site like this with WordPress.com
Get started