Info

This question is closed. Reopen it to edit or answer.

I am trying to calculate the perimeterof leaf but i'm getting the output as 2.7895e+3 in this way .please check this and correct my code. Thankyou in advance

1 view (last 30 days)
leaf=imread('13001931309789.jpg');
bw=1-im2bw(leaf);
imshow(bw);
p=regionprops(bw,'Perimeter');
all=[p.Perimeter];

Answers (2)

KALYAN ACHARJYA
KALYAN ACHARJYA on 14 Jun 2020
As the sample leaf image is not attched with the question , hence I have checked with another image and it shown correctly
leaf=imread('leaf.jpg');
bw=1-im2bw(leaf);
imshow(bw);
p=regionprops(bw,'Perimeter');
all=[p.Perimeter]

darova
darova on 15 Jun 2020
Edited: darova on 15 Jun 2020
I'd add imclose to your to clean the image (you have same deffects in it)
I1 = imclose(bw,ones(10));
p=regionprops(I1,'Perimeter');
result
all =
1.9774e+03
Then i used impoly manually to make a course contour to see if it's close to that value
p = impoly;
p1 = p.getPosition;
x = p1(:,1);
y = p1(:,2);
dl = hypot(diff(x),diff(y));
sum(dl)
axis on
result
ans =
1.6716e+03

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!