- opencv实现直方图均衡化有现成的函数:
cv.equalizeHist(img)(全局)
代码距离:
实验图片:
import cv2
import numpy as np
img = cv2.imread("D:/images/test.png", 0)
equ = cv2.equalizeHist(img)
res = np.hstack((img, equ))
cv2.imshow("res", res)
cv2.waitKey(0)
局部直方图实现函数:
import numpy as np
import cv2 as cv
img = cv.imread('tsukuba_l.png',0)
clahe = cv.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
cl1 = clahe.apply(img)
cv.imwrite('clahe_2.jpg',cl1)