How to display image in Python using Matplotlib

You can display 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 display image in Python using Matplotlib
How to display 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
image = mpimg.imread("man.jpg")

# Display the Image 
plt.imshow(image)

Output:

Output

Free Learning Resources

Leave a Comment

Your email address will not be published.