Bird
0
0

Which of the following code snippets correctly performs connected component labeling on a binary NumPy array img using SciPy?

easy📝 Conceptual Q3 of 15
SciPy - Image Processing (scipy.ndimage)
Which of the following code snippets correctly performs connected component labeling on a binary NumPy array img using SciPy?
Afrom scipy.ndimage import connected_components labeled_array, num_features = connected_components(img)
Bfrom scipy.ndimage import label labeled_array = label(img)
Cimport scipy.ndimage labeled_array, num_features = scipy.ndimage.connected_components(img)
Dfrom scipy.ndimage import label labeled_array, num_features = label(img)
Step-by-Step Solution
Solution:
  1. Step 1: Import the correct function

    The function is named label in scipy.ndimage.
  2. Step 2: Correct function call

    label(img) returns a tuple: labeled array and number of features.
  3. Final Answer:

    from scipy.ndimage import label\nlabeled_array, num_features = label(img) -> Option D
  4. Quick Check:

    label returns two outputs [OK]
Quick Trick: label returns labeled array and count [OK]
Common Mistakes:
  • Using nonexistent function connected_components
  • Not unpacking the tuple returned by label
  • Importing wrong functions or modules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes