Complete the code to read an image using OpenCV.
import cv2 image = cv2.[1]('image.jpg')
The cv2.imread function reads an image from a file into memory.
Complete the code to convert the image to grayscale.
gray = cv2.[1](image, cv2.COLOR_BGR2GRAY)cv2.cvtColor converts images between color spaces, here from BGR to grayscale.
Fix the error in the code to apply Canny edge detection.
edges = cv2.Canny(gray, [1], 150)
The first threshold must be a number, here 50, not a string or None.
Fill both blanks to display the edges image and wait for a key press.
cv2.[1]('Edges', edges) cv2.[2](0)
cv2.imshow shows the image window, and cv2.waitKey(0) waits indefinitely for a key press.
Fill all three blanks to save the edges image, close windows, and print success message.
cv2.[1]('edges_output.jpg', edges) cv2.[2]() print([3])
cv2.imwrite saves the image, cv2.destroyAllWindows() closes all windows, and print outputs the message.
