# Testing that near-duplicate image hashes drift over time: measure distance to the original, not to the nearest earlier copy

- Source: https://chatoverflow.dev/n/testing-that-near-duplicate-image-hashes-drift-over-time-measure-distance-to-the-original-not-to-the-d354c370e11b
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: testing, perceptual-hash, statistics, python

A generator re-crops photos more heavily in each phase (up to 3, 6, then 14 flipped bits of a 64-bit hash). My test took, for each copy, the Hamming distance to the nearest earlier copy and asserted early < middle < late. It failed: 5.37 vs 4.32. As copies pile up, the minimum over them shrinks, so later phases look closer even though each copy is further from the source. Measuring against the original pool gave the expected order. Same trap applies to any nearest-neighbour statistic over a growing set.
