如何用Python实现两图像像素匹配相似度计算?
摘要:1、简介 GitHub:https:github.comwhtskypixelmatch-py 2、代码 测试图片点击进行下载:Image from PIL import Image from pixelmatch.contrib.
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")
