Enhance Contrast Of Color Image


# Load image
import cv2
import numpy as np
from matplotlib import pyplot as plt

Load Image

# Load image
image_bgr = cv2.imread('images/plane.jpg')

Convert Image To YUV Color Format

# Convert to YUV
image_yuv = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2YUV)

Enhance Image

# Apply histogram equalization
image_yuv[:, :, 0] = cv2.equalizeHist(image_yuv[:, :, 0])

Convert To RGB

# Convert to RGB
image_rgb = cv2.cvtColor(image_yuv, cv2.COLOR_YUV2RGB)

View Image

# Show image
plt.imshow(image_rgb), plt.axis("off")