0
0
SciPydata~10 mins

Image interpolation in SciPy - Interactive Code Practice

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

Complete the code to import the interpolation function from scipy.

SciPy
from scipy import [1]
Drag options to blanks, or click blank then click option'
Aintegrate
Boptimize
Csignal
Dinterpolate
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong scipy submodule like optimize or integrate.
Forgetting to import the interpolate module.
2fill in blank
medium

Complete the code to create a 2D interpolation function from image data.

SciPy
interp_func = scipy.interpolate.RegularGridInterpolator((x, y), [1])
Drag options to blanks, or click blank then click option'
Ax
Binterp_func
Cimage_data
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Passing coordinate arrays instead of image data.
Using the interpolation function variable itself as input.
3fill in blank
hard

Fix the error in the code to interpolate the image at new points.

SciPy
new_values = interp_func([1])
Drag options to blanks, or click blank then click option'
A[[x_new, y_new]]
B[x_new, y_new]
C(x_new, y_new)
Dx_new, y_new
Attempts:
3 left
💡 Hint
Common Mistakes
Passing coordinates as a tuple or flat list instead of a 2D array.
Not wrapping the coordinates in an outer list.
4fill in blank
hard

Fill both blanks to create a dictionary of interpolated pixel values for points where x is greater than 5.

SciPy
interp_points = {point: interp_func([point])[1] point in points if point[0] [2] 5}
Drag options to blanks, or click blank then click option'
A for
B >
C <
D if
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'if' instead of 'for' for the loop.
Using '<' instead of '>' for the condition.
5fill in blank
hard

Fill all three blanks to create a new image by interpolating at scaled coordinates.

SciPy
scaled_image = [1]([2] * scale_factor, [3] * scale_factor, method='linear')
Drag options to blanks, or click blank then click option'
Ascipy.interpolate.interpn
Bx_coords
Cy_coords
Dimage_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using the image data as the first argument instead of the interpolation function.
Not scaling both x and y coordinates.
Using the wrong interpolation method.