<jupyter_start><jupyter_text>Color Threshold, Blue Screen  Import resources<jupyter_code># import matplotlib.pyplot as plt
# import numpy as np
# import cv2

# %matplotlib inline

#########

import matplotlib.pyplot as plt
import numpy as np
import cv2

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Read in and display the image<jupyter_code># # Read in the image
# image = cv2.imread('images/pizza_bluescreen.jpg')

# # Print out the type of image data and its dimensions (height, width, and color)
# print('This image is:', type(image), 
#       ' with dimensions:', image.shape)

#########################
# Read in  the image
image = cv2.imread('images/pizza_bluescreen.jpg')

# Print out the type of the image data and its dimensions (height, width, and color)
print('this image is:', type(image),
     'with dimensions:', image.shape)
# # Make a copy of the image
# image_copy = np.copy(image)

# # Change color to RGB (from BGR)
# image_copy = cv2.cvtColor(image_copy, cv2.COLOR_BGR2RGB)

# # Display the image copy
# plt.imshow(image_copy)

#########################################################################

# it's good practicce to always copy the image



image_copy = np.copy(image)

# change color to RGB (from BGR)
image_copy = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# display the image copy
plt.imshow(image_copy)<jupyter_output><empty_output><jupyter_text>Define the color threshold<jupyter_code># ## TODO: Define the color selection boundaries in RGB values
# # play around with these values until you isolate the blue background
# lower_blue = np.array([0,0,200]) 
# upper_blue = np.array([250,250,255])

###########################################

# array in RGB format
lower_blue = np.array([0,0,220])
upper_blue = np.array([70,70,255])<jupyter_output><empty_output><jupyter_text>Create a masksemua warna kecuali biru dijadiin hitam.selecting area of interest<jupyter_code># # Define the masked area
# mask = cv2.inRange(image_copy, lower_blue, upper_blue)

# # Vizualize the mask
# plt.imshow(mask, cmap='gray')

##############

mask = cv2.inRange(image_copy, lower_blue, upper_blue)

# visualize the mask
plt.imshow(mask, cmap = 'gray')
# # Mask the image to let the pizza show through
# masked_image = np.copy(image_copy)

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

# # Display it!
# plt.imshow(masked_image)

##################################################

# mask the image to let the pizza show through
masked_image = np.copy(image_copy)
masked_image[mask != 0] = [0,0,0]

plt.imshow(masked_image)<jupyter_output><empty_output><jupyter_text>Mask and add a background image<jupyter_code># # Load in a background image, and convert it to RGB 
# background_image = cv2.imread('images/space_background.jpg')
# background_image = cv2.cvtColor(background_image, cv2.COLOR_BGR2RGB)

# # Crop it to the right size (514x816)
# crop_background = background_image[0:514, 0:816]

# # Mask the cropped background so that the pizza area is blocked
# crop_background[mask == 0] = [0, 0, 0]

# # Display the background
# plt.imshow(crop_background)

##################################################################

# load in a background image, and convert it to RGB
background_image = cv2.imread('images/space_background.jpg')
background_image = cv2.cvtColor(background_image, cv2.COLOR_BGR2RGB)

# Crop it to the right size 
crop_background = background_image[0:514, 0:816]

# Mask the cropped background so that the pizza area is blocked
crop_background[mask == 0] = [0,0,0]

# display the background
plt.imshow(crop_background)<jupyter_output><empty_output><jupyter_text>Create a complete image<jupyter_code># # Add the two images together to create a complete image!
# complete_image = masked_image + crop_background

# # Display the result
# plt.imshow(complete_image)

####################################

# add the two images together to create a complete image
complete_image = masked_image + crop_background

# display the result
plt.imshow(complete_image)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17323420074349444, 'fraction_numerical': 0.020817843866171002, 'mean_word_length': 6.006944444444445, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '380654', 'license': 'Apache-2.0', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1312, 'n_words': 367, 'path': '03-Blue Screen.ipynb', 'repo_name': 'brdx88/cv_udacity_notebook', 'size': '4035'}