In the following code (blue text), I am repeatedly getting that NoneType object is not iterable. Can anyone identify the problem?
---------------------------------------------------------------------------------------------------------
from PIL import Image
import numpy as np
import sys
import os
import csv
format='.png'
myDir = "TL_Dataset/Hats and Caps (Processed)"
#Useful function
def createFileList(myDir, format='.png'):
fileList = []
print(myDir)
for root, dirs, files in os.walk(myDir, topdown=False):
for name in files:
fullName = os.path.join(root, name)
fileList.append(fullName)
return fileList
# load the original image
myFileList = createFileList('TL_Dataset/Hats and Caps (Processed)')
for file in fileList:
print(file)
img_file = Image.open(file)
# img_file.show()
# get original image parameters...
width, height = img_file.size
format = img_file.format
mode = img_file.mode
# Save Greyscale values
value = np.asarray(img_file.getdata(), dtype=np.int).reshape((img_file.size[1], img_file.size[0])) value = value.flatten()
print(value)
with open("img_pixels.csv", 'a') as f:
writer = csv.writer(f)
writer.writerow(value)
--------------------------------------------------------------------------------------------------------