【发布时间】:2015-11-09 08:16:41
【问题描述】:
为实时定点实现准备实验室代码,我写了如下函数
function res = imcorr(inIm,kernel)
% res=imfilter(inIm,kernel,'replicate'); %initial implementation
% res=imfilter(inIm,kernel); %same as we crop the result below
res=xcorr2(inIm,kernel); %faster, works with singles, but shifts result by 2 pixels
s=size(inIm);
rect=[fix((size(res,2)-s(2))/2), fix((size(res,1)-s(1))/2), s(2), s(1)];
res=imcrop(res,rect);
然后我使用来自https://gist.github.com/goulu/ba70175f870fdb2c25e3 的代码(从http://www.mathworks.com/help/signal/ref/xcorr2.html 编辑)作为测试平台,并注意到xcorr2 和imfilter 获得的结果在两个方向上都有2 个像素的偏移:
这是从哪里来的?
【问题讨论】:
-
您可以尝试使用手动生成的矩阵吗?
标签: matlab image-processing correlation