I am trying to read a png image in python. The imread function in scipy is being deprecated and they recommend using imageio library.
However, I am would rather restrict my usage of external libraries to  scipy, numpy and matplotlib libraries. Thus, using imageio or scikit image is not a good option for me. 
Are there any methods in python or scipy, numpy or matplotlib to read images, which are not being deprecated?
The imread() function in pyplot module of matplotlib library is used to read an image from a file into an array. Parameters: This method accepts the following parameters. fname : This parameter is the image file to read. format: This parameter is the image file format assumed for reading the data.
scikit-image is an image processing Python package that works with NumPy arrays which is a collection of algorithms for image processing. Let’s discuss how to deal with images into set of information and it’s some application in the real world. Important features of scikit-image :
Most functions of skimage are found within submodules. Images are represented as NumPy arrays, for example 2-D arrays for grayscale 2-D images. Code #2 : skimage.data submodule provides a set of functions returning example images.
If the GIF is stored in memory: Imageio can read from filenames, file objects, http, zipfiles and bytes. Note: reading from HTTP and zipfiles works for many formats including png and jpeg, but may not work for all formats (some plugins “seek” the file object, which HTTP/zip streams do not support).
Imageio provides a range of example images , which can be used by using a URI like 'imageio:chelsea.png'. The images are automatically downloaded if not already present on your system. Therefore most examples below should just work.
With matplotlib you can use (as shown in the matplotlib documentation)
import matplotlib.pyplot as plt import matplotlib.image as mpimg  img=mpimg.imread('image_name.png')   And plot the image if you want
imgplot = plt.imshow(img) 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With