Here you can find the source of getDistance(int c1, Color c2)
private static double getDistance(int c1, Color c2)
//package com.java2s; //License from project: LGPL import java.awt.*; public class Main { private static double getDistance(int c1, Color c2) { c1 = 0xff000000 | c1;/*from w w w . j a va 2s. c o m*/ double rmean = ((c1 >> 16) + c2.getRed()) / 2.0; double r = ((c1 >> 16) & 0xFF) - c2.getRed(); double g = ((c1 >> 8) & 0xFF) - c2.getGreen(); int b = ((c1 >> 0) & 0xFF) - c2.getBlue(); double weightR = 2 + rmean / 256.0; double weightG = 4.0; double weightB = 2 + (255 - rmean) / 256.0; return weightR * r * r + weightG * g * g + weightB * b * b; } }