[SciPy-user] Fitting sphere to 3d data points
James Vincent
jjv5 at nih.gov
Thu Jan 25 08:47:25 CST 2007
David,
Thanks for the reply. I think I should have been clearer about the
problem. I have a surface patch of data points, not an actual whole
sphere. It will probably be a very small section of total sphere
surface. I would like to fit the sphere that best fits just those
points that I have. The center of the sphere will be highly dependent
on the curvature of the points.
I think the leastsq routine is right, I just can't figure out how
to pass the data in yet (it's my first work with scipy).
Jim
On Jan 25, 2007, at 9:31 AM, David Huard wrote:
> Hi James,
>
> As a first guess, I'd say the center of the sphere is simply the
> mean of your data points, if they're all weighted equally. With
> only one parameter left to fit, it should be easy enough. However,
> you may want to look at the paper:
>
> Werman, Michael and Keren, Daniel
> A Bayesian method for fitting parametric and nonparametric models
> to noisy data
> Ieee Transactions on Pattern Analysis and Machine Intelligence, 23,
> 2001.
>
> They write that the Mean Square Error approach overestimates the
> radius in the case of circles. They don't talk about the 3D case,
> but I'd guess similar problems arise. They provide a method to fit
> parametric shapes with some robustness to data errors.
>
> Cheers,
>
> David
>
>
>
> 2007/1/25, James Vincent <jjv5 at nih.gov>:
> Hello,
>
> Is it possible to fit a sphere to 3D data points using
> scipy.optimize.leastsq? I'd like to minimize the residual for the
> distance from the actual x,y,z point and the fitted sphere surface.
> I can see how to minimize for z, but that's not really what I'm
> looking for. Is there a better way to do this? Thanks for any help.
>
> params = a,b,c and r
> a,b,c are the fitted center point of the sphere, r is the radius
>
> err = distance-to-center - radius
> err = sqrt( x-a)**2 + (y-b)**2 + (z-c)**2) - r
>
>
>
> ----
> James J. Vincent, Ph.D.
> National Cancer Institute
> National Institutes of Health
> Laboratory of Molecular Biology
> Building 37, Room 5120
> 37 Convent Drive, MSC 4264
> Bethesda, MD 20892 USA
>
> 301-451-8755
> jjv5 at nih.gov
>
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
----
James J. Vincent, Ph.D.
National Cancer Institute
National Institutes of Health
Laboratory of Molecular Biology
Building 37, Room 5120
37 Convent Drive, MSC 4264
Bethesda, MD 20892 USA
301-451-8755
jjv5 at nih.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070125/dcf1b801/attachment.html
More information about the SciPy-user
mailing list