Bird
0
0

What is wrong with this code that tries to get the blue channel?

medium📝 Debug Q7 of 15
Matplotlib - Image Display
What is wrong with this code that tries to get the blue channel?
blue_channel = img[:, :, 3]
ABlue channel is not in the last dimension
BIndex 3 is out of bounds for color channels
CMissing parentheses in slicing
DShould use img[:, :, 0] for blue
Step-by-Step Solution
Solution:
  1. Step 1: Check color channel indices

    RGB images have channels indexed 0,1,2 only.
  2. Step 2: Identify index error

    Index 3 is out of range and causes an error.
  3. Final Answer:

    Index 3 is out of bounds for color channels -> Option B
  4. Quick Check:

    Valid channel indices: 0,1,2 only [OK]
Quick Trick: Channel indices go from 0 to 2 in RGB images [OK]
Common Mistakes:
  • Using index 3 for blue
  • Confusing channel order
  • Assuming 4 channels exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes