<jupyter_start><jupyter_text>HSV colorspace  Import resources<jupyter_code>import matplotlib.pyplot as plt
import matplotlib.image as mpimg

import numpy as np
import cv2

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Read in RGB image<jupyter_code># Read in the image
image = mpimg.imread('images/car_green_screen2.jpg')

plt.imshow(image)<jupyter_output><empty_output><jupyter_text>RGB threshold Visualize the green threshold you defined in the previous, consistent green color case.<jupyter_code># Define our color selection boundaries in RGB values
lower_green = np.array([0,180,0]) 
upper_green = np.array([100,255,100])

# Define the masked area
mask = cv2.inRange(image, lower_green, upper_green)

# Mask the image to let the car show through
masked_image = np.copy(image)

masked_image[mask != 0] = [0, 0, 0]

# Display it!
plt.imshow(masked_image)<jupyter_output><empty_output><jupyter_text>Convert to HSV<jupyter_code># Convert to HSV
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)

# HSV channels
h = hsv[:,:,0]
s = hsv[:,:,1]
v = hsv[:,:,2]

# Visualize the individual color channels
f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(20,10))
ax1.set_title('H channel')
ax1.imshow(h, cmap='gray')
ax2.set_title('S channel')
ax2.imshow(s, cmap='gray')
ax3.set_title('V channel')
ax3.imshow(v, cmap='gray')<jupyter_output><empty_output><jupyter_text>TODO: Mask the green area using HSV color space<jupyter_code># Define our color selection boundaries in HSV values

## TODO: Change these thresholds
# This initial threshold allows a certain low range for Hue (H)
lower_hue = np.array([0,0,0]) 
upper_hue = np.array([100,255,255])

# Define the masked area
mask = cv2.inRange(image, lower_hue, upper_hue)

# Mask the image to let the car show through
masked_image = np.copy(image)

masked_image[mask != 0] = [0, 0, 0]

# Display it!
plt.imshow(masked_image)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12211740041928722, 'fraction_numerical': 0.030922431865828093, 'mean_word_length': 6.486274509803922, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '16744', 'license': 'MIT', 'n_tokens_mistral': 750, 'n_tokens_neox': 713, 'n_words': 184, 'path': '1_1_Image_Representation/.ipynb_checkpoints/5_2. Green screen, HSV conversion-checkpoint.ipynb', 'repo_name': 'adl-aleb/ComputerVision_ND-', 'size': '1908'}