1histogram Equalization in Image Processing
1histogram Equalization in Image Processing
Image Processing
Image processing techniques play a crucial role in enhancing the quality and visual appeal of
images. One such technique, histogram equalization, is widely used for improving contrast in
images. In this blog post, we'll delve into the details of histogram equalization, providing a step-by-
step explanation with mathematical calculations and a practical example.
CDF(i)=∑ij=0hj
CDFnormalized(i)=max(CDF)−min(CDF)CDF(i)−min(CDF)×255
T(i)=round(CDFnormalized(i)×255)
Equalized Image(x,y)=T(OriginalImage(x,y))
Type of histogram equalization
4. Bi-Histogram Equalization:
• Involves dividing the histogram into two halves and equalizing each half separately.
• Useful for images with unevenly distributed pixel values.
plt.subplot(1, 2, 1)
plt.imshow(image, cmap='gray')
plt.title('Original Image')
plt.subplot(1, 2, 2)
plt.imshow(equalized_image, cmap='gray')
plt.title('Global Histogram Equalization')
plt.show()
plt.subplot(1, 2, 1)
plt.imshow(image, cmap='gray')
plt.title('Original Image')
plt.subplot(1, 2, 2)
plt.imshow(equalized_image, cmap='gray')
plt.title('Adaptive Histogram Equalization')
plt.show()
Contrast Limited Adaptive Histogram Equalization (CLAHE) is particularly well-suited for images
with specific characteristics, where the distribution of pixel intensities varies across different
regions. It is often applied in scenarios where the limitations of standard Adaptive Histogram
Equalization (AHE) need to be addressed. Here are some scenarios in which CLAHE is commonly
used:
1. Medical Imaging:
• CLAHE is extensively used in medical imaging, including X-rays, CT scans, and
MRI images. It helps enhance contrast in different tissues and structures, addressing
variations in illumination and ensuring that the enhancement is controlled.
2. Satellite and Aerial Imaging:
• CLAHE is beneficial for satellite and aerial imagery where lighting conditions may
vary across the scene. It adapts to local characteristics, revealing details in both
shadowed and well-illuminated areas.
3. Microscopy:
• In microscopic images, CLAHE is applied to enhance contrast in regions with
varying intensity levels. This aids in better visualization of cellular structures and
details.
4. Underwater Imaging:
• CLAHE can be effective for improving the contrast in underwater images, where
lighting conditions may vary, and details may be obscured.
5. Low-Light or Night Vision Images:
• Images captured in low-light conditions or night vision scenarios may benefit from
CLAHE, which adapts to the varying levels of illumination while limiting the risk of
over-amplifying noise.
6. Heterogeneous Scenes:
• CLAHE is effective in enhancing contrast in images with regions of varying texture,
brightness, or contrast. It helps bring out details in each region independently.
7. Document Images with Varying Background Illumination:
• When dealing with scanned documents that have varying levels of background
illumination, CLAHE can be applied to enhance the visibility of text and details.
8. Remote Sensing:
• CLAHE is used in remote sensing applications to enhance contrast in images
captured by sensors on satellites or unmanned aerial vehicles (UAVs).
9. Dermatology:
• In dermatological images, where features such as moles and lesions may have
varying intensities, CLAHE can be employed for better visualization.
10.Outdoor Surveillance Images:
• For surveillance images captured outdoors, CLAHE can help enhance visibility in
different areas of the scene, considering variations in lighting.
11.Natural Scene Images:
• CLAHE can be applied to natural scene images with complex lighting conditions,
ensuring that the contrast enhancement is adapted to local variations.
In summary, CLAHE is particularly useful for images where the content is spatially heterogeneous,
and the goal is to enhance contrast while avoiding issues such as noise amplification and over-
amplification of intensities. It strikes a balance between local and global contrast enhancement,
making it versatile in various applications.
plt.subplot(1, 2, 1)
plt.imshow(image, cmap='gray')
plt.title('Original Image')
plt.subplot(1, 2, 2)
plt.imshow(equalized_image, cmap='gray')
plt.title('CLAHE')
plt.show()
plt.subplot(1, 2, 1)
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
plt.title('Original Image')
plt.subplot(1, 2, 2)
plt.imshow(cv2.cvtColor(equalized_image, cv2.COLOR_BGR2RGB))
plt.title('Color Histogram Equalization')
plt.show()
Conclusion
Histogram equalization is a powerful tool for enhancing image contrast, and understanding the
underlying mathematics is key to effectively applying it in image processing tasks. By following the
steps outlined in this blog post, you can gain insights into the process and improve the visual quality
of your images.
Experimenting with histogram equalization on different images and understanding its strengths and
limitations will empower you to make informed decisions in image processing applications.