# 导入相关模块和包
import cv2 as cv
import numpy as np
# 定义亮度调整函数
def contrast_brightness_demo(image, c, b):
h, w, channels = image.shape
blank = np.zeros([h, w, channels], image.dtype)
dst = cv.addWeighted(image, c, blank, 1 - c, b)
cv.imshow('demo_image', dst)
# 读取图片
src = cv.imread(r'C:\Users\Administrator.PC-20201106KUIO\Desktop\lena.jpg')
# 展示原图
cv.imshow('image', src)
# 调用对比度和亮度调整函数
contrast_brightness_demo(src, 0.2, 100)
# 等待按下任意键
cv.waitKey(0)
# 释放内存
cv.destroyAllWindows()