Correlation among 2 images

不想你离开。 提交于 2019-12-04 15:26:13

This is the function used to do correlation (coefficient) between two images (matrices):

r = corr2(A,B) computes the correlation coefficient between A and B, where A and B are matrices or vectors of the same size.

while xcorr2 (A, B) solves for CROSS correlation.

MATLAB has xcorr2 just for this purpose. I suppose your code would look something like:

r = xcorr2(f1, f2) / (P .^ 2)

Where f1 and f2 are the two images. The resulting matrix r is a (2P-1)×(2P-1) matrix, and each of its elements reflect the measure of similarity between f1 and f2, when the two images are shifted by an offset corresponding to that element's offset from the center.

Note that if you're interested only in the correlation between two unshifted images, then you should save execution time and use corr2, like @TheByzantine has suggested in his answer.

use the xcorr2 function. For example:

 C=xcorr2(A,B)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!