-
Notifications
You must be signed in to change notification settings - Fork 336
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
simple fix for colorhash algo #216
base: master
Are you sure you want to change the base?
Conversation
Will this break backwards compatibility, for example, for someone who created a database of colorhashes? |
If they're using bin bits size greater than 46, then yes. It will affect the outputs. This doesn't change anything for people using bin bits 3 to 45. However, the change in this PR does give you the correct output which you should be getting. |
Just a small question: for what application would one use so many bits? If you hash, you want it to be lossy so that similar images have the same value. |
It does seem unlikely that anyone would use such a large bin bits size. I was playing around with this library and was working on something that does exactly what this library does in Go. So while testing and comparing values for hashes i noticed this bug in the python repo. |
I think the idea of the line is that a value should fit between 0 and 2^bitsize, from another range. The line scales linearly and then discretizes to integer. The change in the PR applies the discretization to |
Actually i have done quite some research on this. If we dont make this change and print out the |
OK, but for that case, |
I noticed a small problem in the color hashing algo for HSV. When the bin bits increase to size 46 and onwards it gives a warning of scalar multiplication and due to this we get a slightly wrong answer.
The warning:
Peppers image bin bit size 46 (with fix)
Peppers image bin bit size 46 (without fix)
Key Difference:
At Position 108–119 (starting from index 0):
With Fix:
feffffffffffec01
Without Fix:
fffffffffff001
The fix: we just needed to round off the
counts
variable before performing other calculations.