MATLAB:具有corr2()的图像水平/垂直自相关

MATLAB:具有corr2()的图像水平/垂直自相关,matlab,image-processing,correlation,Matlab,Image Processing,Correlation,我有一张图像,我正试图计算R_h[x]、R_v[x]、-50的水平和垂直自相关函数估计值,你可以看看。 这基本上可以: mInputImage1 = randn([200, 200]); mInputImage2 = medfilt2(randn([200, 200])); mCorrImage = corr2(mInputImage1, mInputImage2); 您可以通过组合(将图像偏移一定数量)和corr2来计算原始图像和偏移图像之间的相关性。您只需要循环检查要检查的值。例如: i

我有一张图像,我正试图计算
R_h[x]、R_v[x]、-50的水平和垂直自相关函数估计值,你可以看看。
这基本上可以:

mInputImage1 = randn([200, 200]);
mInputImage2 = medfilt2(randn([200, 200]));

mCorrImage = corr2(mInputImage1, mInputImage2);

您可以通过组合(将图像偏移一定数量)和
corr2
来计算原始图像和偏移图像之间的相关性。您只需要循环检查要检查的值。例如:

img = peaks(100);  % Sample data
x = -50:50;   % Desired offsets
output = zeros(1,101); %preallocate space for the result

for i=x   % loop over the offsets
    img2=circshift(img,[i 0]);   % Shift the image by the desired lag
    output(i+51)=corr2(img,img2);   % Calculate the correlation between the offset image and the original
end

plot(x,output)


我想你可以从这里得到另一个维度的相同图形,甚至可以得到一个水平和垂直维度位移组合的矩阵。

谢谢,但这与我想做的有点不同。我想垂直扫描图像,绘制一张自相关图,滞后范围为-50:50,然后水平扫描。因此,由于图像在同一个邻域内可能有相似的像素,我希望当两侧的延迟接近零时,会出现一个三角形的函数。我试着查看文档,但没有发现它对此有帮助。您可以随时从total correlation函数中提取所需的数据。