- OpenCV 3 Computer Vision with Python Cookbook
- Alexey Spizhevoy Aleksandr Rybnikov
- 70字
- 2021-08-27 19:47:42
How to do it...
Perform the following steps:
- Import all necessary modules:
import cv2
import numpy as np
- 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
- 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()