Count objects labeled in image

2 ビュー (過去 30 日間)
Tu Nguyen
Tu Nguyen 2022 年 4 月 14 日
編集済み: Image Analyst 2022 年 4 月 16 日
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

採用された回答

Image Analyst
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
  2 件のコメント
Image Analyst
Image Analyst 2022 年 4 月 16 日
For what it's worth, I'm attaching my shape recognition demos.
Tu Nguyen
Tu Nguyen 2022 年 4 月 16 日
I tried your way but all value less than 1.5. Now I am trying both ways to figure out. The method of @Faraz Hedayati I am struggling how to convert the out last output image to an actual image because the spot on the image just a plot.

サインインしてコメントする。

その他の回答 (1 件)

Tala
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 件のコメント
Tu Nguyen
Tu Nguyen 2022 年 4 月 16 日
Hi @Faraz Hedayati, how can I process the image with the plot on it? I make the image gray but it backs to initial image without the marked circle
Tala
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 ExchangeImage Segmentation and Analysis についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by