In this section, we will see how to perform histogram equalization using the OpenCV function, cv2.equalizeHist(), and how to apply it to both grayscale and color images. The cv2.equalizeHist() function normalizes the brightness and also increases the contrast of the image. Therefore, the histogram of the image is modified after applying this function. In the next subsections, we will explore both the original and the modified histogram in order to see how it is changed.
Histogram equalization
Grayscale histogram equalization
Using the cv2.equalizeHist() function with the purpose of equalizing the contrast of a given grayscale image is pretty easy:
image = cv2.imread('lenna.png')
gray_image = cv2.cvtColor(image, cv2...