Activity 4 – Length and Area Estimation in Images

In this activity, a new method of image processing was taught to us. This was using green’s theorem in area estimation.

From our Mathematical Methods courses, we know that green’s theorem is a relation between the line integral of a contour and the area bounded by the contour. this is helpful in figuring out the area of objects with weird shapes.

We begin the activity with a simple image.

Act4

Test Image, simple rectangle 430×225 px in size. The image area is 500×500 px.

We use the edge function of Scilab’s SIVP toolbox. This function automatically detects the edge of the shape(though it only takes in grayscales). Interestingly, it uses many kinds of edge detection methods and thus still requires human control(at least in choosing).

The left one is detected by the sobel method and the right one was detected by the canny method.

So, using the edge points(from the obciously better ‘canny’ method), we can find the contour integral of the image using the discrete form of green’s theoremCodeCogsEqn

and we get the area of the rectangle.

while making the image in Paint, I set its dimensions to be 430×225 px and made sure it was centered at (250,250) that gives us an area A = 96,750 pixel. By taking the difference of the maximum and minimum value of x in list of edge points, we get a dimension of(428×225) and an area of 96300(0.5% percent away). But that would require every area we want to measure to be a rectangle. Using the green’s theorem method,  we get an area of 96,954 pixel. which is about 0.2% away from the the real value, half the error of the max – min method. Interestingly, I found that knowing the centroid improves the method’s accuracy.  In my code, the further I was from the actual centroid of the shape, the worse my measurements were.

We extended this new method to some real world applications:

I wanted to find out how big the CS Amphitheater was. So I took a screenshot of the google maps image of the amphitheater.

Amphitheater

google maps screenshot of CS Amphitheater. Bottom corner: Map to scale.

There are two things to take here. Using Paint, I measured the number of pixels the scale bar(which corresponded to a  20 meter distance in real life). I cropped the image. Darkened the area I wanted to measure and saved it as a monochrome image.

with the centroid (calculated using midpoints of the maximum distance of the axes) at (279,290),  the area calculated using Green’s theorem = 4448.75 sq. m. Which is 0.7% away from the expected 4417 sq.m  found using the bar scale.

I’m more or less confident with the green’s method algorithm so I used it to find the area of NIP.Act4NIP.png

I don’t know if I’m right but the area calculated was 5529 sq.m.

Finally, we used an image analysis software called imageJ that has a pixel scale. As a sample I used a 50 peso bill. Using ImageJ,  I used the length of the bill as the known length and found that the width was 66.75mm(it was actually 66mm).

Additionally, I tried looking at the Republic Seal

The measurement dialog box tells me that line in yellow tells is 10.155 mm.

I think I deserve 12/10 for this activity because I did all the procedures correctly and investigated the effects of centroid placement and experimented with shapes.

Many thanks to the heroes who wrote the scilab documentation.

code.PNG

I had to get creative.

About Nestor

One day, I thought, hey, I'll be writer. Turned out that writing isn't exactly a science. Now I'm a physics major wasting time trying to write
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment