Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

imread()
matplotlib
python
communitycreator

What is the matplotlib.pyplot.imread() function in Python?

Educative Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

matplotlib is one of the multiple libraries provided by Python.

The main purpose of matplotlib is to provide us with data visualization. This library is based on numpy, and the purpose of designing this library is to work with the border SciPy stack.

Matplotlib has a sub-library known as pyplot, which makes it a visual open-source like Matlab.

imread() is a function provided by the matplotlib.pyplot library, and is used to read an image and store it in the form of an array.

Syntax

matplotlib.pyplot.imread(fname, format=None)

Parameters

  • fname: This is the name of the image to be read.
  • format: This is the file format for reading images.

Return type

  • This is an array that contains data for all the images.

Code

# Importing modules
import matplotlib.pyplot as plt
# Reading image using imread
image=plt.imread("educative.jpeg")
# Displaying read image
plt.imshow(image)

Explanation

  • Line 2: We import the matplotlib.pyplot library.

  • Line 5: We read the image using the imread() function.

  • Line 8: We display the read image using imshow().

RELATED TAGS

imread()
matplotlib
python
communitycreator
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring