Activity 4 – Length and area estimation in images

The objective of this activity is to use various softwares to measure area and length of images. To apply the skill acquired, we measured the area of a chosen building or any place of interest. I captured an image of the place using Google maps and measured its area using a scale for pixel to unit length ratio. We used Green’s theorem to measure the area of any image by using edges of the shape of interest. Morphological operations are the second technique used for this activity. These operations consider connected pixels as blobs. The area is calculated by counting pixels in the blob. The software used to measure length and area of images are Scilab 5.5.1 and ImageJ.

Green’s theorem is mathematically given by the equation:

A=\frac{1}{2}\sum\limits_{i=1}^{N_b} [x_{i}y_{i+1}-y_{i}x_{i+1}]

The equation tells us that the area can be computed by finding the coordinates of the edge of the shape by slicing the shape into “pie slices”. The adjacent edge coordinates are considered for each element of the summation. The sum of these elements gives us the area of the shape.

We verified the theorem by producing synthetic images in Scilab. The area of these images are analytically known. I produced 3 shapes: a circle, a square box and an ellipse. A Scilab code was produced based on the Green’s theorem to calculate the area of these shapes. I would like to recognize the help given to me by Ron Aves and Jesli Santiago in producing this Scilab code. I had a hard time thinking of how to sort the polar angle of the edges of the shapes with its respective x and y coordinates. Thank you for giving me a tip on how to collapse these matrices into a single matrix consisting of these important values.

code

After producing the figure, the image is loaded in Scilab. We find the edge using the command edge in Scilab. The method that proves to be most effective in our figures is “canny”. We record the pixel coordinates of the edge of the figure. Using these coordinates we take the polar angles of the coordinates then sort the coordinates with their respective polar angles to place adjacent coordinates next to each other. For these synthetic figures, I did not use the concept of the centroid since these figures are already centered.

circlesquareellipse

Upon sorting the coordinates, Green’s theorem was used to compute for the area in pixel units. The data gathered for each figure is as follows:

  1.  Circle -> radius = 0.7 -> Real Area: 1.5393 -> Scilab Area: 1.5387 -> Deviation: 0.04%
  2. Square -> length = 1 -> Real Area: 1 -> Scilab Area: 1.001 -> Deviation: 0.1%
  3. Ellipse -> a = 0.707, b = 0.767 -> Real Area: 1.7038 -> Scilab Area: 1.7031 -> Deviation: 0.04%

The deviations are very small that is why we can verify that Green’s theorem using edge coordinates of the shapes. After doing this I felt so happy just like this kid.

meme1

The next activity aims to use ImageJ to measure area. I was a bit surprised on how light the program is. It is also very user-friendly. The objective is to measure the area of a scanned image knowing the analytical area of the scanned object. I used my UP ID for this part of the activity. I would like to apologize for anyone who would be viewing my ID. I hope you’re ready in what you are about to see. Haha.

IDcut

My ID has dimensions of 86 cm x 54 cm. Its area is 4644 cm^{2} or 0.4644 m^{2}. Knowing the length of the ID, I drew a straight line to the length of the image. I set the scale by using Analyze > Set Scale… placing the known distance. The scale is given by 1169.14 pixels/m. By placing a polygon (rectangle) in the ID, we measured the area by using Analyze > Measure. The computed area for the ID is 0.455m^{2} with a deviation of 2.02%. We can observe that ImageJ computed a well accurate area of the scanned object.

To wrap up the activity, we aim to compute the area of a desired building or location. I chose the National Theater or the Tanghalang Pambansa in the CCP Complex. The building’s image in Google Map is shown below.

Untitled

I cropped the scale for me to check the area of the building in ImageJ. This scale is used to supply a known distance in the ImageJ program. The Scilab code used to measure area by Green’s theorem was also used to measure the building’s area. I faced a dilemma since I could not find the area of the National Theater. I never found the exact area of the building.

meme2

So to check the area of the building, I assumed that the exact area of the building is the computed area using ImageJ. Since I proved that accuracy is not a problem in the ImageJ mechanism of computing the area, I believe I can use this area. The scale used by ImageJ was 3.45 pixels/m. I loaded the figure in Scilab and modified the code by considering the centroid of the figure. I was not sure if the bitmap figure of the building is centered.

     Untitledcode2

The Scilab code used for this part of the activity is shown above. The bitmap image was created using GIMP. I would like to thank Jaime Olivares for helping me in editing the image to convert it into bitmap. Also credit is due to Robert Tacbad for helping me in completing my code adpating the concept of the centroid.

By running the Scilab code, I obtained an area of 97692.167 pix^2. Using the scale in ImageJ, I converted the pixel area in to real area. The computed Scilab area is 8207.7015 sq. meters. Using ImageJ, I was able to compute an area of 8191.388 sq. meters. I obtained a deviation of 0.2%. I could say that the Scilab code was effective in computing the area of the National Theater of the Philippines.

meme3

For my self-evaluation, I give myself a 9 of 10 since I finished the activity with good results. The 1 point I deducted is due to the punctuality of my work. I should have finished this activity last Friday or at least this weekend. I hope I can cope up in the next activity. I enjoyed doing the activity except for the image editing which took me so long. I really have no skills on image editing. Converting the image from Google Map into a bitmap image took me a lot of hours. It was a real challenge and I am really glad I was able to make it. Thank you Maam for this activity. 🙂

Leave a comment