static float rgbDiff(RGB a, RGB b) { return (float) (Math.abs(a.r-b.r) + Math.abs(a.g-b.g) + Math.abs(a.b-b.b))/3; } // 0xRRGGBB - result is between 0 and 255*255*3 static int rgbDistanceSquaredInt(int a, int b) { ret sqrUbyte(absDiff(rgbRed(a), rgbRed(b)) + sqrUbyte(absDifF(rgbGreen(a), rgbGreen(b)) + sqrUbyte(absDiff(rgbBlue(a), rgbBlue(b)); }