How can you find circular blobs in an image?

I am trying to find certain parts of an image, and so used the Canny edge detector. Now I want to get rid of all the edges that are not vaguely circular in shape. How can I remove them?
This is a sample image that I am trying to search.

 Accepted Answer

What if the blob is shaped like a C or a G? Is that roughly circular? If so, you'll need to call bwconvhull() first. If not, you can look at the ration of perimeters square to areas
measurements = regionprops(binaryImage, 'Area', 'Perimeter');
allAreas = [measurements.Area];
allPerimeters = [measurements.Perimeter];
circularities = 4*pi*allAreas ./ allPerimeters^2;
round objects will have circularity values more than around 0.8 or so, or whatever value you want to go with.

6 Comments

Will this give me the values individually for each blob, or will it give me an average?
circularities is an array with each element being the circularity of the blob having that index. Does that answer your question? Now, how about answering mine?
Thank you so much! In answering your question, the blobs may be C's or G's, as long as the blobs are roughly circular.
Then you'll want to call
binaryImage = bwconvhull(binaryImage, 'objects');
to turn the C an G into solid round blobs. Otherwise they're considered wavy stick-like objects and won't have a circularity close to 1.
The values I am receiving are all greater than one. Is that a problem?
If the blobs are all round, it might happen that some values are more than 1. If they are stick-like then the values should be low, like around 0 to 0.6 or so. I actually made a mistake and forgot to square the perimeter. I've now corrected it and the correct equation is also below:
circularities = 4*pi*allAreas ./ allPerimeters^2;

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!