
How to create a circles (smallest and biggest circle) based on points in an image given, then find the center and radius?
5 次查看(过去 30 天)
显示 更早的评论
Hi,
I have extract some points from Image Scanning, I need to create 2 circle (smallest circle and largest circle) in order to calculate the error of circularity (Rmax - Rmin), in order to do that I need to find the center and radius. Did any have done this kind of case?
Below are some image as reference:
- Points extract from image scanning

2. Example of circles need to be done

Any help will be appreciated.
Thanks in advance
0 个评论
采纳的回答
Image Analyst
2019-1-15
To get the minimal bounding outer circle, try this:

I asked John for the largest interior circle, and he said that's a much more difficult problem and he doesn't have code for that.
3 个评论
更多回答(1 个)
KSSV
2019-1-15
YOu can try to fit a circle with the coordinates (x,y) you have. Check the below code:
function [xc,yc,R,a] = circfit(x,y)
%CIRCFIT Fits a circle in x,y plane
%
% [XC, YC, R, A] = CIRCFIT(X,Y)
% Result is center point (yc,xc) and radius R. A is an optional
% output describing the circle's equation:
%
% x^2+y^2+a(1)*x+a(2)*y+a(3)=0
% by Bucher izhak 25/oct/1991
n=length(x); xx=x.*x; yy=y.*y; xy=x.*y;
A=[sum(x) sum(y) n;sum(xy) sum(yy) sum(y);sum(xx) sum(xy) sum(x)];
B=[-sum(xx+yy) ; -sum(xx.*y+yy.*y) ; -sum(xx.*x+xy.*y)];
a=A\B;
xc = -.5*a(1);
yc = -.5*a(2);
R = sqrt((a(1)^2+a(2)^2)/4-a(3));
3 个评论
KSSV
2019-1-15
Ou are running the code in a wrong way...you have to save the above code into a function and call the function.
Image Analyst
2019-1-16
编辑:Image Analyst
2019-1-16
This fits a circle through the data, which could be part of the solution, but it does not find the max bounding circle (like my Answer).
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


