我需要读取图像(500x300x3)并将它们存储在数组中:
import os
import numpy as np
data = np.empty((number_of_images, 3, 300, 500), dtype="float32")
imgs = os.listdir("./images")
num = len(imgs)
for i in range(num):
img = Image.open("./images/" + imgs[i])
arr = np.asarray(img, dtype="float32")
data[i, :, :, :] = arr
现在出现此错误是因为arr
的大小为500x300x3,但我想将其存储为np.empty((number_of_images, 3, 300, 500), dtype="float32")
。
任何建议都将不胜感激!