Prerequisite : Analyze-image-using-histogram
Histogram equalization is a method in image processing of contrast adjustment using the image’s histogram.
This method usually increases the global contrast of many images, especially when the usable data of the image is represented by close contrast values. Through this adjustment, the intensities can be better distributed on the histogram. This allows for areas of lower local contrast to gain a higher contrast. Histogram equalization accomplishes this by effectively spreading out the most frequent intensity values. The method is useful in images with backgrounds and foregrounds that are both bright or both dark.
OpenCV has a function to do this, cv2.equalizeHist(). Its input is just grayscale image and output is our histogram equalized image.
Input Image :
Below is Python3 code implementing Histogram Equalization :
- Introduction to OpenCV
- OpenCV - Overview
- Set up Opencv with anaconda environment
- Filter Color with OpenCV
- OpenCV | Loading Video
- OpenCV | Saving an Image
- Image Inpainting using OpenCV
- OpenCV: Segmentation using Thresholding
- OpenCV | Displaying an Image
- Draw a triangle with centroid using OpenCV
- Python | Smile detection using OpenCV
- Image Resizing using OpenCV | Python
- Python OpenCV | cv2.line() method
- Python OpenCV | cv2.imwrite() method
- Python OpenCV | cv2.imshow() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.