Count centroids in an image

Hey I have this binary image, with the centroids detetced but I need a way to count them so I get an output as number of characters is 7. I haven't been able to find a function or any way to do this. CountImage.jpg

5 件のコメント

Adam Danz
Adam Danz 2019 年 11 月 9 日
How are you plotting the blue * ?
Adam Kelly
Adam Kelly 2019 年 11 月 9 日
Using this;
s = regionprops(fill,'centroid');
centroids = cat(1,s.Centroid);
imshow(fill)
hold on
plot(centroids(:,1),centroids(:,2),'b*')
hold off
After I filled the image, thought it would be easier to count if I could label the centroids and then count the centroids but having trouble with that part.
darova
darova 2019 年 11 月 9 日
Only using 2 centoids? (1 and 2)?
plot(centroids(:,1),centroids(:,2),'b*')
Matt J
Matt J 2019 年 11 月 10 日
but I need a way to count them
Why not just
numel(s)
Adam Danz
Adam Danz 2019 年 11 月 10 日
@Adam Kelly, it looks like you've got several suggestions here. Let us know if you get stuck or if you're looking for something different.

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

回答 (1 件)

Arash Rabbani
Arash Rabbani 2019 年 11 月 10 日

1 投票

Why not simply label the binary image? and 'Num' would be the number of characters.
[Label, Num]=bwlabel(Image)

製品

リリース

R2019b

質問済み:

2019 年 11 月 9 日

コメント済み:

2019 年 11 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by