M-File Help: ransac | View code for ransac |
Random sample and consensus
m = ransac(func, x, T, options) is the ransac algorithm that robustly fits data x to the model represented by the function func. ransac classifies Points that support the model as inliers and those that do not as outliers.
x typically contains corresponding point data, one column per point pair. ransac determines the subset of points (inliers) that best fit the model described by the function func and the parameter m. T is a threshold on how well a point fits the estimated, if the fit residual is aboe the the threshold the point is considered an outlier.
[m,in] = ransac(func, x, T, options) as above but returns the vector in of column indices of x that describe the inlier point set.
[m,in,resid] = ransac(func, x, T, options) as above but returns the final residual of applying func to the inlier set.
'maxTrials', N | maximum number of iterations (default 2000) |
'maxDataTrials', N | maximum number of attempts to select a non-degenerate data set (default 100) |
out = func(R) is the function passed to RANSAC and it must accept a single argument R which is a structure:
R.cmd | the operation to perform which is either (string) |
R.debug | display what's going on (logical) |
R.X | data to work on, N point pairs (6xN) |
R.t | threshold (1x1) |
R.theta | estimated quantity to test (3x3) |
R.misc | private data (cell array) |
The function return value is also a structure:
OUT.s | sample size (1x1) |
OUT.X | conditioned data (2DxN) |
OUT.misc | private data (cell array) |
OUT.inlier | list of inliers (1xM) |
OUT.valid | if data is valid for estimation (logical) |
OUT.theta | estimated quantity (3x3) |
OUT.resid | model fit residual (1x1) |
The values of R.cmd are:
'size' | OUT.s is the minimum number of points required to compute an estimate to OUT.s |
'condition' | OUT.x = CONDITION(R.X) condition the point data |
'decondition' | OUT.theta = DECONDITION(R.theta) decondition the estimated model data |
'valid' | OUT.valid is true if a set of points is not degenerate, that is they will produce a model. This is used to discard random samples that do not result in useful models. |
'estimate' | [OUT.theta,OUT.resid] = EST(R.X) returns the best fit model and residual for the subset of points R.X. If this function cannot fit a model then OUT.theta = []. If multiple models are found OUT.theta is a cell array. |
'error' | [OUT.inlier,OUT.theta] = ERR(R.theta,R.X,T) evaluates the distance from the model(s) R.theta to the points R.X and returns the best model OUT.theta and the subset of R.X that best supports (most inliers) that model. |
Peter Kovesi School of Computer Science & Software Engineering The University of Western Australia pk at csse uwa edu au http://www.csse.uwa.edu.au/~pk
© 1990-2012 Peter Corke.