Bird
0
0

Which of the following is the correct way to apply the Sobel filter on a 2D image array named img using SciPy?

easy📝 Syntax Q12 of 15
SciPy - Image Processing (scipy.ndimage)
Which of the following is the correct way to apply the Sobel filter on a 2D image array named img using SciPy?
Ascipy.ndimage.sobel(img, axis=2)
Bscipy.ndimage.laplace(img, axis=1)
Cscipy.ndimage.sobel(img, axis=0)
Dscipy.ndimage.gaussian_filter(img, sigma=1)
Step-by-Step Solution
Solution:
  1. Step 1: Recall Sobel filter usage in SciPy

    The Sobel filter is applied using scipy.ndimage.sobel with the image and axis (0 for vertical, 1 for horizontal).
  2. Step 2: Check axis validity

    For a 2D image, valid axes are 0 or 1. Axis=2 is invalid and will cause an error.
  3. Final Answer:

    scipy.ndimage.sobel(img, axis=0) -> Option C
  4. Quick Check:

    Sobel syntax = scipy.ndimage.sobel(img, axis) [OK]
Quick Trick: Use axis 0 or 1 for 2D images with sobel [OK]
Common Mistakes:
  • Using axis=2 on 2D images causes errors
  • Confusing laplace and sobel functions
  • Using gaussian_filter instead of sobel for edges

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes