0

i have a folder of gray-scale images from 0 to 9 and they are around 2400, i need to load them in python so as to have all Zeors together as an array , then Ones together as an array, etc... i used below code to load one image as an array but i don`t know how to load all images and group each number together. i thought about iteration through the folder.

Do anyone know how to do it or is there any other idea?

import imageio

im = imageio.imread('Train/1.jpg')
Abdo
  • 9
  • 2

1 Answers1

0

You can do it in the following manner:

import imageio
for i in range(9):
    im = imageio.imread('Train/'+str(i)+'.jpg')

You can also create a 3D variable whose third dimension is equal to the number of files to read the complete data in a single 3D array.

Manmeet Singh
  • 405
  • 2
  • 11