Challenge - 5 Problems
Gaussian Filter Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Gaussian filter on a simple 2D array
What is the output of applying
gaussian_filter with sigma=1 to the following 2D array?SciPy
import numpy as np from scipy.ndimage import gaussian_filter arr = np.array([[0, 0, 0], [0, 10, 0], [0, 0, 0]]) result = gaussian_filter(arr, sigma=1) print(result.round(2))
Attempts:
2 left
💡 Hint
Think about how Gaussian smoothing spreads the value around neighbors.
✗ Incorrect
The Gaussian filter smooths the array by spreading the central high value to neighbors, reducing the peak and increasing nearby values. The output shows a blurred version with values less than 10 but spread around the center.
🧠 Conceptual
intermediate1:30remaining
Effect of increasing sigma in gaussian_filter
What happens to the output image when you increase the
sigma parameter in gaussian_filter?Attempts:
2 left
💡 Hint
Think about what smoothing means for an image.
✗ Incorrect
Increasing sigma increases the spread of the Gaussian kernel, causing more smoothing and thus a blurrier image.
🔧 Debug
advanced1:30remaining
Identify the error in gaussian_filter usage
What error will this code raise when run?
SciPy
from scipy.ndimage import gaussian_filter arr = [[1, 2], [3, 4]] result = gaussian_filter(arr, sigma='two') print(result)
Attempts:
2 left
💡 Hint
Check the type expected for sigma parameter.
✗ Incorrect
The sigma parameter must be a number or a sequence of numbers. Passing a string causes a TypeError.
❓ data_output
advanced1:30remaining
Number of unique values after gaussian_filter
Given this 1D array, how many unique values does the output have after applying
gaussian_filter with sigma=0.5?SciPy
import numpy as np from scipy.ndimage import gaussian_filter arr = np.array([0, 0, 10, 0, 0]) result = gaussian_filter(arr, sigma=0.5) unique_count = len(np.unique(result)) print(unique_count)
Attempts:
2 left
💡 Hint
Consider the symmetry of the array: edge positions are equal, next-to-center equal, center different.
✗ Incorrect
The output array has 3 distinct smoothed values because of symmetry: the two edge positions have the same value, the two adjacent to center have the same value, and the center is different.
🚀 Application
expert2:00remaining
Choosing sigma for edge preservation in image smoothing
You want to smooth an image using
gaussian_filter but keep edges sharp. Which sigma value strategy is best?Attempts:
2 left
💡 Hint
Less smoothing means edges stay sharper.
✗ Incorrect
Small sigma values apply minimal smoothing, preserving edges better than large sigma values which blur edges.