Analyse d'images sous python
Bonjour,
je cherche à faire une moyenne d'une centaine d'images qui sont sous tiff.
Pour l'instant j'ai le programme :
Code:
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() |
Mais j'ai comme message d'erreur : operands could not be broadcast together with shapes (1200,1920,1) (1200,1920) (1200,1920,1)
Je n'arrive pas à identifier l'erreur, merci de votre aide :)