# Numpy.corrcoef() for twice one object does not return matrix of 1's

I'm trying to compare if two pictures are similar or close to similar. The picture is available as numpy.ndarray and contains of 28x28 pixels. It might look like the one below: When I get the image as numpy.ndarray and calculate the corrcoef

image = data['test_dataset']
matrix = np.corrcoef(image, image)


I was expecting a matrix full of 1's. Instead I get as print(matrix) something like:

[[ 1.          0.88450496  0.71112943 ...,  0.38349944  0.86398242
0.95855052]
[ 0.88450496  1.          0.85582039 ...,  0.60284577  0.99192916
0.85438787]
...


Afterwards I wanted to create the .mean() of the matrix and if the value is higher than for example 0.98 the images are similar.

Can someone help me getting a matrix full of 1's instead of my strange looking output? Thanks in advance.

From the numpy documentation of the first passed argument x : array_like A 1-D or 2-D array containing multiple variables and observations. Each row of x represents a variable, and each column a single observation of all those variables.
So in your result matrix, the coefficient appearing in position [0, 0] is the correlation of the first row of the image with itself (should be equal to 1, which is the case) The coefficient appearing in position [0, 1] is the correlation between the first row and the second row of the image and cannot be equal to 1 as these rows are clearly not identical. It should however be equal to the coefficient in position [1, 0] which is the case.
• Mutual information maybe? It seems that the medpy library has a full module called metric.image. Sklearn.metric has also some metrics implemented. Good luck with this :) Nov 22 '16 at 15:26