#coding=<coding=utf-8>
from PIL import Image
if __name__ == "__main__":
image1 = Image.open("009.png")
image2 = Image.open("010.png")
width, height = image1.size
width_s, height_s = image2.size
for h in range(0, height):
for w in range(0, width):
pixel = image1.getpixel((w, h))
for h_s in range(0, height_s):
for w_s in range(0, width_s):
pixel = image2.getpixel((w_s, h_s))
if image1.size != image2.size:
size = (352,288)
image1 = image1.resize(size).convert("RGB")
image2 = image2.resize(size).convert("RGB")
diff = [(x, y) for x in xrange(width) for y in xrange(height) if image1.getpixel((x, y)) != image2.getpixel((x, y))]
pre = 1.0 - 1.0*len(diff)/(width*height*1.0)
else:
diff = [(x, y) for x in xrange(width) for y in xrange(height) if image1.getpixel((x, y)) != image2.getpixel((x, y))]
pre = 1.0 - 1.0*len(diff)/(width*height*1.0)
print("Hello python !!!")
print pre
两幅图像间的精确对比
最新推荐文章于 2023-08-16 18:33:03 发布