There's a lot that could improve on that. Using YUV, using the distance from the average instead of absolute values, normalizing...