how to finding aspect ratio from an binary object of leaf
Show older comments
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.. :)
Accepted Answer
More Answers (0)
Categories
Find more on Agriculture in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!