{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / measure / fit / CircleModel

class

skimage.measure.fit:CircleModel

source: /dev/scikit-image/src/skimage/measure/fit.py :457

Signature

class   CircleModel ( center radius )

Members

Summary

Total least squares estimator for 2D circles.

Extended Summary

The functional model of the circle is

r**2 = (x - xc)**2 + (y - yc)**2

This estimator minimizes the squared distances from all points to the circle

min{ sum((r - sqrt((x_i - xc)**2 + (y_i - yc)**2))**2) }

A minimum number of 3 points is required to solve for the parameters.

Parameters

center : array-like, shape (2,)

Coordinates of circle center.

radius : float

Circle radius.

Raises

: ValueError

If center does not have length 2.

Notes

The estimation is carried out using a 2D version of the spherical estimation given in [1].

Examples

t = np.linspace(0, 2 * np.pi, 25)
xy = CircleModel((2, 3), 4).predict_xy(t)
model = CircleModel.from_estimate(xy)
model.center
model.radius
res = model.residuals(xy)
np.abs(np.round(res, 9))
The estimation can fail when — for example — all the input or output points are the same. If this happens, you will get a transform that is not "truthy" - meaning that ``bool(tform)`` is ``False``:
if model:
    print("Estimation succeeded.")
bad_data = np.ones((4, 2))
bad_model = CircleModel.from_estimate(bad_data)
if not bad_model:
    print("Estimation failed.")
Trying to use this failed estimation transform result will give a suitable error:
bad_model.residuals(xy)  # doctest: +IGNORE_EXCEPTION_DETAIL

Aliases

  • skimage.measure.CircleModel