Helper Functions:
Main Script:
import cv2
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import requests
from io import BytesIO
!wget <https://raw.githubusercontent.com/yyhtbs-yye/data4wget/main/images/image_proc_lenna.png>
# Load image from URL
image = Image.open("image_proc_lenna.png")
image = np.array(image)
# Convert RGB to HSV
image_hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
image_hsv_float = uint82float(image_hsv, is_hsv=True)
hue_gamma = 1.5 # Adjust this gamma value for experimentation
# Copy the floating point image as an output initialization
image_hsv_corrected_float = image_hsv_float.copy()
# Apply gamma correction to hue only
image_hsv_corrected_float[:, :, 0] = (image_hsv_float[:, :, 0] ** hue_gamma)
image_hsv_corrected = float2uint8(image_hsv_corrected_float, is_hsv=True)
image_rgb_corrected = cv2.cvtColor(image_hsv_corrected, cv2.COLOR_HSV2RGB)
# Plot original and corrected images side by side
plt.figure(figsize=(12, 6))
# Original image
plt.subplot(1, 2, 1)
plt.title("Original Image")
plt.imshow(image)
# Corrected image
plt.subplot(1, 2, 2)
plt.title("Gamma Corrected Image")
plt.imshow(image_rgb_corrected)
plt.show()

plot_image_histogram_rgb(image)
plot_image_histogram_rgb(image_rgb_corrected)


plot_image_histogram_hue(image)
plot_image_histogram_hue(image_rgb_corrected)
