Monday, June 29, 2009

Activity 2:Area estimations of images with defined images

Activity 2 Area estimations of images with defined images

For this activity the area of certain region in an image with a defined geometry is estimated using Green’s theorem. In summation (discrete) form, if there are Nb pixels in the boundary or contour of R then the area of R is

The parametrized x and y coordinates for this computation were obtained using th SCIlab’s SIP toolbox function follow() that has the command
[x,y] = follow(Img).The xy vectors stores the parametized contour and Img is a binary array of 0 and 1 where 0 is equivalent to background and 1 is the object. But before we can do this, the image data is first loaded in for processing.

Imread is used to read the image and obtain an array containing the image data and im2bw is used to convert these data values to binary by thresholding, say 0.5. Then the follow command is used to trace the x y pixel coordinates nearest the edge which we plug in to Green’s function to get the area.




Another way of obtaining the area is by taking the sum of the white region via sum(Img). Basically we sum the 1’s in the binary array. This value is equivalent to what we call the analytical sum and is used to check the experimental area value obtained using Green’s function. The closer these values coincide the lesser the error.

The code made is shown below:

I=imread('C:\Users\USA\Desktop\circle140d.bmp');
b=im2bw(I,0.5);
[x,y]=follow(b);
xsize=size(x);
ysize=size(y);
xlen=length(x);
ylen=length(y);
xi(1)=x(xlen);
yi(1)=y(ylen);
A_g=abs(0.5* sum( xi.*y - x.*yi));
A_sum=sum(b) ;
D= abs( (A_sum-A_g)/A_sum),"Error"

**************************************

I would like to acknowledge Rommel for helping me with scilab and code for loop code.. when it didn’t worked… thanks otherwise I wouldn’t have finished the work.
Grade: 9/10 because of the small error in the results.

No comments:

Post a Comment