How to fast change image brightness with python + OpenCV?

前端 未结 12 910
感动是毒
感动是毒 2020-12-05 10:42

I have a sequence of images. I need to average brightness of these images.

First example (very slow):

img = cv2.imread(\'test.jpg\')         


        
12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 11:12

    import cv2
    import numpy as np
    
    image = cv2.imread('image.jpg')
    image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
    
    increase = 100
    
    v = image[:, :, 2]
    v = np.where(v <= 255 - increase, v + increase, 255)
    image[:, :, 2] = v
    
    image = cv2.cvtColor(image, cv2.COLOR_HSV2BGR)
    
    cv2.imshow('Brightness', image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    

提交回复
热议问题