织梦CMS - 轻松建站从此开始!

罗索

SIFT特征点匹配与消除错配:BBF,RANSAC(2)

jackyhwei 发布于 2011-08-15 17:00 点击:次 
while iterations k // 进行 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
TAG:

while iterations < k //进行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 //错误小于阈值t
            add point to consensus_set  //成为同盟,加入consensus set
   
    if the number of elements in consensus_set is > d //同盟军已经大于d个人,够了
        (this implies that we may have found a good model,
        now test how good it is)
        better_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 := better_model
            best_consensus_set := consensus_set
            best_error := this_error
    increment iterations
 
return best_model, best_consensus_set, best_error
 
2.       RANSAC去除错配:
H = ransac_xform( feat1, n1, FEATURE_FWD_MATCH, lsq_homog, 4, 0.01,homog_xfer_err, 3.0, NULL, NULL );
     nm = get_matched_features( features, n, mtype, &matched );
     /* initialize random number generator */
     rng = gsl_rng_alloc( gsl_rng_mt19937 );
     gsl_rng_set( rng, time(NULL) );
 
     in_min = calc_min_inliers( nm, m, RANSAC_PROB_BAD_SUPP, p_badxform ); //符合这一要求的内点至少得有多少个
     p = pow( 1.0 - pow( in_frac, m ), k );
     i = 0;
     while( p > p_badxform )//p>0.01
     {
         sample = draw_ransac_sample( matched, nm, m, rng );
         extract_corresp_pts( sample, m, mtype, &pts, &mpts );
         M = xform_fn( pts, mpts, m );
         if( ! M )
              goto iteration_end;
         in = find_consensus( matched, nm, mtype, M, err_fn, err_tol, &consensus);
         if( in > in_max ) {
              if( consensus_max )
                   free( consensus_max );
              consensus_max = consensus;
              in_max = in;
              in_frac = (double)in_max / nm;
         }
         else
              free( consensus );
         cvReleaseMat( &M );
 
iteration_end:
         release_mem( pts, mpts, sample );
         p = pow( 1.0 - pow( in_frac, m ), ++k );
     }
     /* calculate final transform based on best consensus set */
     if( in_max >= in_min )
     {
         extract_corresp_pts( consensus_max, in_max, mtype, &pts, &mpts );
         M = xform_fn( pts, mpts, in_max );
         in = find_consensus( matched, nm, mtype, M, err_fn, err_tol, &consensus);
         cvReleaseMat( &M );
         release_mem( pts, mpts, consensus_max );
         extract_corresp_pts( consensus, in, mtype, &pts, &mpts );
         M = xform_fn( pts, mpts, in );      
思考中的一些问题:
features间的对应关系,记录在features->fwd_match里(matching feature from forward
imge)。
 
1.       数据是nm个特征点间的对应关系,由它们产生一个3*3变换矩阵(xform_fn = hsq_homog函数,此要>=4对的对应才可能计算出来咯~),此乃模型model
2.       然后开始找同盟军(find_consensus函数),判断除了sample的其它对应关系是否满足这个模型(err_fn = homog_xfer_err函数,<=err_tolOK~),满足则留下。
3.       一旦大于当前的in_max,那么该模型就升级为目前最牛的模型。(最最原始的RANSAC是按错误率最小走的,我们这会儿已经保证了错误率在err_tol范围内,按符合要求的对应数最大走,尽量多的特征能匹配地上)
4.       重复以上3步,直到(1-wm)k <=p_badxform (0.01),模型就算找定~
5.       最后再把模型和同盟军定一下,齐活儿~
 
声明:以上代码参考Rob HessSIFT实现。
 
(ijuliet)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201108/14854.html]
本文出处:blog.csdn.net/ijuliet 作者:ijuliet
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
相关文章
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容