MATLAB: How to count number of circles of a gray scale image

circle countImage Processing Toolbox

I want to count number of circles of a gray scale image. I have attached the sample image. I just want to count the number of circle of that image and fill the gaps of that circle. What should i do??

Best Answer

How many do you see? I see two circular black discs plus a bunch of other blobs that have irregular shapes, though some parts of their perimeters are circular.
Then you can count them with bwlabel();
[~, NumBlobs] = bwlabel(binaryImage);
Another way is to use regionprops() to compute the area and perimeter of the blobs and compute the circularity and keep only blobs that are sufficiently close to being circular.
I can't do it all for you but if you have questions, attach whatever code you have.