我需要将图像加载到数组中。然后我想用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'