This is the code I have tried.
import cv2
import numpy as np
img = cv2.imread("mc.jpeg")
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
alpha = 3.5
beta = -2
new = alpha * img + beta
new = np.clip(new, 0, 255).astype(np.uint8)
cv2.imwrite("cleaned.png", new)
Is there an adaptive way to adjust alpha and beta values for different images?
I have to use different alpha and beta values since not all images have the same contrast and/or brightness.