Read an image with scipy.misc in Python

The following tutorial will guide you through reading an image from the path of the image file and returning the NumPy array of the image using scipy.misc. A package scipy.misc is found in the SciPy module of Python. The package is also known as miscellaneous routines and contains a number of methods that perform different functions. By reading this tutorial thoroughly, you will be able to clear up all your doubts.

Required Modules

Ensure that the following libraries are installed in your code space extension or you may install it by the commands in your terminal window as shown below:


pip install numpy


pip install scipy

With the help of the example given below, we will learn how to read an image using imread() function in scipy.misc (which reads the file path):

Example: Read an image with scipy.misc

#import the required modules
from scipy import misc
import imageio
import matplotlib.pyplot as plt
#write the path of the file under imread()function
img = imageio.imread('C:/Users/PRACHI PANDEY/Downloads/lion.jpeg')
#print the shape and type of image 
#using plt.imshow() function show the image 


(314, 474, 3)

Read an image with scipy.misc

Based on the output obtained, it is evident that the NumPy array of the given image is displayed. This particular program begins by importing the required modules and then copying the path of the image under the section of imread() function, here we will also use imageio library of Python (which reads a wide range of images, videos, etc.). After we have done this, we will print the type and shape of the image, as well as plot it with the help of plt.imshow ().

Leave a Reply

Your email address will not be published. Required fields are marked *