Complete the code to convert an image from BGR to grayscale using OpenCV.
gray_image = cv2.cvtColor(color_image, [1])OpenCV uses BGR format by default, so to convert to grayscale, use cv2.COLOR_BGR2GRAY.
Complete the code to convert an image from BGR to HSV color space.
hsv_image = cv2.cvtColor(input_image, [1])Since OpenCV images are in BGR format, use cv2.COLOR_BGR2HSV to convert to HSV.
Fix the error in the code to convert an image from HSV back to BGR.
bgr_image = cv2.cvtColor(hsv_image, [1])To convert from HSV back to BGR, use cv2.COLOR_HSV2BGR.
Fill both blanks to create a dictionary comprehension that maps color names to their HSV ranges.
hsv_ranges = {color: ([1], [2]) for color in colors}The dictionary maps each color to a tuple of its lower and upper HSV bounds.
Fill all three blanks to create a mask for a color range and apply it to the image.
mask = cv2.inRange(hsv_image, [1], [2]) result = cv2.bitwise_and(original_image, original_image, mask=[3])
The mask is created using lower and upper HSV bounds, then applied to the original image using the mask.