【opencv】cv2.imread()读取通道顺序

cv2默认为 BGR顺序,而其他软件一般使用RGB,所以需要转换 

import cv2
import numpy as np

fengmian = 'picture.jpg'

img = cv2.imread(fengmian)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # cv2默认为bgr顺序
h, w, _ = img.shape #返回height,width,以及通道数,不用所以省略掉

其他读取都是RGB:

常用    img = Image.open('./1.png') 

猜你喜欢

转载自blog.csdn.net/qq_30159015/article/details/82149438