opencv学习笔记(6)对比度和亮度

# coding=UTF-8
import cv2 as cv
import numpy as np


def contrast_brighten_demo(image,c,b):#c为对比度 contrast  b 为亮度 brightness
    cv.imshow("original",image)
    h,w,ch=image.shape #获取图像尺寸
    blank =np.zeros([h,w,ch],image.dtype) #创建一个和图像尺寸相同的纯黑图片
    dst=cv.addWeighted(image,c,blank,1-c,b)#调整权重 
    cv.imshow("con-bri-demo",dst)



scr = cv.imread("D:/academic/picture/opencv_data/lena.jpg")
contrast_brighten_demo(scr,1,200)
cv.waitKey()
cv.destroyAllWindows()

调整图像对比度和亮度的,有空再更

你可能感兴趣的:(opencv学习)