Skip to content

Latest commit

History

History
107 lines (69 loc) 路 3.78 KB

topic-color-difference.md

File metadata and controls

107 lines (69 loc) 路 3.78 KB

Computing color difference

The Colourful library contains a range of algorithms that can be used to compute a difference between colors, i.e. provide a certain metric that can be used as a distance between two colors in a color space.

The color difference is commonly denoted as delta E, or 螖E. Some of the algorithms operate on specific color spaces. If you want to use them in other color spaces, you can do so if you convert your colors into the required space beforehand.

CIE Delta-E 1976

The CIE76 algorithm operates in the Lab color space.

var labColor1 = new LabColor(55, 80, 50);
var labColor2 = new LabColor(18, 36, -60);
double difference = new CIE76ColorDifference().ComputeDifference(labColor1, labColor2); // 124.1169

Related links

CMC l:c (1984)

The CMC algorithm operates in the Lab color space and has two modes: Acceptability and Imperceptibility.

var differenceThreshold = CMCColorDifferenceThreshold.Acceptability; // or "Imperceptibility"
var differenceCalculator = new CMCColorDifference(differenceThreshold);
var labColor1 = new LabColor(55, 80, 50);
var labColor2 = new LabColor(18, 36, -60);
double difference = differenceCalculator.ComputeDifference(in labColor1, in labColor2); // 69.7388

Related links

CIE Delta-E 1994

The CIE94 algorithm operates in the Lab color space and has two modes: GraphicArts and Textiles.

var application = CIE94ColorDifferenceApplication.GraphicArts; // or "Textiles"
var differenceCalculator = new CIE94ColorDifference(application);
var labColor1 = new LabColor(55, 80, 50);
var labColor2 = new LabColor(18, 36, -60);
double difference = differenceCalculator.ComputeDifference(in labColor1, in labColor2); // 60.7882

Related links

CIE Delta-E 2000

The CIEDE2000 algorithm operates in the Lab color space.

var differenceCalculator = new CIEDE2000ColorDifference();
var labColor1 = new LabColor(55, 80, 50);
var labColor2 = new LabColor(18, 36, -60);
double difference = differenceCalculator.ComputeDifference(in labColor1, in labColor2); // 52.2320

Related links

JzCzhz Delta-Ez

The 螖Ez algorithm operates on the JzCzhz color space, a cylindrical variant of Jzazbz.

var differenceCalculator = new JzCzhzDEzColorDifference();
var color1 = new JzCzhzColor(0.3, 0.4, 165);
var color2 = new JzCzhzColor(0.8, 0.6, 25);
double difference = differenceCalculator.ComputeDifference(in color1, in color2); // 1.0666

Related links

Euclidean distance

The Euclidean distance is a generic algorithm that can operate in any color space.

// example for euclidean distance in the XYZ color space
var differenceCalculator = new EuclideanDistanceColorDifference<XYZColor>();
var color1 = new XYZColor(0.5, 0.5, 0.5);
var color2 = new XYZColor(0.2, 0.4, 0.6);
double difference = differenceCalculator.ComputeDifference(in color1, in color2); // 0.3317

Related links