Python计算两图相似性-像素匹配(pixelmatch)

1、简介

GitHub:https://github.com/whtsky/pixelmatch-py

 

2、代码

测试图片点击进行下载:Image

from PIL import Image
from pixelmatch.contrib.PIL import pixelmatch

img_a = Image.open("WD1.png").resize((1920, 1080))
img_b = Image.open("WD2.png").resize((1920, 1080))
img_diff = Image.new("RGBA", img_a.size)
# note how there is no need to specify dimensions
mismatch = pixelmatch(img_a, img_b, img_diff, includeAA=True)
print(mismatch)
img_diff.save("pixelmatch-diff.png")

 

posted @ 2024-01-30 14:36  莲(LIT)  阅读(312)  评论(0编辑  收藏  举报