我需要将图像加载到阵列。然后我想通过pyplot显示它。问题介于两者之间。
我尝试了不同类型的读取。我只能从pyplot安装一个引起问题的程序。
import numpy as np
from matplotlib.pyplot import imread
images = []
img = imread('1.png')
img = np.array(img.resize(224,224))
images.append(img)
images_arr = np.asarray(images)
images_arr = images_arr.astype('float32')
plt.figure(figsize=[5,5])
curr_img = np.reshape(images_arr[0],(224,224))
plt.imshow(curr_img,cmap='gray')
plt.show()
有错误:
images_arr = images_arr.astype('float32')
TypeError: float() argument must be a string or a number,not 'NoneType'