distance method

  1. @override
double distance(
  1. (double, double, double) one,
  2. (double, double, double) two
)
override

Standard CIE 1976 delta E formula also takes the square root, unneeded here. This method is used by quantization algorithms to compare distance, and the relative ordering is the same, with or without a square root.

This relatively minor optimization is helpful because this method is called at least once for each pixel in an image.

Implementation

@override
double distance((double, double, double) one, (double, double, double) two) {
  final dL = one.$1 - two.$1;
  final dA = one.$2 - two.$2;
  final dB = one.$3 - two.$3;
  return dL * dL + dA * dA + dB * dB;
}