I have thousands of images in a folder. The images are named 0.png, 1.png, 2.png......
I wrote the following code to generate an average image for positive samples and similarly for negative samples.
file_list = glob.glob(trainDir)
n = len(file_list)
label = np.load('labels_v2.dat')
positive = np.empty((300,400,4))
negative = np.empty((300,400,4))
labels = np.empty(n)
count_p = 0
count_n = 0
for i in range(1000):
img = imread(file_list[i])
lbl = label[i]
if (lbl == 1):
positive += img
count_p += 1
print file_list[i]
However this reads the files in the order 1,10,100,1000,10000,10001...... and my labels are in the order 0,1,2,3,..... How can I make it read in the right order?