Simon Shkolnik :
I need to convert a PNG
image string into a numpy
array. What are the best approaches?
Nicolas Gervais :
You can use matplotlib
for that:
import matplotlib.pyplot as plt
array = plt.imread('my_picture.png')
or PIL
:
from PIL import image
import numpy as np
array = np.array(Image.open('my_picture.png'))
or cv2
:
array = cv2.imread('my_picture.png')
or imageio
:
import imageio
im = imageio.imread('my_picture.png')
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=278877&siteId=1