Home > Image Processing > 4. Area estimation of images with defined edges

4. Area estimation of images with defined edges

Area computation has several applications in biomedical imaging, marine signaling and geomatics.  Here we explore on the use of the image processing tool  Scilab and a standard scientific algorithm for calculating areas out of raw images.

Green’s theorem is a vector identity that relates the surface integral of a boundary to its line integral.  It says that the area of a surface can be calculated by the equation:

which can be expressed in discrete form as:

When dealing with images, we can use the coordinates (x and y) or the pixel locations of the image in order to compute for the area of interest.  We begin by applying these basic methods on the simple figures below:

Figure 1. Basic polygons: circle, square and triangle.

We first make sure the images are in their binary form in order for the machine to easily interpret the values.  The area to calculate should be set to white, and the background black.  Then we use Scilab’s follow() function that returns an array of the coordinates of the detected edges or contour.

I = imread('circle.bmp');
I = im2bw(I, 0.5);

[x,y] = follow(I);
plot2d(x,y, rect=[0, 0, 250, 419]);

The plot2d() function allows us to view the edges detected in the image. Figure 2 below shows the results for the three polygons.

Figure 2. Edge detection results for the three polygons.

Applying the Green’s theorem we write our Scilab code as follows:

len = length(x);
area_calculated = 0;

for i=1:len-1
   area_partial = (x(i)*y(i+1)) - (x(i+1)*y(i));
   area_calculated = area_calculated + area_partial;

Finally we make sure that the boundary of the contour is closed such that x(len+1)=x(1) and y(len+1)=y(1)

area_partial = (x(len)*y(1)) - (x(1)*y(len));
area_calculated = (area_calculated + area_partial)/2;

The actual area of a digital image can be known through the sum of all its filled pixels.  We get the accuracy by first calculating the percent error.

area_analytical = sum(I);
percent_error = (abs(area_analytical - area_calculated)/area_analytical)*100;

accuracy = 100 - percent_error;

Accuracies may also be visualized by overlaying the plot of the polygon with its detected edges. (Click on the images for larger view.)

Figure 3. Overlayed plots for the polygons and their contours.

Here the summarized calculations for the three figures:


Pixel Count

Calculated Area


Circle 95812 95319 99.4854507
Square 62500 62001 99.2016000
Triangle 45066 44614 98.9970266

Notice the accuracy of the algorithm on well-defined contours.  We can also investigate the effectiveness of this method on other shapes such as the following:

Figure 4. Test figures: (1) a smaller square, (2) puzzle swan, (3) lowecase T (4) cat silhouette

The following are the results for the area estimation:


Pixel Count

Calculated Area


Small Square 22500 22201 98.6711111
Puzzle swan 20983 20650.5 98.4153840
Lowercase T 26517 25882.5 97.6071954
Cat silhouette 17904 18073.5 99.0532842

We notice here that error increases when the area calculated for is of lower resolution. Also, more inaccuracies arise when it becomes more difficult for the algorithm to traverse the contour.


Geomatics Application

We apply this estimation algorithm in finding the total land area of the National Science Complex of the University of the Philippines Diliman.

Figure 5. Helicopter view of the National Science Complex. Courtesy of Gil Jacinto.

We obtain a satellite map from Google Maps and highlight the area using a GIMP selection tool [2].

Figure 6. Highlighted area of the National Science Complex. Courtesy of Google Maps.

The selected area is then converted to a binary image and was later calculated for its area.

Figure 7. Binary representation of the land area.

The National Science Complex is known to have an area of 21.9 hectares (multiply by 10,000 to convert to sq. meters).   Using the Google Maps’ scale legend, we perform ratio and proportion in order to obtain actual measurements.  We find that 87px of the image represent 200m of the land area. The following table displays the pixel calculations and the actual area accuracy.


Analytical Area

Calculated Area


Map image (in sq. pixels) 45481 45047 99.045755
Land area (in hectares) 21.9 23.806051 91.296571

Our results show that the method of Green’s Theorem proves to be an accurate algorithm on practical discrete digital images, such as the NSC map.  The minimal errors is accounted on the manual method selection and the limited resolution of the map.

For this segment, I would rate myself 11 for completing the tasks and figuring out other necessary methods to find the land area estimation.

[1] Soriano, M., 2010.  Area estimation of images with defined edges.  Applied Physics 186.
[2] Hattingh, F., 2008. GIMP for dummies – How to highlight part of image.
[3] Vergara, J., 2009. Area estimation for images with defined edges.
[4] Wolfram, 2010. A Discrete Green’s Theorem. Wolfram Demonstrations Project.

  1. July 1, 2010 at 3:04 pm

    2 smart for me 😉

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: