EllipseFitter

class sonic.EllipseFitter

This software is made available under the MIT license. See SONIC/LICENSE for details.

Method Summary
static fitEllipse(ellipsePts, method_str)

Performs an ellipse fitting to (x,y) points, given a particular fitting method. Currently can perform least-squares, semi-hyper least squares and hyper least squares fits.

NOTE: Returns both implicit and explicit solutions, since at times the conic’s implicit solution won’t be stable enough to convert back to explicit solution without recentering

NOTE: The code in this work is largely based off of the following references:

  1. Kanatani, K., & Rangarajan, P. (2011). “Hyper least squares fitting of circles and ellipses.” Computational Statistics & Data Analysis, 55(6), 2197-2208.

  2. Krause, M., Price, J., & Christian, J. A., “Analytical Methods in Crater Rim Fitting and Pattern Recognition.” AAS/AIAA Astrodynamics Specialist Conference, Paper AAS 23-350, Big Sky, MT, 12-17 Aug 2023.

Inputs:
  • ellipsePts (sonic.Points2): X,Y vals of 2D points to fit

  • method_str (1x1 string): String specifying which type of ellipse fitting operation to perform. Can be ‘ls’ for least-squares, ‘shls’ for semi-hyper least squares, or ‘hls’ for hyper least squares

Outputs:
  • conicObj (1,1) sonic.Conic: conic object for solution

Last revised: Nov 15, 2024 Last author: Tara Mina

static getEllipseCovariance(conicObj, ellipsePts, sigsqrXY)

Compute analytical covariance of implicit solution for ellipse fitting.

Derivation of HLS covariance originally from Kanatani & Rangarajan (2011) and is also readily accessible in Krause, Price, & Christian (2023). This function uses the same notation as in Krause, et al. (2023).

NOTE: The choice of normalization factor, N, of the different ellipse fitting methods affects the bias of the implicit ellipse solution, but not the standard deviation. Thus, this same function can be used to compute the covariance for all ellipse fitting methods.

NOTE: This function implements Equation (45h) in Krause, et al. (2023). But, there are 2 typos:

  1. last term M_pseudoinverse should be transposed (though because M is symmetric, its pseudoinverse should also be symmetric)

  2. P_a should have a (1/n^2) factor multiplied to it (should also be in Eqs. 45 b-h), where n is number of point samples

Inputs:
  • conicObj (1x1 sonic.Conic): conic fit, as computed by a particular ellipse fitting method

  • ellipsePts (sonic.Points2): X,Y vals of 2D points on the edge of the ellipse, to fit

  • sigsqrXY – variance (squared std dev) of x and y coordinates (assumed that noise in 2D points are isometric)

Outputs:
  • Pa – covariance (6x6) of the implicit solution

Last revised: Sep 24, 2024 Last author: Tara Mina