1 Introduction
PIL, OpenCV and numpy are several data formats commonly used in Python;
2 PIL and OpenCV
2.1 PIL to OpenCV
The storage format after OpenCV reads the image file is np.array ;
You can refer to the following code:
import cv2
# ———— Show pictures with PLT————
img=cv2.imread('1.jpg') #Open the image, opencv reads the data of the image by default: (height, width, channel (B, G, R)).
img = img[:,:, (2, 1, 0)] # Change the order of image channels to: RGB
# PLT default read image data format: (height, width, channel (R, G, B)).
img2=img[: , : , : : -1]