# Covariance scalar from matrix

I am trying to implement SSIM Structural similarity in Python.

One of the necessary elements is the covariance between the two matrices. Using numpy.cov() We get a covariance matrix.

Is there a way to go from the covariance matrix to a single value representing the covariance?

• You can use something like np.cov(x,y)[0,1] Oct 18 '20 at 2:06
• I don't get a 2x2 matrix though, when I do np.cov(x,y) Oct 18 '20 at 3:12

$$\sigma_{xy} = \frac{1}{N-1}\Sigma_{i=1}^N(x_i - \mu_x)(y_i - \mu_y)$$
• I believe in the paper x and y are the matrices. N is the number of elements in the matrix. x_i is the ith element in the matrix...so I guess there is a bit of liberty taken with the notation Oct 19 '20 at 18:00