I made a script in PIL or image processing but I wan tit to work fro videos too so I am rewriting it in opencv2-python. The issue I am running into is there is no equivalent of PIL auto contrast specifically the cutoff property.
If you have a solution let me know.
EDIT:
I am going to add examples to show what I an trying to do and what I am expecting and what result I am getting.
Sample Image here
PIL CODE
from PIL import Image, ImageOps
img = Image.open("his_equi.jpg").convert("L") #name of the file is his_equi.jpg
edited = ImageOps.autocontrast(img, cutoff=3)
edited.save("hiseqpil_1.jpg")
PIL OUTPUT here
CV2 CODE
import cv2
img = cv2.imread("his_equi.jpg", 0)
alpha = 1.8 # Contrast control (1.0-3.0)
beta = 0 # Brightness control (0-100)
img = cv2.convertScaleAbs(img, alpha=alpha, beta=beta)
clahe = cv2.createCLAHE(clipLimit=3, tileGridSize=(2, 2))
img = clahe.apply(img)
cv2.imwrite('hiscl_2.jpg', img)
CV2 OUTPUT here
I tried cv2.equalizeHist()
import cv2
img = cv2.imread("his_equi.jpg", 0)
img = cv2.equalizeHist(img)
cv2.imwrite('hiscl_2.jpg', img)
cv2.equalizeHist() output here
You can see how I want the darkest pixels to become black even though they are grey and light grey pixels to become White. I think this is called normalizing an image.