<aside> 💡 Tip: Click any section in the Wiki Headers underneath this notice, it will take you right to the corresponding section!

</aside>

Import Block

import os
import cv2
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import exifread
import pandas as pd
from IPython.display import display_html
import locale
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
locale.setlocale(locale.LC_ALL, '')

Singapore July 2023 Week-Long Shoot (Neon Child)

Hue, Saturation & Brightness

# Specify the path to the folder containing CR2 images
folder_path = "Box/RAW - 2023 Personal Photos/Singapore July 2023"

# Initialize histograms for hue, saturation, and brightness
hue_hist = np.zeros(180, dtype=int)
saturation_hist = np.zeros(256, dtype=int)
brightness_hist = np.zeros(256, dtype=int)

# Iterate through all CR2 images in the folder
for filename in os.listdir(folder_path):
  if filename.endswith(".CR2"):
    try:
      # Open the image using PIL for proper CR2 support
      image = Image.open(os.path.join(folder_path, filename))

      # Convert to RGB color space if needed
      if image.mode != "RGB":
        image = image.convert("RGB")

      # Convert to NumPy array for processing
      image_array = np.array(image)

      # Convert to HSV color space
      hsv_image = cv2.cvtColor(image_array, cv2.COLOR_RGB2HSV)

      # Separate hue, saturation, and brightness channels
      hue, saturation, brightness = cv2.split(hsv_image)

      # Flatten the channels for easier histogram calculation
      hue_flat = hue.flatten()
      saturation_flat = saturation.flatten()
      brightness_flat = brightness.flatten()

      # Update the histograms based on pixel counts
      hue_hist += np.bincount(hue_flat, minlength=180)
      saturation_hist += np.bincount(saturation_flat, minlength=256)
      brightness_hist += np.bincount(brightness_flat, minlength=256)

    except Exception as e:
      print(f"Error processing {filename}: {e}")

# Create the hue histogram with color-mapped bins
plt.figure(figsize=(20, 10))
plt.title("Histogram of Hues of tremolo_truong's Singapore July 2023 Shoot")
plt.xlabel("Hue Value")
plt.ylabel("Pixel Count")
plt.xlim(0,180)
plt.bar(np.arange(180), hue_hist, color=plt.cm.hsv(np.arange(180) / 180))
plt.show()

purple = plt.get_cmap('Purples')
gray = plt.get_cmap('gray')
purples = purple(np.linspace(0,1,256))
grays = gray(np.linspace(0,1,256))

# Create the saturation histogram with custom colormap
plt.figure(figsize=(20, 10))
plt.title("Histogram of Saturations of tremolo_truong's Singapore July 2023 Shoot")
plt.xlabel("Saturation Value")
plt.ylabel("Pixel Count")
plt.xlim(0,255)
plt.bar(np.arange(256), saturation_hist, color=purples)
plt.show()

# Create the brightness histogram with custom colormap
plt.figure(figsize=(20, 10))
plt.title("Histogram of Brightnesses of tremolo_truong's Singapore July 2023 Shoot")
plt.xlabel("Brightness Value")
plt.ylabel("Pixel Count")
plt.xlim(0,255)
plt.bar(np.arange(256), brightness_hist, color=grays)
plt.show()

Untitled

Untitled

Untitled

Downtown Austin September 2023 Shoot (Unreleased Album)

Hue, Saturation & Brightness

# Specify the path to the folder containing CR2 images
folder_path_1 = "Box/RAW - 2023 Personal Photos/Downtown Austin Sept 2023"

# Initialize histograms for hue, saturation, and brightness
hue_hist_1 = np.zeros(180, dtype=int)
saturation_hist_1 = np.zeros(256, dtype=int)
brightness_hist_1 = np.zeros(256, dtype=int)

# Iterate through all CR2 images in the folder
for filename in os.listdir(folder_path_1):
  if filename.endswith(".CR2"):
    try:
      # Open the image using PIL for proper CR2 support
      image = Image.open(os.path.join(folder_path_1, filename))

      # Convert to RGB color space if needed
      if image.mode != "RGB":
        image = image.convert("RGB")

      # Convert to NumPy array for processing
      image_array = np.array(image)

      # Convert to HSV color space
      hsv_image = cv2.cvtColor(image_array, cv2.COLOR_RGB2HSV)

      # Separate hue, saturation, and brightness channels
      hue, saturation, brightness = cv2.split(hsv_image)

      # Flatten the channels for easier histogram calculation
      hue_flat = hue.flatten()
      saturation_flat = saturation.flatten()
      brightness_flat = brightness.flatten()

      # Update the histograms based on pixel counts
      hue_hist_1 += np.bincount(hue_flat, minlength=180)
      saturation_hist_1 += np.bincount(saturation_flat, minlength=256)
      brightness_hist_1 += np.bincount(brightness_flat, minlength=256)

    except Exception as e:
      print(f"Error processing {filename}: {e}")

# Create the hue histogram with color-mapped bins
plt.figure(figsize=(20, 10))
plt.title("Histogram of Hues of tremolo_truong's Austin September 2023 Shoot")
plt.xlabel("Hue Value")
plt.ylabel("Pixel Count")
plt.xlim(0,180)
plt.bar(np.arange(180), hue_hist_1, color=plt.cm.hsv(np.arange(180) / 180))
plt.show()

# The saturation and brightness colormaps are already declared above, so are available for use in this chunk as well

# Create the saturation histogram with custom colormap
plt.figure(figsize=(20, 10))
plt.title("Histogram of Saturations of tremolo_truong's Austin September 2023 Shoot")
plt.xlabel("Saturation Value")
plt.ylabel("Pixel Count")
plt.xlim(0,255)
plt.bar(np.arange(256), saturation_hist_1, color=purples)
plt.show()

# Create the brightness histogram with custom colormap
plt.figure(figsize=(20, 10))
plt.title("Histogram of Brightnesses of tremolo_truong's Austin September 2023 Shoot")
plt.xlabel("Brightness Value")
plt.ylabel("Pixel Count")
plt.xlim(0,255)
plt.bar(np.arange(256), brightness_hist_1, color=grays)
plt.show()

Untitled

Untitled

Untitled

Hoi An Ancient Town June 2022 Shoot (Unreleased Album)