- 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
475 views (last 30 days)
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
Image Analyst on 7 Jan 2013
Edited: Image Analyst on 7 Jan 2013
See my Image Segmentation Tutorial in my File Exchange if you want an example.