Bird
0
0

You want to display a 2D numpy array as an image but only show pixel values between 50 and 200. Which imshow parameters help achieve this?

hard📝 Application Q9 of 15
Matplotlib - Image Display
You want to display a 2D numpy array as an image but only show pixel values between 50 and 200. Which imshow parameters help achieve this?
AUse <code>cmap='gray'</code> only
BUse <code>interpolation='nearest'</code> only
CResize the array to values between 50 and 200 before imshow
DUse <code>vmin=50</code> and <code>vmax=200</code> in imshow
Step-by-Step Solution
Solution:
  1. Step 1: Understand vmin and vmax

    These parameters set the data value range mapped to the colormap.
  2. Step 2: Confirm other options

    cmap changes colors but not value range; resizing data is manual; interpolation affects pixel smoothing.
  3. Final Answer:

    Use vmin=50 and vmax=200 in imshow -> Option D
  4. Quick Check:

    vmin/vmax control displayed data range [OK]
Quick Trick: Set vmin and vmax to clip displayed pixel values [OK]
Common Mistakes:
  • Confusing cmap with value range
  • Trying to resize array manually
  • Ignoring vmin/vmax parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes