473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Ellipse fitting in python?

Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.

Thanks!

Ron
Jul 18 '05 #1
6 6613
on********@hotmail.com (Ron Kneusel) writes:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


This is a set of points with some noise (scatter), right?

A not-very-thoughtful answer: a sledgehammer method is to throw an
implementation of a standard nonlinear least-squares algorithm at the
problem. For example, SciPy contains a wrapper of MINPACK's nonlinear
LS solver . There are several implementations of the same
(Levenburg-Marquardt) algorithm in pure Python floating around, too.

If there's no scatter, it's time to dig out your old algebra textbooks
:-)
John
Jul 18 '05 #2
John J. Lee wrote:
on********@obvious.com (Ron Kneusel) writes:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


This is a set of points with some noise (scatter), right?

A not-very-thoughtful answer: a sledgehammer method is to throw an
implementation of a standard nonlinear least-squares algorithm at the
problem. For example, SciPy contains a wrapper of MINPACK's nonlinear
LS solver . There are several implementations of the same
(Levenburg-Marquardt) algorithm in pure Python floating around, too.


A quick comment in case it's not obvious: an ellipse is not a function in
Cartesian coordinates, and most standard LS solvers expect a function. So
it's probably best to convert things over to polar before feeding the data to
the LS solver.

f
Jul 18 '05 #3
Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


It's not so easy; it's a nonlinear orthogonal distance regression problem.
I know of a FORTRAN package and I myself have a (more general) package written
in Scilab ( a Matlab "clone" )

If you have just a few datasets, I'll compute a fit for you.
But implementing it in Python would be much work.
--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jul 18 '05 #4
Aloha,

Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


See http://www.magic-software.com/Approximation.html
Here are C++ Sources, you will need a interface like SWIG for using this
in python.

Wishing a happy day
LOBI
Jul 18 '05 #5
On Wed, 14 Jul 2004, Fernando Perez wrote:
A quick comment in case it's not obvious: an ellipse is not a function in
Cartesian coordinates, and most standard LS solvers expect a function. So
it's probably best to convert things over to polar before feeding the data to
the LS solver.


You could break both the ellipse and the data into two pieces (say, y>=K
and y<K). Polar coordinates might get you more uniform results, though.

Jul 18 '05 #6
Helmut Jarausch wrote:
Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.

It's not so easy; it's a nonlinear orthogonal distance regression problem.
I know of a FORTRAN package and I myself have a (more general) package
written
in Scilab ( a Matlab "clone" )


I wrote a wrapper to the FORTRAN ODRPACK.

http://starship.python.net/crew/kern...odr-0.6.tar.gz
If you have just a few datasets, I'll compute a fit for you.
But implementing it in Python would be much work.

Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Grant Edwards | last post by:
I'm looking for a surface fitting library for Python. Something like the least-squares module in scientific python, except I want to fit a surface (z = f(x,y)) instead of a curve (y = f(x)). ...
5
by: lgeastwood | last post by:
I have tweaked the PictureBox97.mdb (Stephen Lebans <www.lebans.com>) code to nicely draw lines, rectangles and circles to the specs that I input. I'm at a loss though with trying to setup an...
11
by: Christopher Ireland | last post by:
Hello! Using the definition for en ellipse (http://en.wikipedia.org/wiki/Ellipse) I can draw an arc of points. However, the end points of this arc do not coincide with the end points of an arc...
2
by: weird0 | last post by:
I wanted to draw an ellipse using c# with System.Drawing.Graphics. I tried out several tutorials and none of them worked and there seems to be something missing. One did execute without any errors...
3
by: illusion.admins | last post by:
I am trying to code something to tell me if a selected point is in a particular ellipse. For the ellipse I know how it was constructed (know the x,y, and width, height). But if I just check to see...
1
by: PankajGaur | last post by:
Hi, I need to create a Ellipse shaped user control which have folloiwng attributes: 1) The edges are smooth 2) The control shuld only be selected when click on the ellipse shape & not when...
8
by: =?Utf-8?B?RGFu?= | last post by:
I would like to draw an ellipse on a windows form and through mouse drags stretch, rotate and relocate the ellipse. Thanks in advance - Dan
0
by: =?Utf-8?B?UGFua2FqR2F1cg==?= | last post by:
Hi, I need to create a Ellipse shaped user control which have folloiwng attributes: 1) The edges are smooth 2) The control shuld only be selected when click on the ellipse shape & not when...
4
by: Evelien | last post by:
Dear python-users, I am trying to do a non-linear least squares fitting. Maybe trying is not the best word, as I already succeeded in that. At the moment I am using leastSquaresFit from...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.