Complete the code to load an image using OpenCV.
import cv2 image = cv2.[1]('image.jpg')
The imread function loads an image from a file into memory.
Complete the code to convert a color image to grayscale using OpenCV.
gray_image = cv2.cvtColor(image, cv2.[1])COLOR_BGR2GRAY converts a color image from BGR to grayscale.
Fix the error in the code to display an image using OpenCV.
cv2.[1]('Image Window', image) cv2.waitKey(0) cv2.destroyAllWindows()
The imshow function displays an image in a window.
Fill both blanks to create a binary threshold on a grayscale image.
_, binary_image = cv2.threshold(gray_image, [1], [2], cv2.THRESH_BINARY)
The threshold value is 127 and the max value for the binary image is 255.
Fill all three blanks to create a dictionary comprehension that maps image filenames to their grayscale shapes.
shapes = {filename: cv2.imread(filename, [1]).shape[:[2]] for filename in files if cv2.imread(filename, [3]) is not None}Images are loaded in grayscale mode (IMREAD_GRAYSCALE), so shape has 2 dimensions (height, width).
