1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| import os, numpy, PIL
from PIL import Image
os.chdir("D://AMELIE//ESSAI_1//" )
print "Current working dir : %s" % os.getcwd()
allfiles=os.listdir(os.getcwd())
imlist=[filename for filename in allfiles if filename[-5:] in [".tiff",".tiff"]]
w,h=Image.open(imlist[0]).size
N=len(imlist)
arr=numpy.zeros((h,w,1),numpy.float)
for im in imlist:
imarr=numpy.array(Image.open(im),dtype=numpy.float)
arr+=imarr/N
N=float(N)
arr=numpy.array(numpy.round(arr),dtype=numpy.uint8)
out=Image.fromarray(arr,mode="F")
out.save("Average.tiff")
out.show() |
Partager