I've been trying to figure out the algorithm to perform full adaptive histogram equalization (without interpolating). However, I still seem to be missing a piece and haven't managed to get the result image right.
Here are the steps that I followed, hoping somebody could shed some light on what is missing:
- Input a gray scale image (0-255).
- Creating an over-sized image and mirroring the values near the borders to avoid borders and corners special cases. (As proposed in page 20 in this article: Adaptive Histogram Equalization a Parallel Implementation)
- Initialize a rank 0 for each pixel in the source image.
- For each pixel in the source image, find its rank in its local area (local area size will be given as input). Pixel rank is the number of pixels in the local area that are smaller than the center pixel (The pixel we are looping on, in the source image)
- New pixel value calculated by: Rank * (Maximum intensity = 255) / (Number of pixels in local area)
Following these steps result in the following output for 30x30 local area window size:
Original:
Output:
I'm hoping for some guidance in the following matter as to what I'm missing here.