A histogram of a digital image represents intensity distribution by plotting bar graph with X-axis as pixel intensity value and Y-axis as the frequency of its occurrence.
Histogram Equalisation is a technique to adjust contrast levels and expand the intensity range in a digital image. Thus, it enhances the image which makes information extraction and further image processing easier.
Following is the algorithm to do histogram equalisation in C language.
- Convert the input image into a grayscale image
- Find frequency of occurrence for each pixel value i.e. histogram of an image (values lie in the range [0, 255] for any grayscale image)
- Calculate Cumulative frequency of all pixel values
- Divide the cumulative frequencies by total number of pixels and multiply them by maximum graycount (pixel value) in the image
For example, consider an image having total 25 pixels having 8 distinct pixel values. All the steps have been applied to the histogram of the original image.
The last row in the above image shows result after multiplication which is actually histogram equalised new gray level mapping of original gray levels.
Below is the C program to perform histogram equalisation of an image.
Boat image before and after Histogram Equalisation (From Left to Right)
Transformation of Histogram before and after Equalisation (From Left to Right)
Note that boat image used in the program is a grayscale raw image. ImageJ and GNUplot are used for viewing images and plotting histograms.
- Image Processing in Java | Set 3 (Colored image to greyscale image conversion)
- Image Processing in Java | Set 4 (Colored image to Negative image conversion)
- Image Processing in Java | Set 6 (Colored image to Sepia image conversion)
- Image Processing in Java | Set 5 (Colored to Red Green Blue Image Conversion)
- Image Processing in Java | Set 7 (Creating a random pixel image)
- Getting started with Scikit-image: image processing in Python
- Image Processing in Java | Set 8 (Creating mirror image)
- Image Processing in Java | Set 11 (Changing orientation of image)
- Image Processing in Java | Set 10 ( Watermarking an image )
- MATLAB | Display histogram of a grayscale Image
- Image Processing In Java | Set 2 (Get and set Pixels)
- Digital Image Processing Basics
- Image Processing without OpenCV | Python
- Image Processing in Java | Set 9 ( Face Detection )
- Image Processing in Java | Set 12 ( Contrast Enhancement )
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.