[英]How I can compare two images using Python to say if they are similar?
I´m working on a project in which I need to compare two images and to say if they are similar, I'm using Python and OpenCV.我正在做一个项目,我需要比较两个图像并说明它们是否相似,我使用的是 Python 和 OpenCV。 Somebody know how I can do it?
有人知道我该怎么做吗?
I've came across a project that required me to compare to images to see if they are similar.我遇到了一个项目,该项目需要我与图像进行比较以查看它们是否相似。 I will recommend this Python Lib.
我会推荐这个 Python Lib。 Imagehash Go through the documentation to understand how it works.
Imagehash Go 通过文档了解它是如何工作的。
Here is a sample Code:这是一个示例代码:
from PIL import Image
import imagehash
img0 = imagehash.average_hash(Image.open('img1.jpg'))
img1 = imagehash.average_hash(Image.open('img2.jpeg'))
cutoff = 5
if img0 - img1 < cutoff:
print('images are similar')
else:
print('images are not similar')
requirements:要求:
pip install ImageHash
pip install pillow
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.