Histogram Equalisation in C | Image Processing
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.
Results: 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.
Please Login to comment...