@@ -0,0 +1,1659 @@
+import matplotlib.pyplot as plt%0Aimport matplotlib.image as mpimg%0Aimport numpy as np%0A%0A# Read in the image%0A# There are six more images available for reading%0A# called sample1-6.jpg, feel free to experiment with the others!%0Aimage_name = 'sample.jpg'%0Aimage = mpimg.imread(image_name)%0A%0A# Define a function to perform a color threshold%0Adef color_thresh(img, rgb_thresh=(0, 0, 0)):%0A    ###### TODO:%0A    # Create an empty array the same size in x and y as the image %0A    # but just a single channel%0A    color_select = np.zeros_like(img%5B:,:,0%5D)%0A    # Apply the thresholds for RGB and assign 1's %0A    # where threshold was exceeded%0A    above_thresh = (img%5B:,:,0%5D %3E rgb_thresh%5B0%5D) %5C%0A                & (img%5B:,:,1%5D %3E rgb_thresh%5B1%5D) %5C%0A                & (img%5B:,:,2%5D %3E rgb_thresh%5B2%5D)%0A    # Index the array of zeros with the boolean array and set to 1%0A    color_select%5Babove_thresh%5D = 1%0A%0A    # Return the single-channel binary image%0A    return color_select%0A    %0A# Define color selection criteria%0A###### TODO: MODIFY THESE VARIABLES TO MAKE YOUR COLOR SELECTION%0Ared_threshold = 150%0Agreen_threshold = 150%0Ablue_threshold = 150%0A######%0Argb_threshold = (red_threshold, green_threshold, blue_threshold)%0A%0A# pixels below the thresholds%0Acolorsel = color_thresh(image, rgb_thresh=rgb_threshold)%0A%0A# Display the original image and binary               %0Af, (ax1, ax2) = plt.subplots(1, 2, figsize=(21, 7), sharey=True)%0Af.tight_layout()%0Aax1.imshow(image)%0Aax1.set_title('Original Image', fontsize=40)%0A%0Aax2.imshow(colorsel, cmap='gray')%0Aax2.set_title('Your Result', fontsize=40)%0Aplt.subplots_adjust(left=0., right=1, top=0.9, bottom=0.)%0A#plt.show() # Uncomment if running on your local machine%0A

Create 1_color_threshold.py