Pillow实现图片对比
来源:互联网 发布:java web记录日志 编辑:程序博客网 时间:2024/04/28 12:48
# coding=utf-8
from PIL import Image
import math
import operator
from functools import reduce
def image_contrast(img1, img2):
image1 = Image.open(img1)
image2 = Image.open(img2)
h1 = image1.histogram()
h2 = image2.histogram()
result = math.sqrt(reduce(operator.add, list(map(lambda a,b: (a-b)**2, h1, h2)))/len(h1) )
return result
if __name__ == '__main__':
img1 = "./img1.jpg" # 指定图片路径
img2 = "./img2.jpg"
result = image_contrast(img1,img2)
print(result)
import math
import operator
from functools import reduce
def image_contrast(img1, img2):
image1 = Image.open(img1)
image2 = Image.open(img2)
h1 = image1.histogram()
h2 = image2.histogram()
result = math.sqrt(reduce(operator.add, list(map(lambda a,b: (a-b)**2, h1, h2)))/len(h1) )
return result
if __name__ == '__main__':
img1 = "./img1.jpg" # 指定图片路径
img2 = "./img2.jpg"
result = image_contrast(img1,img2)
print(result)
如果两张图片完全相等,则返回结果为浮点类型“0.0”,如果不相同则返回结果值越大。
0 0
- Pillow实现图片对比
- Pillow实现图片对比
- python 的 Pillow实现图片对比
- Python3.4的Pillow库实现验证码图片
- python Pillow 处理图片
- Python图片处理模块Pillow
- 【Python】Pillow图片处理库
- 【003】Python实现图片转字符画(pillow 库的使用)
- 使用python pillow 图片转字符串
- [python + pillow] 修改图片的尺寸
- Pillow库的使用+图片转字符串
- Python3 Pillow生成简单验证码图片
- Python中用PIL/Pillow裁剪图片
- opencv 实现YUV 图片差异对比
- Pillow简单使用--数组到图片、图片到数组转换
- python3用pillow生成验证码,tornado中输出图片
- python3使用pillow库为图片添加滤镜
- python-识别图片-安装及配置:tesseract+pytesseract+Pillow
- [美剧赏析] 权力的游戏<Game of Thrones>完全赏析 (1-2)
- spring Aop实现原理(源码)
- input 的value 含有英文双引号问题
- 彻底理解自定义View的测量
- 只用位运算来实现整数的加减乘除四则运算 (转载,还没有来得及整理!!!!)
- Pillow实现图片对比
- mini2440 Linux启动
- java中List集合遍历和迭代器遍历
- 312. Burst Balloons
- androidStudio com.android.ide.common.process.ProcessException解决方法
- Django国际化
- POJ2135-Farm Tour(固定流量的最小费用流)
- uvalive4329
- JavaScript对象模型