I would like to ask if is there any method to sort the filename (ascending order) of the image files first, followed by doing the calculation of the standard deviation and mean of each image file?
dir_path = "The file path"
listOfImageFiles = os.listdir(dir_path)
fileext = ('.png', 'jpg', 'jpeg')
for imageFile in listOfImageFiles:
if imageFile.endswith(fileext):
im = Image.open(os.path.join(dir_path, imageFile))
stat = ImageStat.Stat(im)
img = mahotas.imread(os.path.join(dir_path, imageFile))
mean = img.mean()
print(str(mean))
print(stat.stddev)
This is what I have done. Any suggestion to add or edit it?