# delta_e 0.2.0 delta_e: ^0.2.0 copied to clipboard

CIE color difference algorithms in Dart. This contains the dE76, dE94 and dE00 color difference algorithms produced by the International Commission on Illumination.

# DeltaE - Quantify Color Difference #

CIE color difference algorithms in Dart. This is a port of zschuessler's JavaScript **DeltaE** library. You can learn about the Delta E metric here: https://zschuessler.github.io/DeltaE/learn/.

## How to use it #

This package differs from the original JavaScript version in quite a few ways. You can compare the following code to the original library's *Use It*
section to get a sense of differences between the two.

```
// Creating two test LAB color objects to compare
LabColor lab1 = LabColor(36, 60, 41);
LabColor lab2 = LabColor(100, 40, 90);
// 1976 formula
print(deltaE76(lab1, lab2)); // 83.04817878797824
print(deltaE(lab1, lab2, algorithm: DeltaEAlgorithm.cie76)); // 83.04817878797824
// 1994 formula
print(deltaE94(lab1, lab2)); // 67.97917774753019
print(deltaE(lab1, lab2, algorithm: DeltaEAlgorithm.cie94)); // 67.97917774753019
// 2000 formula
print(deltaE00(lab1, lab2)); // 56.85828292477247
print(deltaE(lab1, lab2, algorithm: DeltaEAlgorithm.ciede2000)); // 56.85828292477247
```

### Top-Level Functions #

**deltaE76(LabColor lab1, LabColor lab2)**

The 1976 formula is the first formula that related a measured color difference to a known set of CIELAB coordinates. This formula has been succeeded by the 1994 and 2000 formulas because the CIELAB space turned out to be not as perceptually uniform as intended, especially in the saturated regions. This means that this formula rates these colors too highly as opposed to other colors.**deltaE94(LabColor lab1, LabColor lab2, [ Weights weights = const Weights() ])**

The 1976 definition was extended to address perceptual non-uniformities, while retaining the CIELAB color space, by the introduction of application-specific weights derived from an automotive paint test's tolerance data.**deltaE00(LabColor lab1, LabColor lab2, [ Weights weights = const Weights() ])**

Since the 1994 definition did not adequately resolve the perceptual uniformity issue, the CIE refined their definition, adding five corrections:- A hue rotation term, to deal with the problematic blue region (hue angles in the neighborhood of 275°)
- Compensation for neutral colors (the primed values in the L
*C*h differences) - Compensation for lightness
- Compensation for chroma
- Compensation for hue

**deltaE(LabColor lab1, LabColor lab2, { DeltaEAlgorithm algorithm = DeltaEAlgorithm.ciede2000, Weights weights = const Weights() })**

Another way of calling the three above functions by passing an algorithm parameter which specifies which formula to use.

### Classes #

**LabColor(double lightness, double chroma, double hue)**

Represents a color in the CIELAB color space, required by all top-level functions. The lightness (L*) must be between 0 and 100, the chroma (a*) between -128 and 128, and the hue (b*) between -128 and 128. This class comes with handy factories that create LabColor instances from RGB, ARGB and RGBA values (alpha is ignored).**Weights({ double lightness = 1, double chroma = 1, double hue = 1 })**

Used to configure the weight factors of the 1994 and 2000 formulas. All the factors must be positive.

### Enums #

**DeltaEAlgorithm**

Represents a DeltaE algorithm. It can be either cie76, cie94 or ciede2000.

## Tests #

The tests have been ported using the **test** package. You can run them from the following command from inside this package's folder.

```
pub run test test/delta_e_test.dart
```