how to finding aspect ratio from an binary object of leaf
3 views (last 30 days)
Show older comments
eprass murdani
on 1 Jan 2017
Edited: eprass murdani
on 3 Jan 2017
Hello all,
I'm new in matlab. I have sample binary image of a leaf from the internet
and I found some script to find height and width from the object from here find height and width an object
This my code in MATLAB:
img = imread('C:\Users\edopras\Documents\MATLAB\BW\5. Quercus robur\iPAD2_C05_EX05_B.TIFF');
imshow(img);
s = regionprops(img);
bb = vertcat(s(:).BoundingBox);
r1 = min(bb(:,2));
c1 = min(bb(:,1));
h = max(bb(:,2)+bb(:,4))-r1+1;
w = max(bb(:,1)+bb(:,3))-c1+1;
rectangle('Position', [c1,r1,w,h],...
'EdgeColor','r','LineWidth',1);
fprintf('\nw = %d\th = %d',w,h);
aspect = h/w
and the result is like this

The value of height = 624, and width = 279.
aspect_ratio= height/width -> "(624/279=2.2366)".
My question is:
Is the algorithm to find aspect ratio correct or not??
and, can I use this value as a feature of shape to my classification in future??
Thanks,
best regards.. :)
0 Comments
Accepted Answer
Image Analyst
on 1 Jan 2017
Yes, it can be, but usually the aspect ratio is the width over the height, like for televisions you see 4:3 or 16:9.
And yes, you can use that as a feature in your image classification routine. Different trees have different ranges of aspect ratios for their leaves.
Maybe you should spend more time in Answers than StackOverflow. You'll find that I post tons of demos here. For an Image Segmentation Tutorial, you can see my File Exchange. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
And of course leaf image analysis (and fruit) seems to be a favorite subject for people here in this forum. Just search for the tag "leaf".
3 Comments
Image Analyst
on 1 Jan 2017
Yes. I'm sure you will include other things in your thesis though. Doing just this is only worth a homework problem, not a Masters degree.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!