Count objects labeled in image
古いコメントを表示
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
採用された回答
その他の回答 (1 件)
Tala
2022 年 4 月 15 日
0 投票
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
2022 年 4 月 16 日
Tala
2022 年 4 月 16 日
please attach your image with the centroids as black cricles.
In your original question you highlighted the centroids of rectangulars. In the second image you have the centoirds of circles and rectangulars, and some objects have two centroids.
back to your original question, whatever technique you used yo find the centroid of rectangulars, change your plot option to filled circles to get this (I call this image I):

Ig=rgb2gray(I);
BW=Ig<15;
imshow(BW)

info=regionprops(BW,'Centroid');
length(info)
which spits out 13
Tu Nguyen
2022 年 4 月 16 日
Image Analyst
2022 年 4 月 16 日
Not sure what you want. In Faraz's last image the circles were white. If you made them black, the whole image would be black. Or do you want to fill the original image's black dots with the surrounding color, like what you'd to with regionfill()?
Did you see my Answer below?
instead of
plot(centroid(1),centroid(2),'ko');
use a dot as your marker with large size.
plot(centroid(1),centroid(2),'.k', 'MarkerSize',25)
Tu Nguyen
2022 年 4 月 16 日
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')
カテゴリ
ヘルプ センター および File Exchange で Image Category Classification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!