Finally got the comparison function into my game. It’s a stripped/daft version of the Discrete Cosine Transform. It works well enough.
Special thanks to Internet Janitor for helping me through the pitfalls of unsigned data manipulation in Java. Check out his Github account here: https://github.com/JohnEarnest
EDIT: Found a problem with my function. It looks like the distance behaves well in test cases, but not in real cases.
Distance between white and black: 4 Distance between white and white: 0 Distance between black and black: 0 Distance between white and user image: 15 Distance between black and user image: 15