标准化互相关的基础知识

5

我正在尝试使用MATLAB中的normxcorr2标准化交叉相关)来计算发育胚胎中移动形状的速度,以下是我的三个问题:

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

2)相关矩阵中的每个值都表示搜索窗口中的模板矩阵。对吗?

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

1个回答

4
为了说明如何使用 normxcorr2,请看下面的示例(改编自这个页面)。
%# 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)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接