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).
참고 항목
카테고리
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!