commonsmachinery / blockhash

blockhash.io
MIT License
88 stars 28 forks source link

Bugfix: Fixed incorrect median calculation. #23

Closed dsoprea closed 7 years ago

dsoprea commented 7 years ago
dsoprea commented 7 years ago

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 commented 7 years ago

Looks good, thanks!