Java Utililty Methods Color Distance

List of utility methods to do Color Distance

Description

The list of methods to do Color Distance are organized into topic(s).

Method

intdistanceToColor(final int distance)
distance To Color
return new Color(INTENSITY_MAX - distance, INTENSITY_MAX - distance, INTENSITY_MAX - distance,
        INTENSITY_MAX).getRGB();
voiddrawArc(Point2D start, double distance, double startAngle, double arcAngle, boolean fill, Graphics2D g2, Color color)
draw Arc
int r2 = (int) (distance * 2);
int x = (int) (start.getX() - distance);
int y = (int) (start.getY() - distance);
g2.setColor(color);
if (fill)
    g2.fillArc(x, y, r2, r2, (int) Math.toDegrees(startAngle), (int) Math.toDegrees(arcAngle));
else
    g2.drawArc(x, y, r2, r2, (int) Math.toDegrees(startAngle), (int) Math.toDegrees(arcAngle));
...
doublegetDistance(int c1, Color c2)
get Distance
c1 = 0xff000000 | c1;
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;
...
intgetMaxDistance(final Color first, final Color second)
Returns the largest absolute difference between the red, green and blue values of the two colors.
int distance = Math.abs(first.getRed() - second.getRed());
if (Math.abs(first.getGreen() - second.getGreen()) > distance) {
    distance = Math.abs(first.getGreen() - second.getGreen());
if (Math.abs(first.getBlue() - second.getBlue()) > distance) {
    distance = Math.abs(first.getBlue() - second.getBlue());
return Math.abs(distance);
...
doublepixelDistance(final Color col1, final Color col2)
Calculates the distance between two colors.
int r1 = col1.getRed();
int g1 = col1.getGreen();
int b1 = col1.getBlue();
int r2 = col2.getRed();
int g2 = col2.getGreen();
int b2 = col2.getBlue();
double pixelDistance = Math
        .sqrt(((r1 - r2) * (r1 - r2)) + ((g1 - g2) * (g1 - g2)) + ((b1 - b2) * (b1 - b2)));
...