What is the functionality of the distance evaluation function in the RANSAC MATLAB function?

7 views (last 30 days)
Dear all,
I have used the RANSAC Matlab function for computing inlier points of the data. Can anyone please tell me the functionality of "distFcn" in the input argument of ransac?
Is the functionality of the distance evaluation function is a euclidean distance?
The following things mentioned with the help of RANSAC.
[model,inlierIdx] = ransac(data,fitFcn,distFcn,sampleSize,maxDistance)
sampleSize = 2; % number of points to sample per trial
maxDistance = 2; % max allowable distance for inliers
fitLineFcn = @(points) polyfit(points(:,1),points(:,2),1); % fit function using polyfit
evalLineFcn = ... % distance evaluation function
@(model, points) sum((points(:, 2) - polyval(model, points(:,1))).^2,2);
[modelRANSAC, inlierIdx] = ransac(points,fitLineFcn,evalLineFcn, sampleSize,maxDistance);
distFcn — Function to compute distances from model:
Function to compute distances from the model to the data, specified as a function handle. The function must be of the form: distances = distFcn(model,data)
If model is an n-element array, then distances must be an m-by-n matrix. Otherwise, distances must be an m-by-1 vector.
Thanks & regards
Sukumar.

Accepted Answer

Walter Roberson
Walter Roberson on 13 Jul 2021
The function that you post uses Euclidean distance. The people who designed ransac did not want to restrict to Euclidean in case someone had a need for a different distance measure. See the documentation for pdist() for examples of other distance functions that are possible (in a general sense.)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!