Image.open獲得的圖片數(shù)據(jù)格式是RGB
cv2.imread獲得的圖片數(shù)據(jù)格式是BGR
Image.open的RGB數(shù)據(jù)到cv2.imshow能正常使用的數(shù)據(jù)轉(zhuǎn)變:
img_rgb = Image.open(filename)
img_bgr = img_rgb[:, :, ::-1]
cv2.imshow("test", img_bgr)
cv2.imread的BGR數(shù)據(jù)到Image中RGB圖像類對象的轉(zhuǎn)換:
img_bgr = cv2.imread(filname)
img_rgb =cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
img_rgb_obj = Image.fromarray(img_rgb)