how to count leaves?

5 views (last 30 days)
Keane Athallah
Keane Athallah on 19 May 2022
Commented: Keane Athallah on 20 May 2022

Accepted Answer

yanqi liu
yanqi liu on 20 May 2022
yes,sir,what is leaves,is it the bigger area,may be use image segment,such as
im = imread('');
im = imcrop(im, [210 125 540 350]);
bw = im2bw(im);
bw2 = bwareaopen(bw, 100);
stats = regionprops(bw2);
figure; imshow(im); hold on;
for i = 1 : length(stats)
hold on; rectangle('position', stats(i).BoundingBox, 'EdgeColor', 'g', 'LineWidth', 2)
cen = stats(i).Centroid;
text(cen(1), cen(2), num2str(i), 'Color', 'r');
title(sprintf('total number is %d', length(stats)));
  1 Comment
Keane Athallah
Keane Athallah on 20 May 2022
thank you so much

Sign in to comment.

More Answers (0)


Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!