Length and Area Estimation

Now here we are again in another exciting activity in Applied Physics 186. YEY!

yey
AAAAAAAAAH!

This time I performed the activity on length and area estimation. This activity is composed of three parts: simulated shape area, google map area and ImageJ measurements.

toomuchDo not worry, it will not be that hard and since I learned Scilab last activity, this activity will be a piece of cake!

dealwithit

To start, I used past codes (see Activity 3) to generate two kinds of shape: a square and a circle.

Figure 1. Centered Square
Figure 1. Centered Square
Figure 2. Centered Circle
Figure 2. Centered Circle

For the two images, the inside of the shape is white while the background is black. This is important because in using the edge function, the boundary must be black to white. If there are any other color present in image, an error would occur. Note that there are different types of edge functions in Scilab (e.g. canny, log, sobel, etc.). These different types will output a different type of edge image but I will not be discussing it here. For this activity, I have chosen the canny type because it outputs the area closest to the theoretical value. The output after using the canny edge function will then be:

Figure 3. Result of the edge function on the square
Figure 3. Result of the edge function on the square
Figure 5. Result of the edge function on the circle
Figure 4. Result of the edge function on the circle

After applying the edge function, I scanned the whole image and searched for a point inside the shape such that no multiple intersection of the radial line occurs.

Figure 3. An example of multiple intersections
Figure 5. An example of multiple intersections Retrieved from: http://www.engram9.info

The best point to choose when dealing with those two shapes is their respective centers. To get the center point, I added the topmost point and the bottom point and divided it by two to get the center in the y-axis. To get the center for the x-axis, I added the rightmost and leftmost point then again divided by two. Starting now, all angle measurements will be from this point.

But before solving for the angle, I used the find function to scan the whole image and return the pixel coordinates in which the pixel is white (or has a value of 1) so that I can now locate the edge pixel coordinates. After getting all edge pixels, I solved for its individual angle (per edge pixel) with respect to the chosen center and sorted it according to increasing angle. With this, we can now apply Green’s theorem to solve for the area inside each of the shapes.

To find the area, I cut the area in small triangle slices. Each pixel coordinate is a point on the edge of the area. We then take two adjacent points with coordinates (x1,y1) and (x2,y2) and find the area of the triangle formed by the two points.

greens
Figure 6. The triangle formed using the center and the two points. Retrieved from: Activity 4 Lecture and Laboratory Manual

The figure above shows an example of the triangle formed by the two points. Taking all the points on the edge pixels and taking their individual areas will give me the total area of the shape. Green’s theorem states that the area of the triangle is equal to:

Equation 1. Green's theorem
Equation 1. Green’s theorem

From the square and circle example, I got a total area of 1.0024859 square units for the square and 1.1308316 square units for the circle. Theoretically, the area for the square and circle should be 1.0 square units and 1.13097 square units respectively. I will therefore get a percent error of 0.25% and 0.012%. These percent error values are small enough to safely assume that the Green’s theorem is usable for any given area under the limitation that the area should be a regular polygon (but for the case of an irregular polygon, the area can be broken down into smaller regular polygon pieces so Green’s theorem can still be used).

The code used for this activity is shown below. Just replace the parameters of imread into the filename of the image in black and white:

Figure . The code for this activity
Figure 7. The code for this activity

Now that we have verified Green’s theorem to be usable, we take an area from Google maps and, using Scilab, find the estimated area of the chosen spot. For my case, I have chosen the state of Colorado in the United States of America. I have chosen this spot because it has a relatively easy shape but large enough so that the scale will be in hundred thousand square kilometers.

colorado
Figure 8. The state of Colorado in the United States. Retrieved from: Google maps

The first will then be to edit the photo such that the area to be covered will be white and the background will be black.

colorado2
Figure 9. The edited state of Colorado

From the image above, we used the canny edge function to isolate the edge pixels.

Figure 9. The edge pixels of the state of Colorado
Figure 10. The edge pixels of the state of Colorado

We then choose a central point and sort the angle of each pixel coordinates from the center in increasing order. After sorting, we use Green’s theorem to get its area. For this case, I multiplied the scaling factor (pixel to kilometers) with the acquired area to have it in square kilometers. The calculated area (from Scilab) is 275449.76 square kilometers. From Wikipedia, the area of Colorado is 269837 square kilometers. I got a percent error of 2.08% which is relatively small. The errors I got may be attributed to the inaccurate editing in Paint (from colored to black and white). Some areas not in the state may have been mistakenly edited to be white and thus part of the state. Since the scale is so large, the value of each pixel will be equal to a few kilometers so a small mistake may lead to a large change in the area of the state.

For the last part of this activity, we are to use the program ImageJ by the National Institutes of Health, US. I scanned a Gerry’s Grill membership card together with a protractor.

imagej2
Figure 11. Gerry’s grill membership card together with a protractor

I used 1 cm from the protractor and used it to calibrate. With the lengths calibrated, I then proceeded to measure the area of the card. I also measured the area of the card using the protractor. From ImageJ, I got an area of 45.609 square centimeters. In using the protractor, I got an area of 45.9 square centimeters. I got a percent error of 0.63%. The error I got can be attributed to the curved corners of the card. It is not easy to measure the area of a card when it has curved corners.

Review:

First of all, I enjoyed doing this activity. Even though I have had a mini vacation for one week (from Thursday to Wednesday) sorry maam =)

But during that mini vacation, in my free time, I did this activity and I was amazed with the results. Anyway, I finished this activity but I have not been able to think of ways to put “above and beyond” in my report so I will just give myself a grade of 10.

10-10

Also, I would like to give credits to those who helped me in this activity. I would like to thank Jesli Santiago and Martin Bartolome for helping me in my code for the Green’s theorem. I would also like to thank the state of Colorado for using their state in my report. Thank you America!

america

Leave a comment