OpenCV默认把图像读成BGR格式,因此需要转化。
def readImage(path):
# OpenCV reads the image in bgr format by default
bgr_img = cv2.imread(path)
# We flip it to rgb for visualization purposes
b,g,r = cv2.split(bgr_img)
rgb_img = cv2.merge([r,g,b])
return rgb_img
或者:img = Image.open(img_path).convert("RGB")
BGR图像转RGB
最新推荐文章于 2024-09-25 11:02:12 发布