circle fitting
7 views (last 30 days)
Show older comments
I have a binary image. This image contains white points randomly a ranged inside a region of interest. I want to draw a circle that can include all these points inside it. Means that I want to write a code that detect all these active points automatically and draw a circle in such a way that all the active (white) points come inside this circle. And outer most white point become a part of the boundary of circle. Can anyone help me in that?
0 Comments
Accepted Answer
Walter Roberson
on 1 Mar 2012
regionprops() the binary image, asking for Centroid and ConvexHull.
The center of the circle will be the centroid.
The ConvexHull will be an N x 2 array of x+y points. The point in that list that is furthest from the centroid will be the point that must be passed through; i.e., that maximum distances will be the radius of the circle.
You could also use the PixelIDList instead of the ConvexHull; it just gives you more points whose distance would have to be calculated.
3 Comments
Image Analyst
on 2 Mar 2012
Then don't accept the answer yet. We don't take personal emails - virtually no one here does. You can post your pictures to tinypic.com, or check here: http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
More Answers (1)
Image Analyst
on 1 Mar 2012
3 Comments
Image Analyst
on 2 Mar 2012
Neither Walter's nor John's solution will work if you have a random smattering of dots along the top of an arc. In that case you'd have to do a fit. Apparently that's complicated. I have a paper or reference to fitting a circle that I'll try to look up later for you.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!