Challenge - 5 Problems
Image Interpolation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of resizing an image with scipy.ndimage.zoom
What is the shape of the output image after applying
scipy.ndimage.zoom with a zoom factor of 2 on a 2D grayscale image of shape (50, 50)?SciPy
import numpy as np from scipy.ndimage import zoom image = np.ones((50, 50)) zoomed_image = zoom(image, 2) print(zoomed_image.shape)
Attempts:
2 left
💡 Hint
Think about how zoom factor affects each dimension size.
✗ Incorrect
The zoom factor of 2 doubles each dimension size, so (50, 50) becomes (100, 100).
🧠 Conceptual
intermediate1:30remaining
Understanding interpolation order in scipy.ndimage.zoom
Which interpolation order in
scipy.ndimage.zoom corresponds to cubic spline interpolation?Attempts:
2 left
💡 Hint
Order 0 is nearest neighbor, order 1 is linear.
✗ Incorrect
Order 3 corresponds to cubic spline interpolation in scipy.ndimage.zoom.
❓ data_output
advanced2:00remaining
Resulting pixel value after zoom with linear interpolation
Given a 1D array
arr = np.array([0, 10, 20]), what is the output of scipy.ndimage.zoom(arr, 2, order=1)?SciPy
import numpy as np from scipy.ndimage import zoom arr = np.array([0, 10, 20]) result = zoom(arr, 2, order=1) print(result)
Attempts:
2 left
💡 Hint
Linear interpolation fills values evenly between points.
✗ Incorrect
Zoom with factor 2 and linear interpolation doubles points, interpolating linearly between original values.
🔧 Debug
advanced2:00remaining
Identify the error in zooming a color image
What error occurs when running this code to zoom a color image with shape (100, 100, 3) using
scipy.ndimage.zoom(image, 2)?SciPy
import numpy as np from scipy.ndimage import zoom image = np.ones((100, 100, 3)) zoomed = zoom(image, 2) print(zoomed.shape)
Attempts:
2 left
💡 Hint
Check how zoom interprets a single float for multi-dimensional arrays.
✗ Incorrect
Passing a single float applies zoom to all axes, including color channels, doubling channels from 3 to 6.
🚀 Application
expert1:30remaining
Choosing correct zoom parameters for RGB image resizing
You want to resize an RGB image of shape (120, 160, 3) to double its width and height but keep color channels unchanged using
scipy.ndimage.zoom. Which zoom parameter is correct?Attempts:
2 left
💡 Hint
Color channels should not be scaled.
✗ Incorrect
Zoom factor must be a tuple matching array dimensions; spatial axes doubled, channel axis kept 1.