【问题标题】:Basics of normalized cross correlation归一化互相关的基础知识
【发布时间】:2009-11-08 00:08:35
【问题描述】:

我正在尝试使用 MATLAB 中的 normxcorr2 (normalized cross-correlation) 来计算发育中胚胎中移动形状的速度。我有 3 个问题:

1) 我的图像尺寸是 260x360 像素。我给出一个 10x10 像素大小的模板,并要求命令在 50x50 像素的搜索窗口中的后续帧中搜索此模板。我得到一个大小为 59x59 的相关矩阵。所以这意味着该命令在搜索窗口中逐个像素地移动模板以寻找最佳相关性。对吧?

2) 相关矩阵中的每个值代表搜索窗口中的一个模板矩阵。对吧?

3) 假设我在相关矩阵的第 10 行和第 16 列得到最大值。这意味着最佳相关模板位于图像中y方向的第10个矩阵和x方向的第16个矩阵中。对吧?

【问题讨论】:

    标签: matlab image-processing computer-vision


    【解决方案1】:

    为了说明 normxcorr2 的使用,请考虑以下示例(改编自 this page

    %# Make light gray plus on dark gray background
    template = 0.2*ones(11);
    template(6,3:9) = 0.6;
    template(3:9,6) = 0.6;
    BW = single(template > 0.5);         %# Make white plus on black background
    imtool(template, 'InitialMagnification','fit')
    
    %# Make new image that offsets the template
    offsetTemplate = 0.2*ones(81);
    offset = [30 50];                    %# Shift by 30 rows, 50 columns
    offsetTemplate( (1:size(template,1))+offset(1), ...
                    (1:size(template,2))+offset(2) ) = template;
    imtool(offsetTemplate, 'InitialMagnification',400)
    
    %# Cross-correlate BW and offsetTemplate to recover offset
    cc_norm = normxcorr2(BW, offsetTemplate);
    imtool(cc_norm, 'InitialMagnification',400)
    [max_cc_norm, imax] = max( abs(cc_norm(:)) );
    [ypeak, xpeak] = ind2sub(size(cc_norm), imax(1));
    corr_offset = [ (ypeak-size(template,1)) (xpeak-size(template,2)) ];
    
    fprintf('Input offset: %d,%d\nRecovered offset: %d,%d\n', offset, corr_offset)
    

    【讨论】:

      猜你喜欢
      • 2019-06-15
      • 1970-01-01
      • 2011-10-29
      • 2017-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-16
      • 2018-05-25
      相关资源
      最近更新 更多