Sunday, June 28, 2009

ACTIVITY 2 - Area Estimation of Images with Defined Edges

In this activity, our goal is to be able to compute for the area of images with the use of Green's Theorem. First, we created images (with black background and white as the object) using MS Paint.


























Then, the areas of the object on each image were calculated using Green's equation given by
I create a code using scilab that computes for the area of the object in a black and white image. This code utilizes Green's equation. The computed area was then compared to the area obtained by summing up all 1's in the image (white object).

SOURCE CODE:

image = imread('tri 4900.JPG');//read image from file
bin = im2bw(image, 0.5);//convert image to black and white
[x,y] = follow(bin);//follow the contour of the object
plot2d(x,y);//plot of the contour

//Green's Theorem
area=[];
for i = 1:(length(y)-1)
area(i) = x(i)*y(i+1)-y(i)*x(i+1);
end
areatot =((sum(area))/2)

//pixel area
pixarea = sum(bin)-length(y)

//percentage error
%err = abs((areatot-pixarea)/pixarea)*100


By using the syntax 'follow', Greens's equation disregards the contour in computing for the area. In order to compensate the pixel area, we have to subtract the perimeter of the contour in the sum of the pixel area. The table below shows the computed areas and corresponding percent error. I give myself a 10/10 in this activity. I understand well the objective of the activity and thus being able to create a code. I acknowledged Raffy and Gilbert for agreeing with me about the fact that 'follow' disregard the number of pixels of the contour using Green's equation.

No comments:

Post a Comment