pHash – An open source perceptual hash library (2013)
phash.org
phash.org
I think classifiers tend to encode actual interesting information.
Github repos tend to outlive the homepage of some projects. I got worried when I read this:
> Copyright © 2008-2010
Or are you using this to ensure there’s no duplicates in a batch of images being uploaded?
Originally I added it because I wanted a way to automatically find the full quality image from my archive and replace the aggressively scaled down versions I used to use. Back in 2003 100KB was considered pretty big for a photo, but now it looks like garbage. I never found time to finish that part of it.
Fun fact, last week one of the main authors of the above 2019 paper spun off a company for the above approach: https://techcrunch.com/2021/08/13/thirdai-raises-6m-to-democ...
Loosely based on this algorithm:
https://benhoyt.com/writings/duplicate-image-detection/
Highly recommended fun exercise.
I would expect that Apple probably did a very good job at their implementation, and pHash is quite old tech.
I evaluated a ton of different images hashing algorithms for PhotoStructure, and saw similar accuracy from pHash, dhash, and mhash. I found that an mhash triplet rendered against a L*a*b* space (rather than just looking at a brightness channel) was best.
I also found too many false negatives _and false positives_ when aggregating duplicates until I also included file metadata heuristics. Pesky camera manufacturers are surprisingly inconsistent in how they encode the same metadata across, say, RAW and JPG images. I'm up to a gig of exemplar pairs that CI tests use to verify a litany of weirdnesses, like inconsistently encoding exposure information (in looking at you, Google Pixels), or GPS (iDevices), or even make, model, and serial number (several dSLR and other flagship phone manufacturers).
I wrote this up with some more details if you're interested: https://photostructure.com/faq/what-do-you-mean-by-deduplica...
Interesting software!