# 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 LCh 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
``````

## 0.1.0+1 #

• Further optimization for pub.dev (adding curly braces to flow control structures)

## 0.1.0 #

• Optimization for pub.dev

## 0.0.3 #

• Initial release

example/main.dart

``````import 'package:delta_e/delta_e.dart';

void main() {
// 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
}
``````

## Use this package as a library

### 1. Depend on it

``````
dependencies:
delta_e: ^0.1.0+1

``````

### 2. Install it

You can install packages from the command line:

with pub:

``````
\$ pub get

``````

with Flutter:

``````
\$ flutter pub get

``````

Alternatively, your editor might support `pub get` or `flutter pub get`. Check the docs for your editor to learn more.

### 3. Import it

Now in your Dart code, you can use:

``````
import 'package:delta_e/delta_e.dart';
``````
 Popularity: Describes how popular the package is relative to other packages. [more] 28 Health: Code health derived from static analysis. [more] 100 Maintenance: Reflects how tidy and up-to-date the package is. [more] 100 Overall: Weighted score of the above. [more] 64

We analyzed this package on Feb 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

• Dart: 2.7.1
• pana: 0.13.5

#### Health suggestions

Format `lib/delta_e.dart`.

Run `dartfmt` to format `lib/delta_e.dart`.

#### Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
test ^1.9.4