bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / measure / fit / EllipseModel
class
skimage.measure.fit:EllipseModel
source: /dev/scikit-image/src/skimage/measure/fit.py :715
Signature
class EllipseModel ( center , axis_lengths , theta ) Members
-
_args_init -
_check_init_values -
_estimate -
_params2init_values -
estimate -
from_estimate -
predict_xy -
residuals
Summary
Total least squares estimator for 2D ellipses.
Extended Summary
The functional model of the ellipse is
xt = xc + a*cos(theta)*cos(t) - b*sin(theta)*sin(t) yt = yc + a*sin(theta)*cos(t) + b*cos(theta)*sin(t) d = sqrt((x - xt)**2 + (y - yt)**2)
where (xt, yt) is the closest point on the ellipse to (x, y). Thus d is the shortest distance from the point to the ellipse.
The estimator is based on a least squares minimization. The optimal solution is computed directly, no iterations are required. This leads to a simple, stable and robust fitting method.
Parameters
center: array_like of shape (2,)Coordinates of ellipse center.
axis_lengths: array_like of shape (2,)Length of first axis and length of second axis. Call these
aandb.theta: floatAngle of first axis.
Raises
: ValueErrorIf
centerdoes not have length 2.
Examples
em = EllipseModel((10, 15), (8, 4), np.deg2rad(30)) xy = em.predict_xy(np.linspace(0, 2 * np.pi, 25)) ellipse = EllipseModel.from_estimate(xy) ellipse.center ellipse.axis_lengths✓
round(ellipse.theta, 2)
✗np.round(abs(ellipse.residuals(xy)), 5)
✓if ellipse: print("Estimation succeeded.") bad_data = np.ones((4, 2)) bad_ellipse = EllipseModel.from_estimate(bad_data) if not bad_ellipse: print("Estimation failed.")✓
bad_ellipse.residuals(xy) # doctest: +IGNORE_EXCEPTION_DETAIL
✓Aliases
-
skimage.measure.EllipseModel