【问题标题】:MATLAB: image horizontal/vertical autocorrelation with corr2()MATLAB:图像水平/垂直自相关与 corr2()
【发布时间】:2017-03-27 05:16:33
【问题描述】:

我有一张图像,我正在尝试计算 R_h[x], R_v[x], -50<=x<=50 的水平和垂直自相关函数估计值。我听说我可以使用corr2() 来完成此操作,但我不确定如何。

【问题讨论】:

    标签: matlab image-processing correlation


    【解决方案1】:

    您可以结合使用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)
    

    我认为您可以从这里获取其他维度的相同图表,甚至可以获取水平和垂直维度的变化组合的矩阵。

    【讨论】:

      【解决方案2】:

      你可以看看corr2() documentation。
      基本上这样就可以了:

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

      【讨论】:

      • 谢谢,但这与我想要做的有点不同。我想垂直扫描图像并绘制自相关图,滞后范围为 -50:50,然后水平执行相同的操作。因此,由于图像可能在同一邻域内具有相似的像素,因此我希望看到三角形的函数,因为滞后从两侧接近零。我尝试查看文档,但没有发现它对此有帮助。
      • 总相关函数中总能提取出你想要的数据。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      • 2014-02-16
      相关资源
      最近更新 更多