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)

 

posted @ 2018-09-19 13:11  Anita-ff  阅读(3190)  评论(0编辑  收藏  举报