Image.open获得的图片数据格式是RGB
cv2.imread获得的图片数据格式是BGR
Image.open的RGB数据到cv2.imshow能正常使用的数据转变:
img_rgb = Image.open(filename)
img_bgr = img_rgb[:, :, ::-1]
cv2.imshow("test", img_bgr)
cv2.imread的BGR数据到Image中RGB图像类对象的转换:
img_bgr = cv2.imread(filname)
img_rgb =cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
img_rgb_obj = Image.fromarray(img_rgb)