Contrast Limited Adaptive Histogram Equalization
Implement Contrast Limited Adaptive Histogram Equalization (CLAHE) for local contrast enhancement, which is an improvement over traditional histogram equalization. CLAHE is essential in image processing as it helps to enhance the contrast of images by dividing them into smaller regions, called tiles, and applying histogram equalization to each tile.
The process involves dividing the image into an 8×8 grid of tiles and applying histogram equalization to each tile. This is done by computing the histogram of each tile, which represents the distribution of pixel intensities, and then clipping the histogram at a threshold to limit contrast amplification. The clipping threshold is typically set to a fraction of the total number of pixels in the tile, preventing over-amplification of noise in homogeneous regions.
Here are the key steps:
- Divide the image into tiles of size n×n.
- Compute the histogram of each tile, which represents the distribution of pixel intensities.
- Clip the histogram at a threshold to limit contrast amplification.
- Apply bilinear interpolation at tile boundaries to avoid artifacts.
This technique is widely used in medical imaging to enhance the visibility of details in images.
Example:
image = low contrast 64x64 image tile_size = 8 clip_limit = 2.0
Enhanced image with improved local contrast
CLAHE process for each 8×8 tile:
- Compute histogram (256 bins)
- Clip: If any bin > clip_limit × avg_bin_count, redistribute excess
- Compute CDF from clipped histogram
- Map pixels using local CDF
Bilinear interpolation blends mappings at tile boundaries.
Constraints:
- image: 2D grayscale array [0-255]
- tile_size: Size of each tile (default 8)
- clip_limit: Histogram clip limit (default 2.0)
- Return: Enhanced image