import numpy as np
import cv2 as cv
def hisEqulColor1(img):
ycrcb = cv.cvtColor(img, cv.COLOR_BGR2YCR_CB)
channels = cv.split(ycrcb)
cv.equalizeHist(channels[0], channels[0])
cv.merge(channels, ycrcb)
cv.cvtColor(ycrcb, cv.COLOR_YCR_CB2BGR, img)
return img
def hisEqulColor2(img):
ycrcb = cv.cvtColor(img, cv.COLOR_BGR2YCR_CB)
channels = cv.split(ycrcb)
clahe = cv.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
clahe.apply(channels[0], channels[0])
cv.merge(channels, ycrcb)
cv.cvtColor(ycrcb, cv.COLOR_YCR_CB2BGR, img)
return img
img = cv.imread('mosaic_2_deHaze.jpg')
img2 = img.copy()
res2 = hisEqulColor2(img2)
cv.imwrite('mosaic_2_deHaze_hist.jpg', res2)