corr2 function not working properly
Mostra commenti meno recenti
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?
Risposte (1)
Steven Lord
il 7 Lug 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
Categorie
Scopri di più su Image Filtering in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!