- Binarize the image so that it's logical. binaryImage = grayImage > 128
- Call binaryImage = imclearborder(binaryImage) to get rid of the single line around the perimeter.
- Invert the image: binaryImage = ~binaryImage, so now black circles are white
- Call binaryImage = imclearborder(binaryImage) to get rid of the large (now white) background
- Call bwlabel: [labeledImage, numberOfCircles] = bwlabel(binaryImage). This gives you the count.
- Call measurements = regionprops(labeledImage) if you want other measurements
Counting objects in an image
55 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
subrajeet
le 7 Jan 2013
Commenté : Beenish Ishtiaq
le 5 Août 2021
Dear Researchers, I have a problem of counting objects in an image. Suppose I have the below image (below link)
which i got after segmentation.
how can I count the small circles in the middle of the image. Kindly suggest
Subrajeet
0 commentaires
Réponse acceptée
Image Analyst
le 7 Jan 2013
Modifié(e) : Image Analyst
le 7 Jan 2013
2 commentaires
Image Analyst
le 7 Jan 2013
Modifié(e) : Image Analyst
le 7 Jan 2013
It's just basic, elementary image segmentation via intensity thresholding. Nothing fancy at all. See updated instructions above.
Plus de réponses (3)
Thomas
le 7 Jan 2013
Modifié(e) : John Kelly
le 8 Nov 2017
You could use techniques shown in many MATLAB image processing demos.
SANAHA PATHAN
le 25 Juil 2016
i want to count number of silkworm eggs from this figure, i used L=Count(binaryfig) this command for counting number of objects ,this command works but i actually dont know what actually this command count,and result of this command is different every time
3 commentaires
anna
le 5 Oct 2016
Modifié(e) : anna
le 5 Oct 2016
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/184885/image.jpeg)
hey I segmented blue nuclei from a blood smear image using k means color segmentation. how can i count the number of segmented blue nuclei. could u please help me with the code for counting [ cant use imfindcircle because the segmented nuclei are not exactly cirlce in shape ]
Image Analyst
le 8 Oct 2016
Beenish Ishtiaq
le 3 Août 2021
Need code for counting different shapes separatelly which shows each shape result respectively in different edit boxes in GUI matlab..
2 commentaires
Image Analyst
le 3 Août 2021
See my attached demos. I find that usually using findpeaks() to count the number of peaks in the plot of distance of perimeter from centroid works pretty well.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!