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

Bugfix: Fixed incorrect median calculation. #23

Merged
merged 2 commits into from
Nov 27, 2017
Merged

Bugfix: Fixed incorrect median calculation. #23

merged 2 commits into from
Nov 27, 2017

Conversation

dsoprea
Copy link
Contributor

@dsoprea dsoprea commented Nov 26, 2017

  • The Python implementation is correct.

- The Python implementation is correct.
@dsoprea
Copy link
Contributor Author

dsoprea commented Nov 26, 2017

Here is the validation. Note that the hashes for the original images and the shrunken images (identified from the filename) aren't identical, but this isn't your problem as long as your interpretation of the algorithm is correct.

Broken:

$ ./blockhash --bits 16 ~/Downloads/*.jpg
1ffc3fff007e000021ff3e3f0f8007c03fff1f8c0f9806003ffc3ff80f0000f0  /home/dustin/Downloads/20170618_155330.jpg
1ffc3fff007e000021ff3e3f0f8007c03fff1f8c0f9806003ffc1ff80f0400f0  /home/dustin/Downloads/20170618_155330-small.jpg
7ff00fe00fe007e00ffd07f807f003e003fc07f807f413f017f927e261c4e0d8  /home/dustin/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers.jpg
7ff00fe00fe007e00ffd07f807f003e003fc07f807f413f013f92fe261c4e0d8  /home/dustin/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers-small.jpg
05fe03fe07fc01d081c06080f7d4ff676fe2fe44f706c080ee08e754f704f242  /home/dustin/Downloads/GoldenEye - article-2737104-20DE666500000578-156_634x423.jpg
00001c003fff3fff07fc03fc03f807f007f303e603ed00df00ff007f00ff00ff  /home/dustin/Downloads/GoldenEye - article-2737104-20DE66C600000578-355_634x950.jpg
6ff82fc807e003f02bf824f0036639fa19fe19fa01f000ef45fe05fe30de005c  /home/dustin/Downloads/GoldenEye - article-2737104-20DE67FF00000578-190_634x423.jpg

Fixed:

$ ./blockhash --bits 16 ~/Downloads/*.jpg
1ffc3fff00fe000021ff7e3f0f8007c03fff1f8d0f9806003ffc3ff80f0400f0  /home/dustin/Downloads/20170618_155330.jpg
1ffc3fff00fe000031ff3e3f0f8007c03fff1f8d0f9806003ffc3ff80f0400f0  /home/dustin/Downloads/20170618_155330-small.jpg
7ff00fe00ff007e00ffd07f807f003f003fc07fa07f413f017f927e261cce0d8  /home/dustin/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers.jpg
7ff00fe00fe007f00ffd07f807f003f003fc07fa07f413f013f92fe261cce0d8  /home/dustin/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers-small.jpg
05fe03ff07fc01d081c06080f7f4ff67efe2fe44f706c080ee08f754f704f242  /home/dustin/Downloads/GoldenEye - article-2737104-20DE666500000578-156_634x423.jpg
00021c003fff3fff07fc03fc03f807f107f703e603ed00df00ff00ff00ff00ff  /home/dustin/Downloads/GoldenEye - article-2737104-20DE66C600000578-355_634x950.jpg
7ff82fc807e003f02ff824f0036639fa19fe19fa01f001efc5fe05fe30de005c  /home/dustin/Downloads/GoldenEye - article-2737104-20DE67FF00000578-190_634x423.jpg

Python (agrees):

$ python blockhash.py ~/Downloads/*.jpg
1ffc3fff00fe000021ff7e3f0f8007c03fff1f8d0f9806003ffc3ff80f0400f0  /home/dustin/Downloads/20170618_155330.jpg
1ffc3fff00fe000031ff3e3f0f8007c03fff1f8d0f9806003ffc3ff80f0400f0  /home/dustin/Downloads/20170618_155330-small.jpg
7ff00fe00ff007e00ffd07f807f003f003fc07fa07f413f017f927e261cce0d8  /home/dustin/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers.jpg
7ff00fe00fe007f00ffd07f807f003f003fc07fa07f413f013f92fe261cce0d8  /home/dustin/Downloads/amazing-mountain-valley-wallpaper-29910-30628-hd-wallpapers-small.jpg
05fe03ff07fc01d081c06080f7f4ff67efe2fe44f706c080ee08f754f704f242  /home/dustin/Downloads/GoldenEye - article-2737104-20DE666500000578-156_634x423.jpg
00021c003fff3fff07fc03fc03f807f107f703e603ed00df00ff00ff00ff00ff  /home/dustin/Downloads/GoldenEye - article-2737104-20DE66C600000578-355_634x950.jpg
7ff82fc807e003f02ff824f0036639fa19fe19fa01f001efc5fe05fe30de005c  /home/dustin/Downloads/GoldenEye - article-2737104-20DE67FF00000578-190_634x423.jpg

@artfwo
Copy link
Member

artfwo commented Nov 27, 2017

Looks good, thanks!

@artfwo artfwo merged commit bb5e7cb into commonsmachinery:master Nov 27, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants