Complete the code to load an image using OpenCV.
import cv2 image = cv2.[1]('road.jpg')
The imread function loads an image from a file into memory.
Complete the code to convert a color image to grayscale.
gray_image = cv2.cvtColor(image, [1])The cv2.COLOR_BGR2GRAY flag converts a color image to grayscale.
Fix the error in the code to detect edges using Canny edge detector.
edges = cv2.Canny(image, [1], 150)
The Canny function requires numeric thresholds. Using a string or None causes errors.
Fill both blanks to create a dictionary comprehension that maps image names to their sizes if width {{BLANK_1}} 500 and height {{BLANK_2}} 500.
sizes = {name: (img.shape[1], img.shape[0]) for name, img in images.items() if img.shape[1] [1] 500 and img.shape[0] [2] 500}The code filters images with width greater than 500 and height less than 500.
Fill all three blanks to create a dictionary comprehension that maps patient IDs to their diagnosis if confidence {{BLANK_1}} 0.8 and diagnosis {{BLANK_2}} 'positive' and patient ID {{BLANK_3}} starts with 'P'.
results = {pid: diag for pid, (diag, conf) in data.items() if conf [1] 0.8 and diag [2] 'positive' and pid.[3]('P')}The code filters patients with confidence at least 0.8, diagnosis equal to 'positive', and IDs starting with 'P'.