i have to apply RANSAC algorithm on an image toget the best fit in license plate detection. how can it be possible?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function [bestModel,bestInliers,bestOutliers,bestError] = ransac(thresError,N,d,iterations)
syms inliers outliers ni no;
% model
bestModel = [];
bestInliers = [];
bestOutliers = [];
bestError = inf;
reply = input('Random generation (1) or input data (2)?\n');
if (reply == 1)
data= rand(2,N);
else
data = input('Enter the data matrix in 2xN format.\n');
end
for i=1:iterations
randomP = randperm(N);
p1 = [ data(1,randomP(1)), data(2,randomP(1)) ];
p2 = [ data(1,randomP(2)), data(2,randomP(2)) ];
inliers = [];
outliers = [];
ni = 0;
no = 0;
a_model = ( p1(2) - p2(2) )/ ( p1(1) - p2(1) );
b_model = p1(2) - a_model*p1(1);
totalError = 0;
for p=1:N
point = data(:,p);
error = abs( data(1,p)*a_model + b_model - data(2,p) )/ sqrt( a_model^2 + 1);
if( thresError < error )
outliers(:,no+1) = point;
no = no+1;
else
totalError = totalError + error;
inliers(:,ni+1) = point;
ni = ni+1;
end
end % data iteration end
% check model
if ( bestError > totalError && d < ni )
bestModel = [a_model,b_model];
bestInliers = inliers;
bestOutliers = outliers;
bestError = totalError;
end
end % main iteration end
return;
1 Kommentar
ezhil K
am 21 Jan. 2019
Even I have the same doubt.If you get a solution please share it with me.Plz
Antworten (0)
Siehe auch
Kategorien
Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!