Java Color Distance distance(Color a, Color b)

Here you can find the source of distance(Color a, Color b)

Description

color distance

License

Apache License

Declaration

public static int distance(Color a, Color b) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.*;

public class Main {
    /**//from  www  .ja va 2 s . c  om
     * color distance
     */
    public static int distance(Color a, Color b) {
        int dist = 0;
        int delta = a.getRed() - b.getRed();
        dist += delta * delta;
        delta = a.getGreen() - b.getGreen();
        dist += delta * delta;
        delta = a.getBlue() - b.getBlue();
        dist += delta * delta;
        delta = a.getAlpha() - b.getAlpha();
        dist += delta * delta;
        return dist;
    }
}

Related

  1. colorDistance(double r1, double g1, double b1, double r2, double g2, double b2)
  2. colorDistance(final double r1, final double g1, final double b1, final double r2, final double g2, final double b2)
  3. colorDistance(final float[] lab1, final float[] lab2)
  4. colorDistance(final float[] lab1, final float[] lab2)
  5. colorDistance(int r1, int g1, int b1, int r2, int g2, int b2)
  6. distance(Color c1, Color c2)
  7. distanceToColor(final int distance)
  8. drawArc(Point2D start, double distance, double startAngle, double arcAngle, boolean fill, Graphics2D g2, Color color)
  9. getDistance(int c1, Color c2)