I want to read from many sample images, and make 2D numpy array that row "i" corresponds to i'th sample, and column j correspond to j'th pixel of image(all pixels of a 12*13 image is saved by a list of 156 numbers)
import numpy as np
images = np.array([])
for Letter in "ABCDEFGHIJKLMNO":
im = Image.open("ABCDEFGHIJKLMNO\\16\\"+Letter+".bmp")
sampleimage = list(im.getdata())
images = np.append(images,[sampleimage])
however I struggling making 2D numpy array. above "images" array become an (1800,) array insted of (11,156) . I tried many differend ways but none of them working properly or efficient (making 2D python list and then converting to numpy array is not efficient. although even that solution doesn't work).
so my question is, what is the best way of creating a 2D numpy array on the fly?
np.appendis hard to use correctly, and even then is slow. Reread thenp.appenddocs. Without anaxisparameter it flattens the inputs, hence your result.