Count objects labeled in image
3 次查看(过去 30 天)
显示 更早的评论
Hi all,
I identified circles and rectangular by a mark circle at centroid. Now I want to count how many object have labeled and how many object not labeled?
The result is in the attached image
Really appreciate for your help
if metric < threshold
centroid = stats(k).Centroid;
plot(centroid(1),centroid(2),'ko');
count =
end
0 个评论
采纳的回答
Image Analyst
2022-4-16
stats = regionprops(L,'Area','Centroid','Perimeter');
allAreas = [stats.Area]
allPerims = [stats.Perimeter];
allCircularities = allPerims .^2 ./ (4 * pi * allAreas)
% Find number with circularity more than 1.5
count = allCircularities > 1.5
更多回答(1 个)
Tala
2022-4-15
I would plot the centroids as filled black circles and threshold colors smaller than 10! then you only have the centorids and length(regionprops( YourImage,'centroid')) would give you the number of rectangulars.
9 个评论
Tala
2022-4-16
编辑:Image Analyst
2022-4-16
I am getting confused about you wanna do after all :).
Did you see Image Analyst's response?
If you want to save your figure as an image you can do:
saveas(gcf,'YourImage.png');
% or
exportgraphics(gcf, 'YourImage.png');
You can then import that as well using
theImage = imread('YourImage.png')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!