I have two folders full of images (around 2000 files each) of different sizes. I need all of them in 28x28 format. After that I need to convert all of those images of each folder into one csv-file. Any ideas how I could do that? I'm an absolute beginner in python so please be a little bit patient, if i need more time to understand the basics.
I tried a solution I found here : Converting images to csv file in python
Specifically :
import numpy as np
import cv2
import os
IMG_DIR = 'C:/Users/Anwender/Documents/Uni/KI/Trainingsdaten/Train'
for img in os.listdir(IMG_DIR):
img_array = cv2.imread(os.path.join(IMG_DIR,img), cv2.IMREAD_GRAYSCALE)
img_array = (img_array.flatten())
img_array = img_array.reshape(-1,1).T
print(img_array)
with open('train.csv', 'ab') as f:
np.savetxt(f, img_array, delimiter=",")`
I hoped that changing img_array = img_array.reshape(-1,1).T
into img_array = img_array.reshape(-1,28*28).T
would give me the described result but instead delivers : "ValueError: cannot reshape array of size 2500 into shape (784)". I understand that there is no common denominator of both numbers so the dividing process without a remainder is not possible.