ellipsemodel

EllipseModel

class skimage.measure.EllipseModel [source]

Bases: skimage.measure.fit.BaseModel

Total least squares estimator for 2D ellipses.

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.

This estimator minimizes the squared distances from all points to the ellipse:

min{ sum(d_i**2) } = min{ sum((x_i - xt)**2 + (y_i - yt)**2) }

Thus you have 2 * N equations (x_i, y_i) for N + 5 unknowns (t_i, xc, yc, a, b, theta), which gives you an effective redundancy of N - 5.

The params attribute contains the parameters in the following order:

xc, yc, a, b, theta

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

Attributes

params (tuple) Ellipse model parameters in the following order xc, yc, a, b, theta.
__init__() [source]
estimate(data) [source]

Estimate circle model from data using total least squares.

Parameters:

data : (N, 2) array

N points with (x, y) coordinates, respectively.

Returns:

success : bool

True, if model estimation succeeds.

predict_xy(t, params=None) [source]

Predict x- and y-coordinates using the estimated model.

Parameters:

t : array

Angles in circle in radians. Angles start to count from positive x-axis to positive y-axis in a right-handed system.

params : (5, ) array, optional

Optional custom parameter set.

Returns:

xy : (..., 2) array

Predicted x- and y-coordinates.

residuals(data) [source]

Determine residuals of data to model.

For each point the shortest distance to the ellipse is returned.

Parameters:

data : (N, 2) array

N points with (x, y) coordinates, respectively.

Returns:

residuals : (N, ) array

Residual for each data point.

doc_scikit_image
2017-01-12 17:20:51
Comments
Leave a Comment

Please login to continue.