How it works...

Matrices are presented with NumPy array classes. These arrays have methods to compute mean values and standard deviations. To normalize a matrix—that is, to get a zero-mean and unit-variance matrix—we need to subtract the mean value, which we can get by calling mean and dividing the matrix by its standard deviation. You can also use the cv2.meanStdDev function, which computes both mean and standard deviation simultaneously.