Bird
0
0

You have a noisy 2D image array with salt-and-pepper noise. Which filter and parameters would best reduce noise while preserving edges?

hard📝 Application Q15 of 15
SciPy - Image Processing (scipy.ndimage)
You have a noisy 2D image array with salt-and-pepper noise. Which filter and parameters would best reduce noise while preserving edges?
import numpy as np
from scipy.ndimage import median_filter, uniform_filter

image = np.array([[10, 10, 10, 10],
                  [10, 255, 10, 10],
                  [10, 10, 10, 10],
                  [10, 10, 10, 10]])
AUse median_filter with size=3 to remove salt-and-pepper noise
BUse uniform_filter with size=3 to blur the image
CUse median_filter with size=1 to keep image unchanged
DUse uniform_filter with size=1 to sharpen edges
Step-by-Step Solution
Solution:
  1. Step 1: Understand noise type and filter effects

    Salt-and-pepper noise is best removed by median filters because they replace each pixel with the median of neighbors, preserving edges.
  2. Step 2: Evaluate filter choices and parameters

    Median_filter with size=3 covers neighbors and removes noise spikes. Uniform_filter averages and blurs edges, not ideal here. Size=1 means no change.
  3. Final Answer:

    Use median_filter with size=3 to remove salt-and-pepper noise -> Option A
  4. Quick Check:

    Median filter + size=3 removes salt-and-pepper noise [OK]
Quick Trick: Median filter removes salt-and-pepper noise best [OK]
Common Mistakes:
  • Using uniform filter which blurs edges
  • Using size=1 which does nothing
  • Confusing noise types and filter effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes