This recipe tells you how to change the data type of matrix elements from uint8 to float32 and perform arithmetic operations without worrying about clamping values (and then convert everything back to uint8).
Converting between different data types and scaling values
Getting ready
You need to have OpenCV 3.x installed with Python API support.
How to do it...
The following steps are required for this recipe:
- Import all necessary modules, open an image, print its shape and data type, and display it on the screen:
import cv2, numpy as np
image = cv2.imread('../data...