corr2 function not working properly
显示 更早的评论
I have tried corr2 on vectors in the following code, but the result doesn't make sense.
r = corr2([1 2], [1 3]) r = 1
Furthermore, when correlating images matlab gives me an output of r = 106! It shouldn't ever be greater than 1. Does anybody know what the problem is?
回答(1 个)
Steven Lord
2015-7-7
For your two vector case, think about what the correlation coefficient means. From the "Mathematical properties" section of that Wikipedia page:
"Correlations equal to 1 or −1 correspond to data points lying exactly on a line (in the case of the sample correlation)"
Do the points (1, 1) and (2, 3) lie exactly on a line? Absolutely. They DEFINE a line.
As for your image correlation, I'd need to see a (small) example that produces a correlation coefficient greater than 1. But one thing to check before trying to create such an example is that you're calling the CORR2 and MEAN2 functions from Image Processing Toolbox. You can do this by executing these lines of code:
which -all corr2
which -all mean2
类别
在 帮助中心 和 File Exchange 中查找有关 Image Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!