Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of the gaussian_filter function in image processing?
The gaussian_filter smooths an image by reducing noise and detail using a Gaussian kernel, which blurs the image gently.
Click to reveal answer
beginner
What does the sigma parameter control in gaussian_filter?
The sigma parameter controls the amount of blurring. A larger sigma means more blur and smoothing.
Click to reveal answer
intermediate
How does gaussian_filter handle edges of an image by default?
By default, gaussian_filter uses 'reflect' mode, which mirrors the image edges to avoid artifacts during filtering.
Click to reveal answer
beginner
Write a simple Python code snippet using scipy.ndimage.gaussian_filter to blur a 2D image array named image with sigma=2.
from scipy.ndimage import gaussian_filter
blurred_image = gaussian_filter(image, sigma=2)
Click to reveal answer
intermediate
Why might you choose gaussian_filter over a simple average filter for image smoothing?
Because gaussian_filter weights nearby pixels more than distant ones, it preserves edges better and produces more natural blurring than a simple average filter.
Click to reveal answer
What effect does increasing the sigma value have in gaussian_filter?
AInverts the image colors
BSharpens the image
CIncreases the blur effect
DRemoves the image edges
✗ Incorrect
Increasing sigma increases the blur by spreading the Gaussian kernel wider.
Which library provides the gaussian_filter function?
Ascipy.ndimage
Bmatplotlib
Cnumpy
Dpandas
✗ Incorrect
gaussian_filter is part of the scipy.ndimage module.
What is the default mode for handling image edges in gaussian_filter?
Aconstant
Breflect
Cnearest
Dwrap
✗ Incorrect
The default mode is 'reflect', which mirrors the edges to reduce artifacts.
Which of these is a benefit of using a Gaussian filter over a simple mean filter?
AIt completely removes noise
BIt sharpens the image
CIt increases image contrast
DIt preserves edges better
✗ Incorrect
Gaussian filters weight pixels by distance, preserving edges better than mean filters.
If you want less blur with gaussian_filter, what should you do?
ADecrease sigma
BIncrease sigma
CIncrease image size
DUse a different image format
✗ Incorrect
Decreasing sigma reduces the blur effect.
Explain how the gaussian_filter works for image smoothing and why it is preferred over simple averaging.
Think about how weighting pixels differently affects the image.
You got /4 concepts.
Describe how you would apply gaussian_filter to a noisy image and what parameters you might adjust.
Focus on the function call and parameter roles.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using gaussian_filter in image processing?
easy
A. To detect edges in the image
B. To smooth the image by reducing noise
C. To convert the image to grayscale
D. To increase the image resolution
Solution
Step 1: Understand the function's role
gaussian_filter applies a blur effect that smooths the image by averaging nearby pixels weighted by a Gaussian curve.
Step 2: Identify the effect on image quality
This smoothing reduces noise and small details, making the image less sharp but cleaner.
Final Answer:
To smooth the image by reducing noise -> Option B
Quick Check:
Gaussian blur = noise reduction [OK]
Hint: Gaussian filter smooths images by blurring noise away [OK]
Common Mistakes:
Thinking it increases resolution
Confusing it with edge detection
Assuming it changes color format
2. Which of the following is the correct way to import and apply a Gaussian filter with sigma=2 to a 2D numpy array named image?
easy
A. from scipy.ndimage import gaussian_filter
filtered = gaussian_filter(image, sigma=2)
B. import scipy
filtered = scipy.gaussian_filter(image, 2)
C. from scipy import gaussian_filter
filtered = gaussian_filter(image, 2)
D. import gaussian_filter from scipy.ndimage
filtered = gaussian_filter(image, sigma=2)
Solution
Step 1: Check the correct import statement
The Gaussian filter is in scipy.ndimage, so import it with from scipy.ndimage import gaussian_filter.
Step 2: Verify function usage
Apply it by calling gaussian_filter(image, sigma=2) to blur with sigma 2.
Final Answer:
from scipy.ndimage import gaussian_filter
filtered = gaussian_filter(image, sigma=2) -> Option A
Quick Check:
Correct import and sigma usage = from scipy.ndimage import gaussian_filter
filtered = gaussian_filter(image, sigma=2) [OK]
Hint: Import from scipy.ndimage, use sigma as keyword [OK]
Common Mistakes:
Wrong import path for gaussian_filter
Passing sigma as positional without keyword
Using incorrect import syntax
3. Given the code below, what will be the output array after applying the Gaussian filter?
Hint: Gaussian blur spreads bright pixels softly to neighbors [OK]
Common Mistakes:
Expecting no change in array
Assuming uniform average instead of weighted blur
Misreading sigma effect as sharpening
4. Identify the error in the following code snippet that applies a Gaussian filter:
import numpy as np
from scipy.ndimage import gaussian_filter
image = np.ones((5,5))
filtered = gaussian_filter(image, sigma='2')
print(filtered)
medium
A. gaussian_filter cannot be applied to numpy arrays
B. The array shape is invalid for gaussian_filter
C. Missing import for numpy
D. sigma should be a number, not a string
Solution
Step 1: Check parameter types
The sigma parameter must be a numeric value (int or float), not a string.
Step 2: Identify the cause of error
Passing '2' as a string causes a type error when the filter tries to compute the blur.
Final Answer:
sigma should be a number, not a string -> Option D
Quick Check:
Numeric sigma required, string causes error [OK]
Hint: Use numeric sigma, not string, to avoid errors [OK]
Common Mistakes:
Passing sigma as string
Assuming gaussian_filter needs special array types
Ignoring import errors
5. You have a noisy grayscale image stored as a 2D numpy array. You want to smooth the image but keep edges relatively sharp. Which approach using gaussian_filter and its parameters is best?
hard
A. Apply gaussian_filter multiple times with sigma=3
B. Use a large sigma value like 5 to blur the image heavily
C. Use a small sigma value like 0.5 to reduce noise but preserve edges
D. Do not use gaussian_filter; use median filter instead
Solution
Step 1: Understand sigma effect on smoothing
Small sigma values cause light blur, preserving edges better than large sigma which blurs heavily.
Step 2: Choose best sigma for noise reduction and edge preservation
Using sigma=0.5 smooths noise but keeps edges sharper than larger sigma values or repeated blurring.
Final Answer:
Use a small sigma value like 0.5 to reduce noise but preserve edges -> Option C
Quick Check:
Small sigma = smooth noise + keep edges [OK]
Hint: Small sigma blurs less, preserving edges better [OK]