net.returnvoid.color

## Class ColorDifference

- java.lang.Object
- - net.returnvoid.color.ColorDifference

-     public class ColorDifference
      extends java.lang.Object

  A collection of functions to calculate the difference / distance or the similarity between colors.
  Author:
    Diana Lange

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static float` | `weightingChroma` Weighting of the chroma for Lab / LCH difference measures
    `static float` | `weightingHue` Weighting of the hue for Lab / LCH difference measures
    `static float` | `weightingLuminance` Weighting of the luminance for Lab / LCH difference measures

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.Float` | `difference(int color1, int color2)` Calculates the difference / distance between two colors.
    `static java.lang.Float` | `difference(RColor color1, RColor color2)` Calculates the difference / distance between two colors.
    `static java.lang.Float` | `difference(RColor color1, RColor color2, ColorDifferenceMeasure measure)` Calculates the difference / distance between two colors.
    `static java.lang.Integer` | `getMostDifferentColor(RColor[] bases, java.util.ArrayList<RColor> targets, ColorDifferenceMeasure measure)` Calculates the most different color of all targets to the base colors.
    `static java.lang.Integer` | `getMostDifferentColor(RColor[] bases, RColor[] targets, ColorDifferenceMeasure measure)` Calculates the most different color of all targets to the base colors.
    `static java.lang.Integer` | `getMostDifferentColor(RColor base, java.util.ArrayList<RColor> targets, ColorDifferenceMeasure measure)` Calculates the most different color of all targets to the base color.
    `static java.lang.Integer` | `getMostDifferentColor(RColor base, RColor[] targets, ColorDifferenceMeasure measure)` Calculates the most different color of all targets to the base color.
    `static java.lang.Integer` | `getMostSimilarColor(RColor base, java.util.ArrayList<RColor> targets, boolean ignoreSelf, ColorDifferenceMeasure measure)` Calculates the most similar color of all targets to the base color.
    `static java.lang.Integer` | `getMostSimilarColor(RColor base, java.util.ArrayList<RColor> targets, ColorDifferenceMeasure measure)` Calculates the most similar color of all targets to the base color.
    `static java.lang.Integer` | `getMostSimilarColor(RColor base, RColor[] targets, boolean ignoreSelf, ColorDifferenceMeasure measure)` Calculates the most similar color of all targets to the base color.
    `static java.lang.Integer` | `getMostSimilarColor(RColor base, RColor[] targets, ColorDifferenceMeasure measure)` Calculates the most similar color of all targets to the base color.
    `static java.lang.Float` | `hsbCone(RColor color1, RColor color2)` Calculates the difference / distance between two colors using HSB Euclidean distance using the 3D interpretation of the color model.
    `static java.lang.Float` | `hsbCylinder(RColor color1, RColor color2)` Calculates the difference / distance between two colors using HSB Euclidean distance using the 3D interpretation of the color model.
    `static java.lang.Float` | `hsbEuclidean(RColor color1, RColor color2)` Calculates the difference / distance between two colors using HSB Euclidean distance.
    `static java.lang.Float` | `labDeltaC(RColor color1, RColor color2)` Calculates the chroma difference / distance between two colors.
    `static java.lang.Float` | `labDeltaE(RColor color1, RColor color2)` Calculates the difference / distance between two colors using Lab Euclidean (Delta E) distance.
    `static java.lang.Float` | `labDeltaE1994(RColor color1, RColor color2)` Calculates the difference / distance between two colors using Lab Delta E 1994 distance.
    `static java.lang.Float` | `labDeltaE2000(RColor color1, RColor color2)` Calculates the difference / distance between two colors using Lab Delta E 2000 distance.
    `static java.lang.Float` | `labDeltaH(RColor color1, RColor color2)` Calculates the hue difference between two colors.
    `static java.lang.Float` | `lchCMC(RColor color1, RColor color2)` Calculates the difference / distance between two colors using CMC distance.
    `static java.lang.Float` | `lchEuclidean(RColor color1, RColor color2)` Calculates the difference / distance between two colors using LCH Euclidean distance.
    `static java.lang.Float` | `rgbEuclidean(RColor color1, RColor color2)` Calculates the difference / distance between two colors using RGB Euclidean distance.
    `static java.lang.Float` | `rgbMeanRed(RColor color1, RColor color2)` Calculates the difference / distance between two colors using RGB Euclidean distance weighted with a mean red value.
    `static java.lang.Float` | `rgbWeighted(RColor color1, RColor color2)` Calculates the difference / distance between two colors using weighted RGB Euclidean distance.
    `static java.lang.Float` | `xyzEuclidean(RColor color1, RColor color2)` Calculates the difference / distance between two colors using XYZ Euclidean distance.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### weightingLuminance

          public static float weightingLuminance

      Weighting of the luminance for Lab / LCH difference measures

    - #### weightingChroma

          public static float weightingChroma

      Weighting of the chroma for Lab / LCH difference measures

    - #### weightingHue

          public static float weightingHue

      Weighting of the hue for Lab / LCH difference measures

  - ### Method Detail

    - #### getMostSimilarColor

          public static java.lang.Integer getMostSimilarColor(RColor base,
                                                              RColor[] targets,
                                                              ColorDifferenceMeasure measure)

      Calculates the most similar color of all targets to the base color. Uses measure to determinate which similarity measure to use. If base is a member of targets, base will be the most similar color.
      Parameters:
        `base` - One color (not null).
        `targets` - Colors from which to chose the similar color from (not null, but the values might be null).
        `measure` - A measure for the similarity (not null).
      Returns:
        The index of the most similar color or -1 if no color found.

    - #### getMostSimilarColor

          public static java.lang.Integer getMostSimilarColor(RColor base,
                                                              RColor[] targets,
                                                              boolean ignoreSelf,
                                                              ColorDifferenceMeasure measure)

      Calculates the most similar color of all targets to the base color. Uses measure to determinate which similarity measure to use. When ignoreSelf is false and base is a member of targets, base will be the most similar color. Otherwise base will be ignored.
      Parameters:
        `base` - - One color (not null).
        `targets` - Colors from which to chose the similar color from (not null, but the values might be null).
        `ignoreSelf` - When true, base will be ignored when it is member of targets.
        `measure` - A measure for the similarity (not null).
      Returns:
        The index of the most similar color or -1 if no color found.

    - #### getMostSimilarColor

          public static java.lang.Integer getMostSimilarColor(RColor base,
                                                              java.util.ArrayList<RColor> targets,
                                                              ColorDifferenceMeasure measure)

      Calculates the most similar color of all targets to the base color. Uses measure to determinate which similarity measure to use. If base is a member of targets, base will be the most similar color.
      Parameters:
        `base` - One color (not null).
        `targets` - Colors from which to chose the similar color from (not null, but the values might be null).
        `measure` - A measure for the similarity (not null).
      Returns:
        The index of the most similar color or -1 if no color found.

    - #### getMostSimilarColor

          public static java.lang.Integer getMostSimilarColor(RColor base,
                                                              java.util.ArrayList<RColor> targets,
                                                              boolean ignoreSelf,
                                                              ColorDifferenceMeasure measure)

      Calculates the most similar color of all targets to the base color. Uses measure to determinate which similarity measure to use. When ignoreSelf is false and base is a member of targets, base will be the most similar color. Otherwise base will be ignored for the similarity.
      Parameters:
        `base` - One color (not null).
        `targets` - Colors from which to chose the similar color from (not null, but the values might be null).
        `ignoreSelf` - When true, base will be ignored when it is member of targets.
        `measure` - A measure for the similarity (not null).
      Returns:
        The index of the most similar color or -1 if no color found.

    - #### getMostDifferentColor

          public static java.lang.Integer getMostDifferentColor(RColor base,
                                                                RColor[] targets,
                                                                ColorDifferenceMeasure measure)

      Calculates the most different color of all targets to the base color. Uses measure to determinate which distance measure to use.
      Parameters:
        `base` - One color (not null).
        `targets` - Colors from which to chose the different color from (not null, but values might be null)
        `measure` - A measure for the similarity.
      Returns:
        The index of the most different color or -1 if no color found.

    - #### getMostDifferentColor

          public static java.lang.Integer getMostDifferentColor(RColor base,
                                                                java.util.ArrayList<RColor> targets,
                                                                ColorDifferenceMeasure measure)

      Calculates the most different color of all targets to the base color. Uses measure to determinate which distance measure to use.
      Parameters:
        `base` - - One color (not null).
        `targets` - - Colors from which to chose the different color from (not null, but values might be null)
        `measure` - - A measure for the similarity.
      Returns:
        The index of the most different color or -1 if no color found.

    - #### getMostDifferentColor

          public static java.lang.Integer getMostDifferentColor(RColor[] bases,
                                                                java.util.ArrayList<RColor> targets,
                                                                ColorDifferenceMeasure measure)

      Calculates the most different color of all targets to the base colors. Uses measure to determinate which distance measure to use.
      Parameters:
        `bases` - - Colors (not null).
        `targets` - - Colors from which to chose the different color from (not null, but values might be null)
        `measure` - - A measure for the similarity.
      Returns:
        The index of the most different color or -1 if no color found.

    - #### getMostDifferentColor

          public static java.lang.Integer getMostDifferentColor(RColor[] bases,
                                                                RColor[] targets,
                                                                ColorDifferenceMeasure measure)

      Calculates the most different color of all targets to the base colors. Uses measure to determinate which distance measure to use.
      Parameters:
        `bases` - - Colors (not null).
        `targets` - - Colors from which to chose the different color from (not null, but values might be null)
        `measure` - - A measure for the similarity.
      Returns:
        The index of the most different color or -1 if no color found.

    - #### difference

          public static java.lang.Float difference(int color1,
                                                   int color2)

      Calculates the difference / distance between two colors. Uses RGB Euclidean distance.
      Parameters:
        `color1` - One color.
        `color2` - One color .
      Returns:
        The value of the difference / distance.

    - #### difference

          public static java.lang.Float difference(RColor color1,
                                                   RColor color2)

      Calculates the difference / distance between two colors. Uses the Euclidean distance of the first colors color space. E.G. if color1 is a RGBColor then the RGBEuclidean distance will be used.
      Parameters:
        `color1` - One color.
        `color2` - One color .
      Returns:
        The value of the difference / distance.

    - #### difference

          public static java.lang.Float difference(RColor color1,
                                                   RColor color2,
                                                   ColorDifferenceMeasure measure)

      Calculates the difference / distance between two colors. How the difference is calculated and which color model to use is defined by the measure.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
        `measure` - A ColorDifferenceMeasure, e.g. ColorDifferenceMeasure.RGBEuclidean
      Returns:
        The value of the difference / distance.

    - #### rgbEuclidean

          public static java.lang.Float rgbEuclidean(RColor color1,
                                                     RColor color2)

      Calculates the difference / distance between two colors using RGB Euclidean distance.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### rgbWeighted

          public static java.lang.Float rgbWeighted(RColor color1,
                                                    RColor color2)

      Calculates the difference / distance between two colors using weighted RGB Euclidean distance. Red is weighted with 2, Green is weighted with 3 and Blue is weighted with 3.
      Parameters:
        `color1` - - One color (not null).
        `color2` - - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### rgbMeanRed

          public static java.lang.Float rgbMeanRed(RColor color1,
                                                   RColor color2)

      Calculates the difference / distance between two colors using RGB Euclidean distance weighted with a mean red value.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### hsbEuclidean

          public static java.lang.Float hsbEuclidean(RColor color1,
                                                     RColor color2)

      Calculates the difference / distance between two colors using HSB Euclidean distance.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### hsbCylinder

          public static java.lang.Float hsbCylinder(RColor color1,
                                                    RColor color2)

      Calculates the difference / distance between two colors using HSB Euclidean distance using the 3D interpretation of the color model.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### hsbCone

          public static java.lang.Float hsbCone(RColor color1,
                                                RColor color2)

      Calculates the difference / distance between two colors using HSB Euclidean distance using the 3D interpretation of the color model.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### xyzEuclidean

          public static java.lang.Float xyzEuclidean(RColor color1,
                                                     RColor color2)

      Calculates the difference / distance between two colors using XYZ Euclidean distance.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### labDeltaC

          public static java.lang.Float labDeltaC(RColor color1,
                                                  RColor color2)

      Calculates the chroma difference / distance between two colors.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### labDeltaH

          public static java.lang.Float labDeltaH(RColor color1,
                                                  RColor color2)

      Calculates the hue difference between two colors.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### labDeltaE

          public static java.lang.Float labDeltaE(RColor color1,
                                                  RColor color2)

      Calculates the difference / distance between two colors using Lab Euclidean (Delta E) distance.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### labDeltaE1994

          public static java.lang.Float labDeltaE1994(RColor color1,
                                                      RColor color2)

      Calculates the difference / distance between two colors using Lab Delta E 1994 distance.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### labDeltaE2000

          public static java.lang.Float labDeltaE2000(RColor color1,
                                                      RColor color2)

      Calculates the difference / distance between two colors using Lab Delta E 2000 distance.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### lchCMC

          public static java.lang.Float lchCMC(RColor color1,
                                               RColor color2)

      Calculates the difference / distance between two colors using CMC distance.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.

    - #### lchEuclidean

          public static java.lang.Float lchEuclidean(RColor color1,
                                                     RColor color2)

      Calculates the difference / distance between two colors using LCH Euclidean distance.
      Parameters:
        `color1` - One color (not null).
        `color2` - One color (not null).
      Returns:
        The value of the difference / distance.