简单几行python + opencv代码达到美颜、逆美颜效果

import cv2
import numpy as np

original_image1 = cv2.imread('original_image.JPG').astype(np.float32)/255

# 设置调整颜色参数,小于1时,数值越小,越具有美白效果。反之,大于1时数值越大,可对美白照片还原原色
gamma1 = 0.6
whitening = np.power(original_image1, gamma1)

# 去除噪点
denoise = cv2.medianBlur(whitening, 5)

cv2.imshow('original_image', original_image1)
cv2.imshow('whitening', whitening)
cv2.imshow('denoise', denoise)

# 将美白图片还原为原色
gamma2 = 1.8
debeautify = np.power(denoise, gamma2)
cv2.imshow('debeautify', debeautify)

cv2.waitKey(0)

简单几行python + opencv代码达到美颜、逆美颜效果_第1张图片

你可能感兴趣的:(opencv)