Fitting a circle of known radius to a binary image
6 views (last 30 days)
Show older comments
Paolo Olson
on 15 Mar 2020
Commented: Paolo Olson
on 15 Mar 2020
I have some binary images to which I would like fit the largest possible circle.
The method I am currently thinking of using is finding the maximum radius using regionprops and fitting that max radius circle to the boundary pixels of the blobs (bwboundaries) (see picture below). I cannot use Hough as the circle all have different radius and often leads to a very noisy output. I have also tried using a least squares algorithm with no radial constraint, but the radius outputted is often to small.
Could someone help me implement something like this, but for matlab, point me to a suitable algorithm or give any better suggestions?
Many thanks :)

0 Comments
Accepted Answer
Image Analyst
on 15 Mar 2020
You can simply measure all the areas and equivalent circular diameters and you're pretty much done.
props = regionprops(mask, 'Area', 'EquivDiameter');
allAreas = [props.Area]
allDiameters = [props.EquivDiameter]
[largestArea, indexOfLargestArea] = max(allAreas)
largestDiameter = allDiameters(indexOfLargestArea)
The equivalent circular diameter is the diameter your blob would have as if all the pixels were rearranged into a perfectly circular shapte.
4 Comments
Image Analyst
on 15 Mar 2020
You might want to look at this:

Pass all the points from your blob into that function to get the outermost circle that will contain everything. But what if you have just some irregularly shaped blob, not like a perfect hemicircle or full circle? What if is just looks like an amorphous blob or splat? What outline would you want to use? Why not use the fitted circle? Or the convex hull? Do you know for a fact that your original objects are circles that have had a chord clipped off of them?
More Answers (0)
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!