benhoyt/dhash

[Question] Why add Y-direction 64-bit hash?

mo-han opened this issue · 1 comments

I was using another image hash lib (https://pypi.org/project/ImageHash/) which does not do this.
Is this XY-128bit pattern a convention or something?

Are you asking why dhash does it in both the X and Y directions to form a 128-bit hash? That's because you get much better results if you do both directions -- images have "changes" or "differences" in both directions, so using both directions in your hash means fewer false positives. There's a note to this effect in Dr. Neal Krawetz's original blog entry about dhash:

Storing values by row or column really doesn't make a difference. Computing both row and column hashes significantly reduces the number of false-positives and is comparable to pHash (almost as accurate). So it maintains speed and gains accuracy as the cost of requiring 128 bits for the hash.