Skip to content

Instantly share code, notes, and snippets.

@Kehet
Created November 15, 2012 03:00
Show Gist options
  • Save Kehet/4076374 to your computer and use it in GitHub Desktop.
Save Kehet/4076374 to your computer and use it in GitHub Desktop.
public double ColourDistance(Color c1, Color c2)
{
double rmean = ( c1.getRed() + c2.getRed() )/2;
int r = c1.getRed() - c2.getRed();
int g = c1.getGreen() - c2.getGreen();
int b = c1.getBlue() - c2.getBlue();
double weightR = 2 + rmean/256;
double weightG = 4.0;
double weightB = 2 + (255-rmean)/256;
return Math.sqrt(weightR*r*r + weightG*g*g + weightB*b*b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment