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!
Get pHash fingerprint of an image
- 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
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
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
Re: Get pHash fingerprint of an image
I'll have a look. Thanks a lot!