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")

(deltaE <- compare(pal(5)))
#>            blue      red    green   yellow
#> red    42.96901                           
#> green  45.17203 68.91205                  
#> yellow 58.32662 49.74802 31.70794         
#> cyan   27.21922 60.08809 45.20276 45.65689
summary(deltaE)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   27.22   43.52   45.43   47.50   56.18   68.91 

# Deuteranopia
deu <- convert(pal, mode = "deuteranopia")
compare(deu(5))
#>            blue      red    green   yellow
#> red    48.65131                           
#> green  47.54984 18.09392                  
#> yellow 62.21275 13.46961 26.56583         
#> cyan   24.04176 43.39140 51.12708 54.18900

# Protanopia
pro <- convert(pal, mode = "protanopia")
compare(pro(5))
#>            blue      red    green   yellow
#> red    33.88826                           
#> green  48.47198 14.79836                  
#> yellow 58.79437 24.03187 21.17733         
#> cyan   24.67298 34.21991 49.39259 49.55829

# Tritanopia
tri <- convert(pal, mode = "tritanopia")
compare(tri(5))
#>             blue       red     green    yellow
#> red    50.727249                              
#> green   1.346637 49.444911                    
#> yellow 43.626450 20.642711 42.597786          
#> cyan   24.817186 56.361997 23.961375 38.777287

# Achromatopsia
ach <- convert(pal, mode = "achromatopsia")
compare(ach(5))
#>             blue       red     green    yellow
#> red    15.133194                              
#> green  38.752027 19.522094                    
#> yellow 26.072281  9.633077 10.043244          
#> cyan   17.098221 31.695821 56.285350 41.893242