Bird
0
0

What is the output of this code?

medium📝 Predict Output Q4 of 15
SciPy - Image Processing (scipy.ndimage)
What is the output of this code?
import numpy as np
from scipy.ndimage import gaussian_filter

img = np.array([[0, 0, 0], [0, 20, 0], [0, 0, 0]])
result = gaussian_filter(img, sigma=0.5)
print(np.round(result, 1))
A[[0.7 1.6 0.7] [1.6 4.0 1.6] [0.7 1.6 0.7]]
B[[0.0 0.0 0.0] [0.0 20.0 0.0] [0.0 0.0 0.0]]
C[[2.0 3.0 2.0] [3.0 20.0 3.0] [2.0 3.0 2.0]]
D[[0.1 0.2 0.1] [0.2 20.0 0.2] [0.1 0.2 0.1]]
Step-by-Step Solution
Solution:
  1. Step 1: Understand input

    Input is a 3x3 array with a single bright pixel (20) in the center.
  2. Step 2: Effect of gaussian_filter with sigma=0.5

    Small sigma means slight smoothing, spreading the center value to neighbors.
  3. Step 3: Expected output

    The center value reduces, neighbors get small values. Rounded to 1 decimal place, values resemble [[0.7 1.6 0.7] [1.6 4.0 1.6] [0.7 1.6 0.7]].
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Small sigma blurs center pixel slightly [OK]
Quick Trick: Small sigma blurs center pixel slightly [OK]
Common Mistakes:
  • Expecting no change with sigma=0.5
  • Assuming output equals input
  • Misunderstanding rounding effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes