0
0
Computer Visionml~20 mins

Writing/saving images in Computer Vision - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Image Saving Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this OpenCV image saving code?
Consider the following Python code using OpenCV to save an image. What will be the output or result after running this code?
Computer Vision
import cv2
import numpy as np

img = np.zeros((100, 100, 3), dtype=np.uint8)
cv2.imwrite('test_image.png', img)
print(cv2.imread('test_image.png').shape)
A(100, 100, 3)
B(100, 100)
CNone
DError: File not found
Attempts:
2 left
💡 Hint
Remember that OpenCV reads color images as 3-channel arrays by default.
Model Choice
intermediate
1:00remaining
Which image format is best for saving photos with lossless quality?
You want to save images without losing any quality for further machine learning processing. Which image format should you choose?
AJPEG
BBMP
CGIF
DPNG
Attempts:
2 left
💡 Hint
Consider which formats compress images without losing data.
Hyperparameter
advanced
1:30remaining
What does the 'quality' parameter control when saving JPEG images with OpenCV?
In OpenCV's cv2.imwrite function, you can specify parameters like cv2.IMWRITE_JPEG_QUALITY. What does this parameter control?
AThe compression level affecting image quality and file size
BThe color depth of the saved image
CThe image resolution in pixels
DThe file permissions of the saved image
Attempts:
2 left
💡 Hint
Think about how JPEG compression works.
🔧 Debug
advanced
1:30remaining
Why does this code fail to save the image correctly?
Look at this code snippet: import cv2 import numpy as np img = np.zeros((50, 50), dtype=np.uint8) cv2.imwrite('output.jpg', img) Why might the saved image appear as a black and white image instead of color?
AThe numpy array dtype must be float32 for color images
BThe file extension '.jpg' is incorrect for color images
CThe image array has only one channel, so it saves as grayscale
Dcv2.imwrite requires images to be in RGB order, not BGR
Attempts:
2 left
💡 Hint
Check the shape of the numpy array representing the image.
🧠 Conceptual
expert
2:00remaining
What is the main difference between cv2.imwrite and PIL.Image.save when saving images?
Both OpenCV's cv2.imwrite and PIL's Image.save can save images. What is a key difference in how they handle image data before saving?
AOpenCV only saves grayscale images, PIL saves color images
BOpenCV expects images in BGR format, PIL expects RGB format
CPIL compresses images automatically, OpenCV does not
DOpenCV saves images as numpy arrays, PIL saves as tensors
Attempts:
2 left
💡 Hint
Think about the color channel order each library uses.