【问题标题】:How to perform matching by MSER and HOG in Matlab如何在 Matlab 中通过 MSER 和 HOG 执行匹配
【发布时间】:2012-12-05 04:46:00
【问题描述】:

我想知道 MSER 和 HOG 在 Matlab 中是否有完整的图像匹配实现。目前我正在使用VLFeat,但在执行图像匹配时遇到了困难。有什么帮助吗?

顺便说一句,我在 VLFeat -Matlab 环境中尝试了以下代码,但不幸的是无法执行匹配。

%Matlab code
%
pfx = fullfile(vl_root,'figures','demo') ;
randn('state',0) ;
rand('state',0) ;
figure(1) ; clf ;

Ia = imread(fullfile(vl_root,'data','roofs1.jpg')) ;
Ib = imread(fullfile(vl_root,'data','roofs2.jpg')) ;

Ia = uint8(rgb2gray(Ia)) ;
Ib = uint8(rgb2gray(Ib)) ;

[ra,fa] = vl_mser(I,'MinDiversity',0.7,'MaxVariation',0.2,'Delta',10) ;
[rb,fb] = vl_mser(I,'MinDiversity',0.7,'MaxVariation',0.2,'Delta',10) ;

[matches, scores] = vl_ubcmatch(fa, fb);

figure(1) ; clf ;
imagesc(cat(2, Ia, Ib));
axis image off ;
vl_demo_print('mser_match_1', 1);

figure(2) ; clf ;
imagesc(cat(2, Ia, Ib));

xa = ra(1, matches(1,:));
xb = rb(1, matches(2,:)) + size(Ia,2);
ya = ra(2, matches(1,:));
yb = rb(2,matches(2,:));

hold on ;
h = line([xa ; xb], [ya ; yb]);
set(h, 'linewidth', 1, 'color', 'b');

vl_plotframe(ra(:,matches(1,:)));
rb(1,:) = fb(1,:) + size(Ia,2);
vl_plotframe(rb(:,mathces(2,:)));
axis image off ;

vl_demo_print('mser_match_2', 1);

%%%%%%

【问题讨论】:

  • 你能详细说明一下吗?你遇到了什么困难?
  • 上面的代码我试过了,可惜匹配不好。

标签: matlab matching matlab-cvst mser


【解决方案1】:

有几个问题。首先,代码有几个错误并且不能按原样运行。我在下面粘贴了我的工作版本。

更重要的是,您正在尝试使用 SIFT 特征匹配函数来匹配 MSER 椭球。这根本行不通,因为 SIFT 基于局部图像梯度给出了一个非常高维的特征向量,而 MSER 检测器只是给你一个边界椭球。

VLFeat 似乎不包含 MSER 匹配函数,因此您可能必须自己编写。查看原始 MSER 论文,了解他们是如何进行匹配的:

"Robust wide-baseline stereo from maximally stable extremal regions", Matas et al. 2002

% Read the input images
Ia = imread(fullfile(vl_root,'data','roofs1.jpg')) ;
Ib = imread(fullfile(vl_root,'data','roofs2.jpg')) ;

% Convert to grayscale
Ia = uint8(rgb2gray(Ia)) ;
Ib = uint8(rgb2gray(Ib)) ;

% Find MSERs
[ra,fa] = vl_mser(Ia, 'MinDiversity',0.7,'MaxVariation',0.2,'Delta',10) ;
[rb,fb] = vl_mser(Ib, 'MinDiversity',0.7,'MaxVariation',0.2,'Delta',10) ;

% Match MSERs
[matches, scores] = vl_ubcmatch(fa, fb);

% Display the original input images
figure(1); clf;
imagesc(cat(2, Ia, Ib));
axis image off;
colormap gray;

% Display a second copy with the matches overlaid
figure(2) ; clf ;
imagesc(cat(2, Ia, Ib));
axis image off;
colormap gray;

xa = fa(1, matches(1,:));
ya = fa(2, matches(1,:));
xb = fb(1, matches(2,:)) + size(Ia,2);
yb = fb(2, matches(2,:));

hold on ;
h = line([xa ; xb], [ya ; yb]);
set(h, 'linewidth', 1, 'color', 'y');

【讨论】:

    【解决方案2】:

    我不知道如何,但 MSER 匹配在 Matlab 本身中有效。

    下面的代码

    file1 = 'roofs1.jpg';
    file2 = 'roofs2.jpg';
    
    I1 = imread(file1);
    I2 = imread(file2);
    
    I1 = rgb2gray(I1);
    I2 = rgb2gray(I2);
    
    % %Find the SURF features.
    % points1 = detectSURFFeatures(I1);
    % points2 = detectSURFFeatures(I2); 
    
    points1 = detectMSERFeatures(I1);
    points2 = detectMSERFeatures(I2); 
    
    %Extract the features.
    [f1, vpts1] = extractFeatures(I1, points1);
    [f2, vpts2] = extractFeatures(I2, points2);
    
    %Retrieve the locations of matched points. The SURF featurevectors are already normalized.
    indexPairs = matchFeatures(f1, f2, 'Prenormalized', true) ;
    matched_pts1 = vpts1(indexPairs(:, 1));
    matched_pts2 = vpts2(indexPairs(:, 2));
    
    
    figure; showMatchedFeatures(I1,I2,matched_pts1,matched_pts2,'montage');
    legend('matched points 1','matched points 2');
    

    给出如下图

    【讨论】:

    • 这需要计算机视觉系统工具箱。
    猜你喜欢
    • 1970-01-01
    • 2013-07-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-11
    相关资源
    最近更新 更多