First, we're asked to make a black and white image of a regular object with the object being white and the background colored black. The area of the object must be known in order to compare it with the results. So I made this 150 by 80 pixel white rectangle with it's upper left corner starting at 100, 100 (origin at upper left corner) using Paint.
And as told, I saved it in BMP format rather than JPG. So the white rectangle has an area of 150 x 80 = 12,000 pixels.
Next, let's load this into scilab and compute for the area:
I = imread("C:\shape.bmp");The removal and addition of the 1st and last elements on xiplus1 and yiplus1 are just to shift it one place. x and y contains 452 elements. And fortunately, the follow function gives out the parametrized contour vectors x and y, so x and y are in coordinate system (not rows and columns).
[x, y] = follow(I);
xiplus1 = x;
d = xiplus1(1);
xiplus1(1) = [];
xiplus1(452) = d;
yiplus1 = y;
e = yiplus1(1);
yiplus1(1) = [];
yiplus1(452) = e;
A = 0.5 * sum((x .* yiplus1) - (y .* xiplus1))
I got the answer of 11,544 pixels which has a 3.8% error:It's a good estimate since the error's under 5%; it's a fairly accurate technique. Although personally, I was expecting it to perform better since the shape was a simple rectangle.
Then using paint, I delineated the area of interest from the rest and the result was:
I have determined that 87 pixels = 200 meters (lengthwise). So that means 1 lengthwise pixel = 2.299 meters and 1 (square) pixel = 5.285 sq meters. Therefore 50, 549.5 pixels would be equivalent to:
267, 139.65 sq metersNow's let's try to compute for the error. Since the scale bars take up two pixels:
scale bar
This means that the error would be plus/minus 1 pixel (lengthwise), which would translate to: (using error propagation)
(200/87) * (1/87) = 0.0264 meters.
Therefore the error in area per pixel would be:
(200/87)*(2)*(0.0264)*(87/200) = 0.121 sq meters
Multiplying this with our answer with 50, 469 pixels, we get the error of:
So the final answer is:
And we have determined 328.37 m and 259.65 m to be the lengths of the semi-major axis and semi-minor axis respectively. Using the formula for the area of an ellipse, we get the value:
(200/87) * (1/87) = 0.0264 meters.
Therefore the error in area per pixel would be:
(200/87)*(2)*(0.0264)*(87/200) = 0.121 sq meters
Multiplying this with our answer with 50, 469 pixels, we get the error of:
6106.75 sq meterswhich is 2.29% of the result.
So the final answer is:
267, 139.65 +- 6106.75 sq metersFinally I have to compare this with the actual value. Sadly, I can't find the area of the region inside the elliptical road on the internet so Joseph Bunao and I used Google Earth to determine the semi-major and semi-minor axis of the ellipse.
And we have determined 328.37 m and 259.65 m to be the lengths of the semi-major axis and semi-minor axis respectively. Using the formula for the area of an ellipse, we get the value:
267, 856.18 sq metersWow! The estimated area is very close to this value and has an error of 0.27%. This shows that the technique is accurate when dealing with images with defined edges since this will determine the contour that is used in Green's theorem.
And with that, I give myself a 10/10 for producing the requirements and understanding the lesson. The images are clear and of good quality.
Score: 10/10
Lastly I would like to thank Dr. Soriano for always entertaining my questions and Joseph Bunao for helping me find the lengths of the axes of the elliptical road.
- Dennis
References:
1. M. Soriano, "A4 - Area Estimation"
2. Google Maps
No comments:
Post a Comment