Bird
0
0

You have a binary image with noise: small isolated pixels scattered randomly. How can you use connected component labeling with scipy to remove noise by keeping only components larger than 2 pixels?

hard📝 Application Q15 of 15
SciPy - Image Processing (scipy.ndimage)
You have a binary image with noise: small isolated pixels scattered randomly. How can you use connected component labeling with scipy to remove noise by keeping only components larger than 2 pixels?
ALabel components, count sizes, then remove components with size ≤ 2
BApply Gaussian blur before labeling to remove noise
CUse label function with parameter 'min_size=3' to filter components
DInvert the image and label the background instead
Step-by-Step Solution
Solution:
  1. Step 1: Label connected components in the binary image

    Use scipy.ndimage.label to assign unique labels to each connected group of pixels.
  2. Step 2: Count the size of each labeled component and filter

    Calculate the size of each component and remove those with size less than or equal to 2 pixels to eliminate noise.
  3. Final Answer:

    Label components, count sizes, then remove components with size ≤ 2 -> Option A
  4. Quick Check:

    Filter small components after labeling to remove noise [OK]
Quick Trick: Label, count sizes, remove small components to clean noise [OK]
Common Mistakes:
  • Expecting label() to filter by size automatically
  • Using image blur instead of component filtering
  • Inverting image does not remove noise directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes