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 :
- Set up Opencv with anaconda environment
- OpenCV: Segmentation using Thresholding
- Python | Grayscaling of Images using OpenCV
- Reading an image in OpenCV using Python
- Python | Play a video using OpenCV
- Python | Image blurring using OpenCV
- Arithmetic operations using OpenCV | Python
- Image Resizing using OpenCV | Python
- Color Spaces in OpenCV | Python
- Image Processing without OpenCV | Python
- Image Pyramid using OpenCV | Python
- Draw a triangle with centroid using OpenCV
- Python | Smile detection using OpenCV
- Image Translation using OpenCV | Python
- Template matching using OpenCV in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.