corr2 function not working properly
7 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Steven Lord
on 7 Jul 2015
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
0 Comments
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!