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

"""
Explanation: Title: Enhance Contrast Of Color Image
Slug: enhance_contrast_of_color_image
Summary: How to enhance the contrast of images using OpenCV in Python.   
Date: 2017-09-11 12:00
Category: Machine Learning
Tags: Preprocessing Images  
Authors: Chris Albon
Preliminaries
End of explanation
"""


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

"""
Explanation: Load Image
End of explanation
"""


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

"""
Explanation: Convert Image To YUV Color Format
End of explanation
"""


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

"""
Explanation: Enhance Image
End of explanation
"""


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

"""
Explanation: Convert To RGB
End of explanation
"""


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

"""
Explanation: View Image
End of explanation
"""


