Bird
0
0

What will be the output shape of the following code snippet?

medium📝 Predict Output Q4 of 15
SciPy - Image Processing (scipy.ndimage)
What will be the output shape of the following code snippet?
import numpy as np
from scipy.ndimage import sobel
image = np.zeros((5,5))
edges = sobel(image, axis=0)
print(edges.shape)
A(4, 5)
B(6, 5)
C(5, 4)
D(5, 5)
Step-by-Step Solution
Solution:
  1. Step 1: Understand input image shape

    The input image is a 5x5 array.
  2. Step 2: Check Sobel output shape behavior

    Sobel filter returns an array of the same shape as input, preserving dimensions.
  3. Final Answer:

    (5, 5) -> Option D
  4. Quick Check:

    Sobel output shape = input shape [OK]
Quick Trick: Sobel output shape matches input shape [OK]
Common Mistakes:
  • Assuming output shrinks by 1 pixel
  • Confusing axis parameter effect on shape
  • Expecting output to expand shape

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes