MATLAB:图像 horizontal/vertical 与 corr2() 的自相关
MATLAB: image horizontal/vertical autocorrelation with corr2()
我有一张图像,我正在尝试计算 R_h[x], R_v[x], -50<=x<=50
的水平和垂直自相关函数估计值。我听说我可以使用 corr2()
来完成此操作,但我不确定如何操作。
你可以看看corr2()
documentation。
基本上这样做:
mInputImage1 = randn([200, 200]);
mInputImage2 = medfilt2(randn([200, 200]));
mCorrImage = corr2(mInputImage1, mInputImage2);
您可以结合使用 circshift
(将图像偏移一定量)和 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)
我想你可以从这里得到它并得到另一个维度的相同图形,或者甚至得到一个矩阵来组合水平和垂直维度的移位。
我有一张图像,我正在尝试计算 R_h[x], R_v[x], -50<=x<=50
的水平和垂直自相关函数估计值。我听说我可以使用 corr2()
来完成此操作,但我不确定如何操作。
你可以看看corr2()
documentation。
基本上这样做:
mInputImage1 = randn([200, 200]);
mInputImage2 = medfilt2(randn([200, 200]));
mCorrImage = corr2(mInputImage1, mInputImage2);
您可以结合使用 circshift
(将图像偏移一定量)和 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)
我想你可以从这里得到它并得到另一个维度的相同图形,或者甚至得到一个矩阵来组合水平和垂直维度的移位。