[英]How I can compare two images using Python to say if they are similar?
我正在做一個項目,我需要比較兩個圖像並說明它們是否相似,我使用的是 Python 和 OpenCV。 有人知道我該怎么做嗎?
我遇到了一個項目,該項目需要我與圖像進行比較以查看它們是否相似。 我會推薦這個 Python Lib。 Imagehash Go 通過文檔了解它是如何工作的。
這是一個示例代碼:
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')
要求:
pip install ImageHash
pip install pillow
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.