Challenge - 5 Problems
Image Resizing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the shape of the resized image?
Given the following code that resizes an image using OpenCV, what will be the shape of the output image?
Computer Vision
import cv2 import numpy as np image = np.zeros((100, 200, 3), dtype=np.uint8) resized_image = cv2.resize(image, (50, 50)) print(resized_image.shape)
Attempts:
2 left
💡 Hint
Remember that OpenCV uses (width, height) for resizing and color images keep 3 channels.
✗ Incorrect
The original image has shape (100, 200, 3). The resize function uses (width, height) = (50, 50), so the output shape is (height, width, channels) = (50, 50, 3).
🧠 Conceptual
intermediate1:30remaining
Why resize images before training a model?
Why do we usually resize images to a fixed size before feeding them into a machine learning model?
Attempts:
2 left
💡 Hint
Think about how models expect input data shapes.
✗ Incorrect
Models require inputs of the same shape to process batches efficiently. Resizing ensures all images match the expected input size.
❓ Hyperparameter
advanced2:00remaining
Choosing interpolation method for resizing
Which interpolation method is best suited for enlarging images to preserve quality?
Attempts:
2 left
💡 Hint
Some methods are better for shrinking, others for enlarging.
✗ Incorrect
INTER_CUBIC uses bicubic interpolation which produces smoother results when enlarging images compared to INTER_LINEAR or INTER_NEAREST.
🔧 Debug
advanced2:00remaining
Why does this resizing code raise an error?
What error will this code raise and why?
import cv2
import numpy as np
image = np.zeros((100, 100, 3), dtype=np.uint8)
resized = cv2.resize(image, (0, 0), fx=2, fy=2)
print(resized.shape)
Attempts:
2 left
💡 Hint
Check OpenCV documentation for resize parameters.
✗ Incorrect
When size is (0, 0), OpenCV uses fx and fy to scale the image. So no error occurs and output shape doubles.
❓ Metrics
expert2:30remaining
Effect of resizing on model accuracy
You train two image classifiers: one with images resized to 64x64, another with 256x256. Which is the most likely outcome?
Attempts:
2 left
💡 Hint
Consider trade-offs between image detail and model complexity.
✗ Incorrect
Larger images provide more detail but increase model complexity and training time, which can cause overfitting if data is limited.