circle fitting

7 views (last 30 days)
Khawaja Asim
Khawaja Asim on 1 Mar 2012
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?

Accepted Answer

Walter Roberson
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
Khawaja Asim
Khawaja Asim on 2 Mar 2012
Thank you for your help. I think image analyst is right. May I send u both few images. After seeing images, suggest something, or do that for me?
Image Analyst
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

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 1 Mar 2012
  3 Comments
Khawaja Asim
Khawaja Asim on 2 Mar 2012
One thing that I have forgot to mention that, these points may not be evenly distributed. They may form an arc, or more maximum number of points can gather on one side, will it work on that also???
Image Analyst
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!