Reputation: 31
I need to read images (500x300x3) and store them in arrays:
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
now here error occurs because the size of arr
is 500x300x3, but I want to store it as np.empty((number_of_images, 3, 300, 500), dtype="float32")
.
Any suggestions will be greatly appreciated!
Upvotes: 0
Views: 2346