Python PIL 的image类和numpy array之间的互换
import cv2 import numpy as np from PIL import Image from PIL import ImageEnhance def getline(frame): img = Image.fromarray(frame.astype('uint8')).convert('RGB') enh_col = ImageEnhance.Color(img) color = 1.5 image_colored = enh_col.enhance(color) enh_con = ImageEnhance.Contrast(image_colored) contrast = 1.5 image_colored = enh_con.enhance(contrast) frame = np.array(image_colored) cv2.imshow("img1",frame)