Copyright (c) 1981, Izhak Bucher
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Scott (view profile)
Sorry, I still have it wrong---xe is "x" in the typical way the general equation for a circle is expressed, not R*cos(th). Thus "xe-xc=Rcos(th)", and "ye-yc=Rsin(th)".
Scott (view profile)
tejas harish: Might be too late to answer your question; perhaps others would like to know the answer to your question. The general equation for a circle in the x-y plane is "(x-xc)^2+(y-yc)^2=R^2". In cylindrical coordinates, a circle is defined by "x-xc=R*cos(th)" and "y-yc=R*sin(th)". Thus "th" is the angle "theta", "R" is the circle radius, "xe" and "ye" are the shifted coordinates, "xe==x-xc" and "ye=y-yc" so that it is equivalent to say "(x-xc)^2+(y-yc)^2=R^2" OR "(xe)^2+(ye)^2=R^2." "sigma" is simply a scaling parameter--note the "x" and "y" variables, which are the coordinates of the points on the circle, have noise added to them--sigma merely scales the noise.
Scott (view profile)
My apologies, I made a small mistake which I can't figure out how to correct by editing my original post. The 2nd equation should say: This function fits the equation for a circle, (x-xc)^2+(y-yc)^2=R^2. In cylindrical coordinates, a circle is defined by "x-xc=R*cos(th)" and "y-yc=R*sin(th)".
Marlin Baidillah (view profile)
ahmet dogrusadik (view profile)
Xin (view profile)
tejas harish (view profile)
can anyone please tell what is significance of variables th,R,xe and sigma in the circlefit code?
Daniel Golden (view profile)
Yasmine (view profile)
Hi,
Does anyone know how to calculate deviation from circularity of the measured points compared to the fitted circle using this code?
SengChoy Liew (view profile)
I have come to a death end in Image processing toolbox to evaluate the circles in a gray scale image.
Anyone how how to use the codes given to fit into those circles in the image so that an histogram for the distribution of circles diameter can be plot ?
Nikolai Chernov (view profile)
This circle fit has been first published by P.Delogne and I.Kasa in the 1970s and is known as "Kasa method" in statistics. It works well when points cover a large part of the circle but is heavily biased when points are restricted to a small arc. Better fits were proposed by Pratt and Taubin.
Works like a charm :-)
Works very well!
I don't really know how, but it works! :D
You saved me a bunch of hours there.
Thank you very much!
Note: This code doesn't minimise the sum of squared radial deviations - that is a nonlinear least squares problem
This code minimises sum((x.^2 + y.^2 - R^2).^2)
Just... Excellent.. thanks.
:-)
I found it to be very effective.
Re: Hedi Kawano
see also
http://www.pitchup.com/matlab/print.aspx?article=168
High-quality code, simple and effective
Very useful if you need to fit measured points to the circle function and compare it further to reference value.
Sorry, it is
http://www.math.niu.edu/~rusin/known-math/99/circlefit
(last "t" was missing)
http://www.math.niu.edu/~rusin/known-math/99/circlefi tells you that the equation used in this "circle_fit.m" gives an approximate solution.
Nice tool for data covering almost a complete circle. But if data exists describing only an arc, circfit fails identifying the assumed center and radius.
I have used this function to verify a feature in a Metrology software giving correctly first 4 digits, so it seems OK
Yuri,
It can be extremely useful. For example, trying to fit a nyquist plot to an experimentally acquired FRFs... Ideally, nyquist plot is supposed to be a circle, but is not due 'noise'
Can someone please enlighten me where one meets such distributions to be fitted by a circle ?