Home>
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"
to
・ Two-dimensional array (n, m) X
Row (n rows): Number of data
Column (m column): Two-dimensional array of images flattened in one dimension
, 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
Related articles
- i want to create a 3d array with c ++ and convert it to an image
- i want to convert multiple image data to a grayscale primary array
- python i want to convert a multidimensional array back to an image
- in pandas, the operation to add the array time obtained by float to the reference time
- java - array element reference issue
- python - i want to increase only the nth element of the array and use it for /{}'format()
- c# - convert image data from systemwindowsmediaimagesource to systemwindowscontrolsimage
- python - how to convert list to numpy array ndarray
- c++ - i want to convert an image classifier created with keras to a caffe model
- javascript - how to do a quick sort by the size of the first element of the array
- how can i convert two arrays into one associative array {key:value} with javascript?
- c++ - i don't understand why the element is displayed when i do * operation on the iterator with set (*setlower_bound(x))
- python - i want to convert the dimensions of a two-dimensional array
- java - array element reference issue
- core dump with dynamic array (difference in operation depending on environment)
- i want to sum up each element of an array in python
- how to embed an array in an element of an array with javascript and output it as a single array
- display only the element in the middle of php array with "," at the end
- i want to convert a movie into an image with ffmpeg
- swift - characters of array element corresponding to index are displayed with color when looping
Related questions
- i want to initialize a string with python numpy
- python - i want to find the intersection of the lines of the least squares method when the button is pressed
- python - i want to find the average hsv value for each divided image
- numpy - it fails with npload
- i want to make a 2d array of python n * n
- python - i want to combine split images
- python - i want to display a graph of matplotlib on tkinter and enable mouse operation in canvas
- numpy - [python] i want to combine alternately and make two sets of two arrays of latitude and longitude
- python - i want to create a new dataframe by repeating the work of extracting the average value of the dataframe
- python - background program by sharley method
I have done what I want to do, so close it.