Python PIL 的image類和numpy array之間的互換

import cv2
import numpy as np
from PIL import Image
from PIL import ImageEnhance



def getline(frame):

    img = Image.fromarray(frame.astype('uint8')).convert('RGB')
    enh_col = ImageEnhance.Color(img)
    color = 1.5
    image_colored = enh_col.enhance(color)
    enh_con = ImageEnhance.Contrast(image_colored)
    contrast = 1.5
    image_colored = enh_con.enhance(contrast)

    frame = np.array(image_colored)
    cv2.imshow("img1",frame)
相關文章
相關標籤/搜索