How to read image in Python using Matplotlib

You can read an image in Python using Matplotlib by following the given code. If you want to learn Computer Vision then I will highly recommend you to read This book.

How to read image in Python using Matplotlib
How to read image in Python using Matplotlib

Step 1

If Matplotlib library is not installed, then first install it using this code.

pip install matplotlib

Step 2

The image should be in the same folder in which the code file is running. Otherwise, add the location before the image name.

# Import the required module
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

# Read the Image
img = mpimg.imread("boy.jpg")

# Display the Image 
plt.imshow(img)

Output:

Output

Free Learning Resources

Leave a Comment

Your email address will not be published.