Get pHash fingerprint of an image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
such
Posts: 2
Joined: 2014-09-08T10:33:47-07:00
Authentication code: 6789

Get pHash fingerprint of an image

Post by such »

Since 6.8.8-2 it is possible to compare two images with the pHash metric.
If I understand properly, a fingerprint of each image is first computed, then an hamming distance between them is performed.
I was wondering if it was possible to have direct (cli or rmagick) access to the pHash fingerprint of the image.

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Get pHash fingerprint of an image

Post by fmw42 »

The algorithm does not do a simple Hamming distance measure for comparison. There are 42 floats that need to be compared using the sum squared difference. I have a couple of scripts that convert the 42 floats into a string of 168 digits. But you cannot use the hamming distance on that. You need to use the script that converts the 168 digits from each image back to the 42 floats and does the rmse metric. The IM function compare has a metric of phash which does the correct comparison (ssd) of the 42 floats.

see my scripts phashconvert and phashcompare at the link below, if you want to use phashconvert to create and store the 168 digits and then use phashcompare later.

see also http://www.fmwconcepts.com/misc_tests/p ... index.html for all my testing and syntax, etc
such
Posts: 2
Joined: 2014-09-08T10:33:47-07:00
Authentication code: 6789

Re: Get pHash fingerprint of an image

Post by such »

I'll have a look. Thanks a lot!
Post Reply