1typedef struct {
2 unsigned char r, g, b;
3} RGB;
4
5double ColourDistance(RGB e1, RGB e2)
6{
7 long rmean = ( (long)e1.r + (long)e2.r ) / 2;
8 long r = (long)e1.r - (long)e2.r;
9 long g = (long)e1.g - (long)e2.g;
10 long b = (long)e1.b - (long)e2.b;
11 return sqrt((((512+rmean)*r*r)>>8) + 4*g*g + (((767-rmean)*b*b)>>8));
12}
13