I am using these functions to modify the values of brightness, contrast and sharpness. My default values are 128, 24, 4 respectively. I extracted these values. I don't know how to extract the value of the color to modify it in the same way.
import numpy as np
import cv2
import matplotlib.pyplot as plt
from PIL import Image, ImageEnhance
def brightness_enhancer(img, br):
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = Image.fromarray(img)
enhancer = ImageEnhance.Brightness(img)
factor = 128/br
return enhancer.enhance(factor)
def contrast_enhancer(img, ct):
#img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
#img = Image.fromarray(img)
enhancer = ImageEnhance.Contrast(img)
factor = 24/ct
return enhancer.enhance(factor)
def sharpness_enhancer(img, sh):
#img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
#img = Image.fromarray(img)
enhancer = ImageEnhance.Sharpness(img)
factor = 4/sh
return enhancer.enhance(factor)
def color_enhancer(img):
#img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
#img = Image.fromarray(img)
enhancer = ImageEnhance.Color(img)
factor = 0.5 #enhancement of the image
return enhancer.enhance(factor)