Ellipse fitting in python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ron Kneusel

    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
  • John J. Lee

    #2
    Re: Ellipse fitting in python?

    oneelkruns@hotm ail.com (Ron Kneusel) writes:
    [color=blue]
    > 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.[/color]

    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

    Comment

    • Fernando Perez

      #3
      Re: Ellipse fitting in python?

      John J. Lee wrote:
      [color=blue]
      > oneelkruns@obvi ous.com (Ron Kneusel) writes:
      >[color=green]
      >> 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.[/color]
      >
      > 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.[/color]

      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

      Comment

      • Helmut Jarausch

        #4
        Re: Ellipse fitting in python?

        Ron Kneusel wrote:[color=blue]
        > 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.
        >[/color]

        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

        Comment

        • Andreas Lobinger

          #5
          Re: Ellipse fitting in python?

          Aloha,

          Ron Kneusel wrote:[color=blue]
          > 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.[/color]

          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

          Comment

          • Christopher T King

            #6
            Re: Ellipse fitting in python?

            On Wed, 14 Jul 2004, Fernando Perez wrote:
            [color=blue]
            > 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.[/color]

            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.

            Comment

            • Robert Kern

              #7
              Re: Ellipse fitting in python?

              Helmut Jarausch wrote:[color=blue]
              > Ron Kneusel wrote:
              >[color=green]
              >> 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.
              >>[/color]
              >
              > 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" )[/color]

              I wrote a wrapper to the FORTRAN ODRPACK.


              [color=blue]
              > If you have just a few datasets, I'll compute a fit for you.
              > But implementing it in Python would be much work.[/color]

              Comment

              Working...