Histogram equalization is a method in image processing of contrast adjustment using the image's histogram. For more information, see [1].
Input
Output
Implementation
This algorithm is trying to find a new mapping palette based on the histogram. Consider a grayscale image X, whose total number of gray levels in the image is L, Denote the histogram of the image as \(H_x\). The probability of an occurrence of a pixel of level \(i\) in the image is:
\[ p[i] = H_x[i] / N \]
where:
\(N\) is total number of pixels in the image.
The cumulative distribution function corresponding to \(p[i]\) is:
\[ cdf_x[i] = \sum_{j=0}^{i}p[j] \]
Using the cumulative distribution function to transform the original pixel value to a new pixel value, the corresponding pixel value is:
\[ y[i] = \sum_{j=0}^{i}p[j] * L \]
Example of image histogram after equalization:
Input
Equalized Output
Usage
Language:
Import VPI module
import vpi
Use the CUDA backend to equalize the input image histogram, creating output VPI image with the result.
with vpi.Backend.CUDA:
output = input.eqhist()
Initialization phase
Include the header that defines the image equalize histogram function.