Info

此问题已关闭。 请重新打开它进行编辑或回答。

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 次查看(过去 30 天)
leaf=imread('13001931309789.jpg');
bw=1-im2bw(leaf);
imshow(bw);
p=regionprops(bw,'Perimeter');
all=[p.Perimeter];

回答(2 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020-6-14
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 2020-6-15
编辑:darova 2020-6-15
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!

Translated by