cie94ColorDifference method

bool cie94ColorDifference(
  1. LABColor color, {
  2. double tolerance = 1.0,
  3. ColorImageStyle colorImageStyle = ColorImageStyle.graphicArt,
  4. double kc = 1.0,
  5. double kh = 1.0,
  6. double sl = 1.0,
})

Compute color differences using the cie94 algorithm.

@color: color is a color of type LAB.

@tolerance: tolerance is the threshold for judging whether there is a difference.

@colorImageStyle: colorImageStyle is an enumeration type of the color image style. For more detailed content, see ColorImageStyle.

@kc: kc is a constant that adjusts the weight for color difference perception. The value of c depends on the color system used. When using the Lab* color space, the value of kc is usually 1. If other color spaces are used, it may be necessary to use different values of kc to obtain a more accurate assessment of color differences.

@kh: kh is a constant that adjusts the weight for brightness difference perception. kh is mainly used to adjust the effect of brightness changes on the evaluation of color differences. It measures the relationship between changes in brightness and how sensitive the human eye is to changes in color. The value of kh depends on the color system used. When using the Lab* color space, the value of kh is usually 1. If you use other color spaces, you may need to use different kh values to get a more accurate assessment of color differences.

@sl: sl is a constant that adjusts the influence of the L* component (luminance). The value of sl is usually 1, which is mainly used to adjust the influence of the L* component to better match the perception of the human visual system. Since the perception of brightness by human eyes is more sensitive than that of chroma, it is necessary to accurately evaluate the perception of color difference by adjusting the value of sl.

Implementation

bool cie94ColorDifference(
  LABColor color, {
  double tolerance = 1.0,
  ColorImageStyle colorImageStyle = ColorImageStyle.graphicArt,
  double kc = 1.0,
  double kh = 1.0,
  double sl = 1.0,
}) {
  final double deltaL = l - color.l;
  final double c1 = sqrt(pow(a, 2) + pow(b, 2));
  final double c2 = sqrt(pow(color.a, 2) + pow(color.b, 2));
  final double deltaC12 = c1 - c2;
  final double deltaA = a - color.a;
  final double deltaB = b - color.b;
  final double deltaH =
      sqrt(pow(deltaA, 2) + pow(deltaB, 2) - pow(deltaC12, 2));
  final double sc = 1 + colorImageStyle.k1 * c1;
  final double sh = 1 + colorImageStyle.k2 * c1;
  final double deltaE = sqrt(pow(deltaL / (colorImageStyle.kl * sl), 2) +
      pow(deltaC12 / (kc * sc), 2) +
      pow(deltaH / (kh * sh), 2));
  return deltaE > tolerance;
}