Perceptual image hashing for Common Lisp
perceptual-hashes library computes perceptual hashes for images
(supported formats include formats supported by
imago + jpeg). Perceptual hashes
are a measure of similarity between images.
You can install perceptual-hashes from Ultralisp
repository. Add Ultralisp repository to quicklisp (if you haven’t already):
(ql-dist:install-dist "http://dist.ultralisp.org/"
:prompt nil)
and install perceptual-hashes:
(ql:quickload :perceptual-hashes)
The following algorithms are supported:
You can find more information
here.
(defconstant +threshold+ 45
"The distance between hashes can vary from 0 to (length hash) =
1024. If it is small enough (<= ~45) the images are similar")
(defun images-similar-p (image-name-1 image-name-2)
(let ((hash1 (perceptual-hashes:ahash image-name-1))
(hash2 (perceptual-hashes:ahash image-name-2)))
(< (perceptual-hashes:hamming-distance hash1 hash2)
+threshold+)))