import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
%matplotlib inline
image = mpimg.imread('images/car_green_screen.jpg')
print('Image dimensions:', image.shape)
plt.imshow(image)
lower_green = np.array([0,200,0])
upper_green = np.array([255,255,255])
mask = cv2.inRange(image, lower_green, upper_green)
plt.imshow(mask, cmap='gray')
masked_image = np.copy(image)
masked_image[mask != 0] = [0, 0, 0]
plt.imshow(masked_image)
background_image = mpimg.imread('images/sky.jpg')
background_image = cv2.cvtColor(background_image, cv2.COLOR_BGR2RGB)
cropped_background = background_image[:450, :660]
cropped_background[mask == 0] = [0,0,0]
plt.imshow(cropped_background)
complete_image = masked_image + cropped_background
plt.imshow(complete_image)
