My old implementation of colourdistance algorithm with c speedups