0
0
SciPydata~10 mins

Image filtering (gaussian_filter) 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 gaussian_filter function from scipy.ndimage.

SciPy
from scipy.ndimage import [1]
Drag options to blanks, or click blank then click option'
Amedian_filter
Bsobel_filter
Cgaussian_filter
Dlaplace_filter
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong filter function.
Forgetting to import from scipy.ndimage.
2fill in blank
medium

Complete the code to apply a Gaussian filter with sigma=2 to the image array named 'img'.

SciPy
blurred_img = gaussian_filter(img, sigma=[1])
Drag options to blanks, or click blank then click option'
A2
B10
C5
D0.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using sigma=0.5 which blurs very little.
Using too large sigma values that blur too much.
3fill in blank
hard

Fix the error in the code to correctly apply gaussian_filter to 'image' with sigma=1.5.

SciPy
filtered = gaussian_filter([1], sigma=1.5)
Drag options to blanks, or click blank then click option'
Aimage
Bpicture
Cimg
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that does not exist.
Typo in the variable name.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each pixel value to its square if the value is greater than 100.

SciPy
{pixel: pixel[1]2 for pixel in pixels if pixel [2] 100}
Drag options to blanks, or click blank then click option'
A**
B>
C<
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' instead of '**' for squaring.
Using '<' instead of '>' in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each pixel's string representation to its value if the value is less than 50.

SciPy
{str([1]): [2] for [3] in pixels if [2] < 50}
Drag options to blanks, or click blank then click option'
Apixel
Bvalue
Dpix
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not converting the pixel to string for the key.