VOOZH about

URL: https://www.geeksforgeeks.org/python/python-working-with-png-images-using-matplotlib/

⇱ Python | Working with PNG Images using Matplotlib - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python | Working with PNG Images using Matplotlib

Last Updated : 22 Sep, 2025

Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. Matplotlib consists of several plots like line, bar, scatter, histogram etc. In this article, we will see how to work with PNG images using Matplotlib.

Example 1: Read a PNG image using Matplotlib

Output

👁 Image

Example 2: Applying pseudocolor to image

Pseudocolor is useful for enhancing contrast of image.

Output

👁 Image

Example 3: We can provide another value to colormap with colorbar.

Output

👁 Image

Interpolation Schemes

Interpolation calculates what the color or value of a pixel “should” be and this needed when we resize the image but want the same information. There's missing space when you resize image because pixels are discrete and interpolation is how you fill that space.

Example 4: Interpolation

Output

👁 Image

Example 5: Here, 'bicubic' value is used for interpolation.

Output

👁 Image

Example 6: 'sinc' value is used for interpolation.

Comment
Article Tags: