June 26, 2008
Thursday
The goal for today is to get the area of a real object via Green's Theorem. My chosen object is a leaf.
The leaf image I used for processing was scaled to half of the above image. As can be seen a length of 1 centimeter in the vertical direction ate the same number of pixels as that in the horizontal direction. So no further rescaling was required. The image was saved with a bit depth of 8 using Paint software. Its histogram was then used to find out which gray level should be the threshold. It was found to be at gray level = 100 or 0.4. When the image had been converted to binary, its colors were afterwards inverted so that the leaf is bright and the background is dark. Then Green's Theorem was applied. (See preceding post for my code for executing the theorem.)
Scilab code for converting the leaf image to binary:
A = imread('leaves2.jpg');
histplot([0:255],A); //to determine the appropriate threshold level
bw = im2bw(A, 0.4); //threshold level= 0.4
imwrite(bw,'bw2.jpg');
Via the pixel counting method, getting sum(sum(bw)), the resulting area was 8491 pixels.
Meanwhile, Green's Theorem yielded an area of 8245 pixels (%difference from the pixel counting result = 2.9%). This is approximately 21 cm squared.
............
I rate myself: 10/10! because I think 21 cm squared is reasonable. The leaf's length was about 10 cm and its width, measured across the middle, was nearly 2 cm.
Credits: Benj and Ed for helping with syntax.
No comments:
Post a Comment