Numpy beginner.

・ Two-dimensional array X_pre
Shape is (n, 1)
Row (n rows): Number of data
Column (1 column): Image file name Example: "xxx.bmp"


・ Two-dimensional array (n, m) X
Row (n rows): Number of data
Column (m column): Two-dimensional array of images flattened in one dimension

To make

, I made the following code for the time being.

I want to be able to complete coding, so I would like advice.
Thank you very much.

from PIL import Image
import numpy as np
import pandas as pd
test = pd.read_csv ('XXXXX.csv') #csv file is read
X_pre = test ['file name'] # (number of data, file name)
width, height = 128,96 #resize size
X = np.zeros ((X_pre.shape [0], width * height)) #X preparation.
for i in range (X_pre.shape [0]): #number of data
  X [i:] = np.array (Image.open (X_pre [i])). Ravel () #Open the file and convert it to a 2D array, then flatten it into a 1D array
  • Answer # 1

    I have done what I want to do, so close it.