RANSAC消除SIFT错配

来源:互联网 发布:淘宝登录优酷会员 编辑:程序博客网 时间:2024/05/22 01:27

RANSAC消除SIFT错配

RANSAC为RANdom SAmple Consensus的缩写,它是根据一组包含异常数据的样本数据集,计算出数据的数学模型参数,得到有效样本数据的算法。它于1981年由 Fischler和Bolles最先提出[1]。
RANSAC算法的基本假设是样本中包含正确数据(inliers,可以被模型描述的数据),也包含异常数据(Outliers,偏离正常范 围很远、无法适应数学模型的数据),即数据集中含有噪声。这些异常数据可能是由于错误的测量、错误的假设、错误的计算等产生的。同时RANSAC也假设, 给定一组正确的数据,存在可以计算出符合这些数据的模型参数的方法。

RANSAC基本思想描述如下:
①考虑一个最小抽样集的势为n的模型(n为初始化模型参数所需的最小样本数)和一个样本集P,集合P的样本数num(P)>n,从P中随机 抽取包含n个样本的P的子集S初始化模型M;
②余集SC=P\S中与模型M的误差小于某一设定阈值t的样本集以及S构成S*。S*认为是内点集,它们构成S的一致集(Consensus Set);
③若#(S*)≥N,认为得到正确的模型参数,并利用集S*(内点inliers)采用最小二乘等方法重新计算新的模型M*;重新随机抽取新 的S,重复以上过程。
④在完成一定的抽样次数后,若为找到一致集则算法失败,否则选取抽样后得到的最大一致集判断内外点,算法结束。
由上可知存在两个可能的算法优化策略。①如果在选取子集S时可以根据某些已知的样本特性等采用特定的选取方案或有约束的随机选取来代替原来的 完全随机选取;②当通过一致集S*计算出模型M*后,可以将P中所有与模型M*的误差小于t的样本加入S*,然后重新计算M*。
RANSAC算法包括了3个输入的参数:①判断样本是否满足模型的误差容忍度t。t可以看作为对内点噪声均方差的假设,对于不同的输入数据需 要采用人工干预的方式预设合适的门限,且该参数对RANSAC性能有很大的影响;②随机抽取样本集S的次数。该参数直接影响SC中样本参与模型参数的检验 次数,从而影响算法的效率,因为大部分随机抽样都受到外点的影响;③表征得到正确模型时,一致集S*的大小N。为了确保得到表征数据集P的正确模型,一般 要求一致集足够大;另外,足够多的一致样本使得重新估计的模型参数更精确。
RANSAC算法经常用于计算机视觉中。例如,在立体视觉领域中同时解决一对相机的匹配点问题及基本矩阵的计算。

其伪代码如下

input:    data - a set of observations    model - a model that can be fitted to data     n - the minimum number of data required to fit the model    k - the number of iterations performed by the algorithm    t - a threshold value for determining when a datum fits a model    d - the number of close data values required to assert that a model fits well to dataoutput:    best_model - model parameters which best fit the data (or nil if no good model is found)    best_consensus_set - data point from which this model has been estimated    best_error - the error of this model relative to the data iterations := 0best_model := nilbest_consensus_set := nilbest_error := infinitywhile iterations < k     maybe_inliers := n randomly selected values from data    maybe_model := model parameters fitted to maybe_inliers    consensus_set := maybe_inliers    for every point in data not in maybe_inliers         if point fits maybe_model with an error smaller than t            add point to consensus_set        if the number of elements in consensus_set is > d         (this implies that we may have found a good model,        now test how good it is)        this_model := model parameters fitted to all points in consensus_set        this_error := a measure of how well better_model fits these points        if this_error < best_error            (we have found a model which is better than any of the previous ones,            keep it until a better one is found)            best_model := this_model            best_consensus_set := consensus_set            best_error := this_error         increment iterationsreturn best_model, best_consensus_set, best_error


原创粉丝点击