![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 ビュー (過去 30 日間)
古いコメントを表示
Jafar Nur Arafah
2019 年 1 月 15 日
コメント済み: Jafar Nur Arafah
2019 年 1 月 16 日
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 件のコメント
採用された回答
Image Analyst
2019 年 1 月 15 日
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 件のコメント
その他の回答 (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).
参考
カテゴリ
Help Center および File Exchange で Polar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!