Every image can be represented by a matrix. For example, a simple image with a diagonal line can be represented by an identity matrix, A1: Suppose we want to calculate the correlation coefficient of A1 and itself, we will use the following formula: Based on the matrix multiplication rule, we can only multiply a m x n matrix A with a n x p matrix B in which the column number of A is equal to the row number of B. In our case, after vectorizing A1, it becomes a 1x4 matrix [1001]. To multiply A1 and A1, we have to first transpose A1 into A1 T which is a 4x1 matrix, then we can calculate the dot product and the coefficient: