我需要一個像這裏找到的函數:http://effbot.org/zone/pil-comparing-images.htm計算兩幅圖像之間的均方根差。代碼如下所示:使用Python和PIL的兩幅圖像之間的均方根差異
import ImageChops
import math, operator
def rmsdiff(im1, im2):
"Calculate the root-mean-square difference between two images"
h = ImageChops.difference(im1, im2).histogram()
# calculate rms
return math.sqrt(reduce(operator.add,
map(lambda h, i: h*(i**2), h, range(256))
)/(float(im1.size[0]) * im1.size[1]))
試圖運行該代碼將導致以下錯誤:類型錯誤:不支持的操作類型爲**或POW():「NoneType」和「INT」。這是它的問題?