ImageHash has a Hamming distance of ** 0 ** for the same image, and ** 1-10 ** for potentially similar images. Reconfirm whether similar images can be detected only with ImageHash.
Hash uses dhush.
reference: https://tech.unifa-e.com/entry/2017/11/27/111546
sample.py
import imagehash
from PIL import Image
hash1 = imagehash.dhash(Image.open('./images/001.png'))
hash2 = imagehash.dhash(Image.open('./images/002.png'))
hash3 = imagehash.dhash(Image.open('./images/003.png'))
print(hash1, hash2, hash3)
print('001.png:002.png - {}'.format(hash1 - hash2))
print('001.png:003.png - {}'.format(hash1 - hash3))
print('002.png:003.png - {}'.format(hash2 - hash3))
The following images are used in this program. 002.png and 003.png choose similar images, 001.png has a different pose, but the composition with the character in the center is the same.
1 | 2 | 3 |
---|---|---|
001.png | 002.png | 003.png |
The Hamming distances of 001.png and other images are 16 and 12, respectively, which are very different. The Hamming distance of 002.png and 003.png is 8. Normally, "1 to 10" are potentially similar images, but since they are completely different images, it can be said to be a false positive. As mentioned in Posted the other day, it can be said that it is difficult to judge similar images only with Image hash.
3868e0f870706979 a269e8e8f0f4f070 b860e0e8f1f0f070
001.png:002.png - 16
001.png:003.png - 12
002.png:003.png - 8
Recommended Posts