Monday, June 22, 2009

Activity 2 - Area Estimation for images with defined edges edges

Using the Green's Theorem, areas of some polygons are obtained in square pixels unit. This analytically estimates the area of the polygon by summing all areas of smaller triangles constituting the polygon.


Images used in the activity:


Area Comparison:

For the analytical way of obtaining the area of the white region, I just summed up all the pixels since this is a binary image pixel will only have values of 1 or 0 with 1 representing the white area and 0 as black. Thus I can obtain the area analytically and compare the results with that of Green's theorem. The results are posted below:
Code:
[pol,map] = imread('I.bmp');
polbw = im2bw(pol,map,0.1);

[x, y] = follow(polbw);
plot2d(x,y)
sz = size(x,1);

xi = x(1:sz -1);
yi = y(1:sz -1);

xi1 = x(2:sz);
yi1 = y(2:sz);

area = 0.5 * sum(xi.*yi1 - yi.*xi1) + (sz/2)
areat = sum(polbw)

err = 100 - ((areat - area) / areat) * 100

Above is the code used to implement the Green's Theorem. It is then vectorized and limited the use of for loops to improve the computing time of the code. It is just a simple code to solve Green's.

The obtained accuracy is very significant since it is at 98 - 100 % accurate in estimating the area. Also, the algorithm has a correction factor added to the computed area of (sz/2) because it covers the contour plot from the follow function. This contour is still part of the original area and a small correction has to be added.

The code is limited to regions only with one filled area. The code does not apply to polygons like a "doughnut" since the follow function of scilab considers only the first connected contour like. In this case, the inner contour for this region will be neglected and a wrong calculated area will be obtained.

I give myself 10 points for satisfying the objectives of the activity.

Extension:

Estimating UP-Diliman's total land cover

I obtained a UP Diliman map from Wikimapia. To make it easier, I mouse-over the UP area and its boundary higlighted in yellow color. I then have the page print-screened. Using Gimp, I manipulated the image so that only the UP area will be left. I used the select by color tool (subtract), added an alpha channel and copied the selected part. Visit http://www.gimp.org/tutorials/Changing_Background_Color_2 for detailed steps. Since I am not skilled in gimp, i used morphological operations in Matlab to enhance more the image to fill in the holes. Specifically I used imclose function to "fill" the map. I finally have a filled-in UP Diliman map and have to invert the color so that white is inside the contour. The following images will illustrate more of the steps.

Then, the final image can now be processed for area estimation in square pixel units. To convert this in square meters, a conversion factor must be obtained. From the print-screened image, I determined how many pixels there are in 500 m after loading it in Paint. This can be seen at the lower left part of the image (scale).

I obtained a conversion ratio of 106 px:500 m and computed UP Diliman area summary:
area = 215179.5 sq px
areat = 215469. sq px
err = 0.1343581 %
up_area_m2 = 4787724.7 sq m
up_area_h = 478.77247 hectares
accuracy = 97.114092 %.
I can say that the algorithm is very good in the area estimation comparing with the reported 493 hectares UP Diliman land cover.

0 comments:

Post a Comment

Followers