Loading...
Implement histogram equalization to enhance image contrast using NumPy.
Histogram equalization redistributes pixel intensities to achieve a more uniform histogram, improving contrast in images with concentrated intensity ranges.
Algorithm:
Where M×N is the total number of pixels and CDFmin is the minimum non-zero CDF value.
image = [[50, 50], [50, 50]]
[[255, 255], [255, 255]]
Step 1: Histogram Only intensity 50 appears, count = 4
Step 2: CDF CDF[50] = 4, all others = 0 or 4
Step 3: Normalize CDF_min = 4, total pixels = 4 CDF_norm[50] = (4-4)/(4-4) × 255 = undefined → use 255 when all same
Step 4: Map All pixels map to 255 (maximum) since they all have the same value.
When all pixels are identical, equalization maps them to maximum intensity.