(image, min=0.5, max=2.0)
return cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
Randomly change the brightness of the input image.
    Protected against overflow.
Randomly change the brightness of the input image.
    Protected against overflow.
Randomly change the brightness of the input image . Protected against overflow .
def _brightness(image, min=0.5, max=2.0):
    '''
    Randomly change the brightness of the input image.
    Protected against overflow.
    '''
    hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)

    random_br = np.random.uniform(min, max)

    # To protect against overflow: Calculate a mask for all pixels
    # where adjustment of the brightness would exceed the maximum
    # brightness value and set the value to the maximum at those pixels.
    mask = hsv[:, :, 2] * random_br > 255
    v_channel = np.where(mask, 255, hsv[:, :, 2] * random_br)
    hsv[:, :, 2] = v_channel

    return cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
def _brightness ( image , min = 0.5 , max = 2.0 ) : hsv = cv2 . cvtColor ( image , cv2 . COLOR_RGB2HSV ) random_br = np . random . uniform ( min , max ) # To protect against overflow: Calculate a mask for all pixels # where adjustment of the brightness would exceed the maximum # brightness value and set the value to the maximum at those pixels. mask = hsv [ : , : , 2 ] * random_br > 255 v_channel = np . where ( mask , 255 , hsv [ : , : , 2 ] * random_br ) hsv [ : , : , 2 ] = v_channel return cv2 . cvtColor ( hsv , cv2 . COLOR_HSV2RGB )