# DeltaE: Calculate the Color Difference between Two Colors In spacesXYZ: CIE XYZ and some of Its Derived Color Spaces

## Description

Calculate Standard CIE Color Differences between two Colors

## Usage

 `1` ```DeltaE( Lab1, Lab2, metric=1976 ) ```

## Arguments

 `Lab1` a numeric Nx3 matrix with Lab values in the rows, or a vector that can be converted to such a matrix, by row. `Lab1` can also be a numeric 3-vector with a single Lab, and it is then replicated to match the size of `Lab2`. `Lab2` a numeric Nx3 matrix with Lab values in the rows, or a vector that can be converted to such a matrix, by row. `Lab2` can also be a numeric 3-vector with a single Lab, and it is then replicated to match the size of `Lab1`. `metric` a vector of color metric specifiers. Valid values are `'1976'`, `'1994'`, and `'2000'`, which refer to the year the metric was recommended by the CIE. They can also be given as integers, as shown. These metrics are often denoted Δ E_{1976}, Δ E_{1994}, and Δ E_{2000}. When more than one metric is given, a matrix is returned, see Value.

## Value

`DeltaE()` returns a numeric vector of length N, or an NxM matrix. It returns a matrix iff `length(metric)=` M 2; the column names are set to the metric names. The elements of the output are the pairwise differences, i.e. between row i of `Lab1` and row i of `Lab2`. The names or rownames are set to the rownames of one of the input matrices.

For `metric=1976` the distance is simply the Euclidean distance between the two points in Lab, see Hunt p. 111.
For `metric=1994` the symmetric version is used, see Hunt p. 670. There is an asymmetric version which is not available in this package.
For `metric=2000` the distance is insanely complicated, see Hunt p. 671.
All these metrics are symmetric, which means that swapping `Lab1` and `Lab2` does not change the result.

## References

Hunt, R. W. G. The Reproduction of Colour. 6th Edition. John Wiley & Sons. 2004.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```DeltaE( c(50,0,0), c(51,2,2, 52,10,11, 46,-13,16) ) ## [1] 3 15 21 path = system.file( "extdata/ciede2000testdata.txt", package='spacesXYZ' ) df = read.table( path, sep='\t', quote='', head=TRUE ) Lab1 = as.matrix( df[ , 1:3 ] ) Lab2 = as.matrix( df[ , 4:6 ] ) cbind( Lab1, Lab2, DeltaE( Lab1, Lab2, metric=c(1976,2000) ) )[ 1:10, ] ## LAB_L_REF LAB_A_REF LAB_B_REF LAB_L_SAM LAB_A_SAM LAB_B_SAM DeltaE.1976 DeltaE.2000 ## [1,] 50.0000 2.6772 -79.7751 50.0000 0.0000 -82.7485 4.0010633 2.0424597 ## [2,] 50.0000 3.1571 -77.2803 50.0000 0.0000 -82.7485 6.3141501 2.8615102 ## [3,] 50.0000 2.8361 -74.0200 50.0000 0.0000 -82.7485 9.1776999 3.4411906 ## [4,] 50.0000 -1.3802 -84.2814 50.0000 0.0000 -82.7485 2.0627008 0.9999989 ## [5,] 50.0000 -1.1848 -84.8006 50.0000 0.0000 -82.7485 2.3695707 1.0000047 ## [6,] 50.0000 -0.9009 -85.5211 50.0000 0.0000 -82.7485 2.9152927 1.0000130 ## [7,] 50.0000 0.0000 0.0000 50.0000 -1.0000 2.0000 2.2360680 2.3668588 ## [8,] 50.0000 -1.0000 2.0000 50.0000 0.0000 0.0000 2.2360680 2.3668588 ## [9,] 50.0000 2.4900 -0.0010 50.0000 -2.4900 0.0009 4.9800004 7.1791720 ## [10,] 50.0000 2.4900 -0.0010 50.0000 -2.4900 0.0010 4.9800004 7.1791626 ```

### Example output

```[1]  3 15 21
LAB_L_REF LAB_A_REF LAB_B_REF LAB_L_SAM LAB_A_SAM LAB_B_SAM DeltaE.1976
[1,]        50    2.6772  -79.7751        50      0.00  -82.7485    4.001063
[2,]        50    3.1571  -77.2803        50      0.00  -82.7485    6.314150
[3,]        50    2.8361  -74.0200        50      0.00  -82.7485    9.177700
[4,]        50   -1.3802  -84.2814        50      0.00  -82.7485    2.062701
[5,]        50   -1.1848  -84.8006        50      0.00  -82.7485    2.369571
[6,]        50   -0.9009  -85.5211        50      0.00  -82.7485    2.915293
[7,]        50    0.0000    0.0000        50     -1.00    2.0000    2.236068
[8,]        50   -1.0000    2.0000        50      0.00    0.0000    2.236068
[9,]        50    2.4900   -0.0010        50     -2.49    0.0009    4.980000
[10,]        50    2.4900   -0.0010        50     -2.49    0.0010    4.980000
DeltaE.2000
[1,]   2.0424597
[2,]   2.8615102
[3,]   3.4411906
[4,]   0.9999989
[5,]   1.0000047
[6,]   1.0000130
[7,]   2.3668588
[8,]   2.3668588
[9,]   7.1791720
[10,]   7.1791626
```

spacesXYZ documentation built on March 26, 2020, 7:03 p.m.