I have a sequence of images. I need to average brightness of these images.
First example (very slow):
img = cv2.imread(\'test.jpg\')
This was my solution to both increase and decrease brightness. Was having some error issues with a couple of the other answers. Function takes in a positive or negative value and alters brightness.
example in code
img = cv2.imread(path_to_image)
img = change_brightness(img, value=30) #increases
img = change_brightness(img, value=-30) #decreases
function being called
def change_brightness(img, value=30):
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
h, s, v = cv2.split(hsv)
v = cv2.add(v,value)
v[v > 255] = 255
v[v < 0] = 0
final_hsv = cv2.merge((h, s, v))
img = cv2.cvtColor(final_hsv, cv2.COLOR_HSV2BGR)
return img