zl程序教程

您现在的位置是:首页 >  后端

当前栏目

from opencv image to PIL image and reverse

Opencv to and from Image reverse PIL
2023-09-14 08:57:33 时间
import cv2
import numpy as np
from PIL import Image

img = cv2.imread("path/to/img.png")

# You may need to convert the color.
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
im_pil = Image.fromarray(img)

# For reversing the operation:
im_o = np.asarray(im_pil)
im_opencv = im_o[:, :, ::-1].copy()