Reputation: 440
I want to know what is the python equivalent of the matlab function corr2 that gives the correlation coefficient between 2 matrices, return only one value.
http://www.mathworks.com/help/images/ref/corr2.html
I only found that the equivalent in python is scipy.signal.correlate2d but this returns an array.
Thanks.
Upvotes: 3
Views: 5555
Reputation: 149
Maybe this can be help you
def mean2(x):
y = np.sum(x) / np.size(x);
return y
def corr2(a,b):
a = a - mean2(a)
b = b - mean2(b)
r = (a*b).sum() / math.sqrt((a*a).sum() * (b*b).sum());
return r
Upvotes: 6