Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
SciPy - Image Processing (scipy.ndimage)
Identify the error in this code snippet:
import numpy as np
from scipy.ndimage import median_filter
arr = np.array([1, 2, 3, 4, 5])
result = median_filter(arr, size='3')
print(result)
Anumpy array must be 2D for median_filter
BSize parameter should be an integer, not a string
Cmedian_filter does not accept size parameter
DMissing import for uniform_filter
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter types for median_filter

    The size parameter must be an integer or tuple of integers, not a string. Passing '3' causes a type error.
  2. Step 2: Validate other options

    median_filter accepts size parameter; 1D arrays are valid; uniform_filter import is unrelated.
  3. Final Answer:

    Size parameter should be an integer, not a string -> Option B
  4. Quick Check:

    Size must be int, not string [OK]
Quick Trick: Size parameter must be int or tuple, not string [OK]
Common Mistakes:
  • Passing size as string
  • Assuming median_filter needs 2D array
  • Confusing median_filter with uniform_filter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes