I have a directory containing 4 folder (1,2,3,4). Each folder has jpg images in them. I used the code below to read the images. The problem is all images are in different shapes. So, now I have a list of images each with different shape.
1) Is there a better way to read img files from a directory? (maybe assign directly to a numpy array)
2) How can I resize the images so that they all have the same shape?
Thanks!
import imageio
import os.path
images = []
for folder in os.listdir('images'):
for filename in os.listdir('images/'+folder):
if filename.endswith(".jpg"):
img = imageio.imread('images/'+folder+'/'+filename)
img.reshape((1,img.flatten().shape[0])).shape
images.append(img)