I am trying to read a png
image in python. The imread
function in scipy
is being deprecated and they recommend using imageio
I read all answers but I think one of the best method is using openCV library.
import cv2
img = cv2.imread('your_image.png',0)
and for displaying the image, use the following code :
from matplotlib import pyplot as plt
plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis
plt.show()
You can also use Pillow like this:
from PIL import Image
image = Image.open("image_path.jpg")
image.show()
If you just want to read an image in Python using the specified libraries only, I will go with
matplotlib
In matplotlib :
import matplotlib.image
read_img = matplotlib.image.imread('your_image.png')