Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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 vue (au cours des 30 derniers jours)
leaf=imread('13001931309789.jpg');
bw=1-im2bw(leaf);
imshow(bw);
p=regionprops(bw,'Perimeter');
all=[p.Perimeter];

Réponses (2)

KALYAN ACHARJYA
KALYAN ACHARJYA le 14 Juin 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]
  1 commentaire
Sarang Nyalkalkar
Sarang Nyalkalkar le 14 Juin 2020
try foe this input and please check it for me. If the same problem arises please fix it for me

darova
darova le 15 Juin 2020
Modifié(e) : darova le 15 Juin 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!

Translated by