opencv-python图像处理之磨皮相机

from PIL import Image
import cv2
from PIL import ImageEnhance
def main_m() :
    frame=cv2.VideoCapture(0)
    while frame.isOpened():
        s,f=frame.read()


        # 滤波
        blur = cv2.bilateralFilter (f,9,75, 75)
        alpha = 0.3
        beta = 1-alpha
        gamma =0
        # 融合
        img_add = cv2.addWeighted(f,alpha, blur, beta, gamma )

        img_add = Image.fromarray(cv2.cvtColor(img_add,cv2.COLOR_BGR2RGB))
         
        enh_sha = ImageEnhance.Sharpness(img_add)
        sharpness = 1.5
        # 增强
        image_sharped = enh_sha. enhance (sharpness)
        # 锐化
        enh_con = ImageEnhance. Contrast (image_sharped)
        contrast = 1.15
        image_contrasted = enh_con.enhance (contrast)
        image_contrasted = cv2.cvtColor(numpy.asarray(image_contrasted), cv2.COLOR_RGB2BGR)
        cv2.imshow("",image_contrasted)
        cv2. waitKey(10)

if __name__ == '__main__':
    main_m()

你可能感兴趣的:(opencv-python)