How to do it...

Perform the following steps:

  1. Import all necessary modules:
import cv2
import numpy as np
  1. Load an image and convert it to one with floating-point elements in range [0,1]:
image = cv2.imread('../data/Lena.png').astype(np.float32) / 255
  1. Subtract the mean value from each image pixel to get a zero-mean matrix. Then, divide each pixel value by its standard deviation to have a unit-variance matrix:
image -= image.mean()
image /= image.std()