commonsmachinery / blockhash-python

Implementation of perceptual image hash calculation in Python
http://blockhash.io/
MIT License
130 stars 29 forks source link

Median Incorrect #8

Closed danielcrane closed 7 years ago

danielcrane commented 7 years ago

On line 17 of blockhash.py the calculation of the median has an error in the indexing of elements.

return (data[length // 2] + data[length // 2 + 1]) / 2.0

should instead be:

return (data[length // 2 - 1] + data[length // 2]) / 2.0

due to the zero-based indexing of Python.

artfwo commented 7 years ago

Good catch, this should be corrected along with the tests.