Tom64b / dHash

dHash = Difference Hash = a quick algorithm to compare images visually

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hamming Distance in PostgreSQL

bartekwww opened this issue · comments

I've calculated hashes of over 400 000 images using your code. Thanks! I've used hamming_distance function from this https://github.com/palestamp/hamming_distance git. I've found that most ot the time it calculates distance as your dhash_distance, but sometimes it is very different. Is it possible to change you code, to works on postgresql to calculate distance from stored hashes? I probably could change hex hashes to bit hashes and do bit xor and popcount. Is it a better way?

I will answer for other people. The distance could be calculated from bit representation of hash. I used gmp_* function to create bit(64) hash and next I calculated popcount (https://github.com/eschmar/postgresql-popcount) on xor bit hashes.