What is an efficient way to detect near-duplicate images in a large dataset?

What is an efficient way to detect near-duplicate images in a large dataset?

I’m interested in identifying duplicate and near-duplicate images in a large collection.

The images may have different resolutions, JPEG compression levels, or minor edits. Exact file hashing would not help when the image content is the same but the files differ.

Would perceptual hashing be sufficient for this use case, or would it make sense to combine pHash with feature matching or image embeddings?

I’m particularly interested in approaches that balance matching accuracy with computational cost as the dataset grows.

pHash alone is usually enough for resize and recompression. bucket by hash and only check candidates within a small hamming distance, that keeps it from going quadratic.

pHash is a good first filter for resizing and JPEG recompression, but I wouldn’t rely on it alone if “minor edits” include crops, rotations, overlays, or color changes. A practical pipeline is to normalize orientation and size, compute a perceptual hash, and use Hamming-distance search to find candidates. Then verify those candidates with a stricter method: local-feature matching for geometric edits, or an image embedding followed by a pixel/SSIM check when you care about visual rather than byte-level duplication. At scale, index hashes with a BK-tree or multi-index hashing instead of comparing every pair. Build a labeled sample from the actual collection and tune both thresholds against it, since the useful Hamming cutoff varies by hash implementation and image domain.