How to create a circles (smallest and biggest circle) based on points in an image given, then find the center and radius?
11 views (last 30 days)
Show older comments
Jafar Nur Arafah
on 15 Jan 2019
Commented: Jafar Nur Arafah
on 16 Jan 2019
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 Comments
Accepted Answer
Image Analyst
on 15 Jan 2019
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 Comments
More Answers (1)
KSSV
on 15 Jan 2019
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 Comments
KSSV
on 15 Jan 2019
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
on 16 Jan 2019
Edited: Image Analyst
on 16 Jan 2019
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).
See Also
Categories
Find more on Feature Detection and Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!