Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phash vs. phash_simple Hamming Distances #211

Open
Aliiiqbp opened this issue Aug 21, 2024 · 4 comments
Open

phash vs. phash_simple Hamming Distances #211

Aliiiqbp opened this issue Aug 21, 2024 · 4 comments

Comments

@Aliiiqbp
Copy link

I am curious about why the Hamming distance between hash values computed from arbitrary images using the "phash" method is always an even number, while this is not the case with the "phash_simple" function.
The only difference between these methods is that phash uses the "median", while phash_simple uses the "mean".

@JohannesBuchner
Copy link
Owner

dctlowfreq is also different

@JohannesBuchner
Copy link
Owner

and dct

@Aliiiqbp
Copy link
Author

Thank you for your response.
The key question is whether we can reduce the hash size by half using the pHash function while maintaining the same semantics, given that the hash values are all at a 2k-bit distance.

I plotted the Hamming distance distribution for a subset of the DIV2K dataset, and there are no odd distances between any pair of images, which does not make sense while this is not the case in phash_simple or other methods like aHash or dHash.

phash:
pHash

phash_simple:
Figure_2

ahash:
Figure_3

dhash:
Figure_4

@JohannesBuchner
Copy link
Owner

See also #13 #17 #97
Maybe from these you can get an understanding why the distances are even.

I am also not sure the hash size and the hamming distance are related such that even distances imply that the hash size can be reduced. I am also hesitant to break backwards compatibility regarding the way the hash size is stored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants