allfiles = os.listdir(os.getcwd())
imlist = [filename for filename in allfiles if filename[-4:] in ['.png',
    '.PNG']]
w, h = Image.open(imlist[0]).size
N = len(imlist)
arr = numpy.zeros((h, w, 3), numpy.float)
for im in imlist:
    imarr = numpy.array(Image.open(im), dtype=numpy.float)
arr = arr + imarr / N
arr = numpy.array(numpy.round(arr), dtype=numpy.uint8)
out = Image.fromarray(arr, mode='RGB')
out.save('Average.png')
out.show()
How to get an average picture from 100 pictures using PIL?