Java Color Distance colorDistance(double r1, double g1, double b1, double r2, double g2, double b2)

Here you can find the source of colorDistance(double r1, double g1, double b1, double r2, double g2, double b2)

Description

Simple Color Distance.

License

Open Source License

Parameter

Parameter Description
r1 first red
g1 first green
b1 first blue
r2 second red
g2 second green
b2 second blue

Return

3d distance for relative comparison

Declaration

public static double colorDistance(double r1, double g1, double b1, double r2, double g2, double b2) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * The contents of this file are subject to the   Compiere License  Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * You may obtain a copy of the License at http://www.compiere.org/license.html
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
 * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
 * are Copyright (C) 1999-2005 Jorg Janke.
 * All parts are Copyright (C) 1999-2005 ComPiere, Inc.  All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/

public class Main {
    /**//from  w  w w  .  j  av a2  s .  c o  m
     *    Simple Color Distance.
     *    (3d point distance)
     *   @param r1 first red
     *   @param g1 first green
     *   @param b1 first blue
     *   @param r2 second red
     *   @param g2 second green
     *   @param b2 second blue
     *   @return 3d distance for relative comparison
     */
    public static double colorDistance(double r1, double g1, double b1, double r2, double g2, double b2) {
        double a = r2 - r1;
        double b = g2 - g1;
        double c = b2 - b1;
        return Math.sqrt(a * a + b * b + c * c);
    }
}

Related

  1. colorDiff(int a, int b)
  2. colorDiffAlpha(int a, int b)
  3. colordiffsq(int rgb0, int rgb1)
  4. colorDistance(final double r1, final double g1, final double b1, final double r2, final double g2, final double b2)
  5. colorDistance(final float[] lab1, final float[] lab2)
  6. colorDistance(final float[] lab1, final float[] lab2)
  7. colorDistance(int r1, int g1, int b1, int r2, int g2, int b2)