Complete the code to save an image using OpenCV.
import cv2 image = cv2.imread('input.jpg') cv2.[1]('output.jpg', image)
The cv2.imwrite function saves an image to a file.
Complete the code to save a grayscale image using OpenCV.
import cv2 image = cv2.imread('input.jpg', [1]) cv2.imwrite('gray_output.jpg', image)
To read an image in grayscale, use cv2.IMREAD_GRAYSCALE as the flag.
Fix the error in saving an image with compression parameters.
import cv2 image = cv2.imread('input.jpg') cv2.imwrite('compressed.jpg', image, [1])
The compression parameters must be passed as a list of pairs: [flag, value].
Fill both blanks to save a PNG image with compression level 3.
import cv2 image = cv2.imread('input.png') cv2.imwrite('output.png', image, [[1], [2]])
Use cv2.IMWRITE_PNG_COMPRESSION flag with compression level 3 for PNG images.
Fill all three blanks to save a JPEG image with quality 85 and grayscale read.
import cv2 image = cv2.imread('input.jpg', [1]) cv2.imwrite('output.jpg', image, [[2], [3]])
Read the image in grayscale with cv2.IMREAD_GRAYSCALE, then save with JPEG quality 85 using cv2.IMWRITE_JPEG_QUALITY flag and value 85.
