![screenshot.jpg](https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/34767/versions/3/screenshot.jpg)
How to create a circles (smallest and biggest circle) based on points in an image given, then find the center and radius?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jafar Nur Arafah
el 15 de En. de 2019
Comentada: Jafar Nur Arafah
el 16 de En. de 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
![test.GIF](https://www.mathworks.com/matlabcentral/answers/uploaded_files/200746/test.gif)
2. Example of circles need to be done
![example.GIF](https://www.mathworks.com/matlabcentral/answers/uploaded_files/200747/example.gif)
Any help will be appreciated.
Thanks in advance
0 comentarios
Respuesta aceptada
Image Analyst
el 15 de En. de 2019
To get the minimal bounding outer circle, try this:
![screenshot.jpg](https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/34767/versions/3/screenshot.jpg)
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 comentarios
Más respuestas (1)
KSSV
el 15 de En. de 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 comentarios
KSSV
el 15 de En. de 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
el 16 de En. de 2019
Editada: Image Analyst
el 16 de En. de 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).
Ver también
Categorías
Más información sobre Polar Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!