Skip to contents

Computes CIELAB distance metric.

Usage

compare(x, metric = 2000, diag = FALSE, upper = FALSE)

Arguments

x

A character vector of colors.

metric

An integer value giving the year the metric was recommended by the CIE. It must be one of "1976", "1994", or "2000" (default; see spacesXYZ::DeltaE()).

diag

A logical scalar: should the diagonal of the distance matrix be printed?

upper

A logical scalar: should the upper triangle of the distance matrix should be printed?

Value

A distance matrix.

See also

Author

N. Frerebeau

Examples

# Trichromat
pal <- colour("bright")
compare(pal(5))
#>          1        2        3        4
#> 2 42.96901                           
#> 3 45.17203 68.91205                  
#> 4 58.32662 49.74802 31.70794         
#> 5 27.21922 60.08809 45.20276 45.65689

# Deuteranopia
deu <- change(pal, mode = "deuteranopia")
compare(deu(5))
#>          1        2        3        4
#> 2 48.65131                           
#> 3 47.54984 18.09392                  
#> 4 62.21275 13.46961 26.56583         
#> 5 24.04176 43.39140 51.12708 54.18900

# Protanopia
pro <- change(pal, mode = "protanopia")
compare(pro(5))
#>          1        2        3        4
#> 2 33.88826                           
#> 3 48.47198 14.79836                  
#> 4 58.79437 24.03187 21.17733         
#> 5 24.67298 34.21991 49.39259 49.55829

# Tritanopia
tri <- change(pal, mode = "tritanopia")
compare(tri(5))
#>           1         2         3         4
#> 2 50.727249                              
#> 3  1.346637 49.444911                    
#> 4 43.626450 20.642711 42.597786          
#> 5 24.817186 56.361997 23.961375 38.777287

# Achromatopsia
ach <- change(pal, mode = "achromatopsia")
compare(ach(5))
#>           1         2         3         4
#> 2 15.133194                              
#> 3 38.752027 19.522094                    
#> 4 26.072281  9.633077 10.043244          
#> 5 17.098221 31.695821 56.285350 41.893242