0
0
Computer Visionml~10 mins

Writing/saving images in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to save an image using OpenCV.

Computer Vision
import cv2
image = cv2.imread('input.jpg')
cv2.[1]('output.jpg', image)
Drag options to blanks, or click blank then click option'
Aresize
Bimshow
Cimwrite
Dimread
Attempts:
3 left
💡 Hint
Common Mistakes
Using cv2.imshow instead of cv2.imwrite.
Trying to read the image again instead of saving.
2fill in blank
medium

Complete the code to save a grayscale image using OpenCV.

Computer Vision
import cv2
image = cv2.imread('input.jpg', [1])
cv2.imwrite('gray_output.jpg', image)
Drag options to blanks, or click blank then click option'
Acv2.IMREAD_UNCHANGED
Bcv2.IMREAD_GRAYSCALE
Ccv2.IMREAD_COLOR
Dcv2.COLOR_BGR2GRAY
Attempts:
3 left
💡 Hint
Common Mistakes
Using color conversion codes instead of read flags.
Using IMREAD_COLOR which reads a color image.
3fill in blank
hard

Fix the error in saving an image with compression parameters.

Computer Vision
import cv2
image = cv2.imread('input.jpg')
cv2.imwrite('compressed.jpg', image, [1])
Drag options to blanks, or click blank then click option'
A[cv2.IMWRITE_JPEG_QUALITY, 90]
Bcv2.IMWRITE_JPEG_QUALITY=90
C{cv2.IMWRITE_JPEG_QUALITY: 90}
D(cv2.IMWRITE_JPEG_QUALITY, 90)
Attempts:
3 left
💡 Hint
Common Mistakes
Passing parameters as a dictionary or tuple.
Using assignment syntax inside the function call.
4fill in blank
hard

Fill both blanks to save a PNG image with compression level 3.

Computer Vision
import cv2
image = cv2.imread('input.png')
cv2.imwrite('output.png', image, [[1], [2]])
Drag options to blanks, or click blank then click option'
Acv2.IMWRITE_PNG_COMPRESSION
Bcv2.IMWRITE_JPEG_QUALITY
C3
D90
Attempts:
3 left
💡 Hint
Common Mistakes
Using JPEG flags for PNG images.
Passing quality value instead of compression level.
5fill in blank
hard

Fill all three blanks to save a JPEG image with quality 85 and grayscale read.

Computer Vision
import cv2
image = cv2.imread('input.jpg', [1])
cv2.imwrite('output.jpg', image, [[2], [3]])
Drag options to blanks, or click blank then click option'
Acv2.IMREAD_GRAYSCALE
Bcv2.IMWRITE_JPEG_QUALITY
C85
Dcv2.IMREAD_COLOR
Attempts:
3 left
💡 Hint
Common Mistakes
Using color read flag instead of grayscale.
Mixing PNG compression flags with JPEG quality.