CMClc: Compute the CMC l:c difference between two colors

View source: R/compute_CMClc.R

CMClcR Documentation

Compute the CMC l:c difference between two colors

Description

Compute the difference between two colors, using the CMC l:c metric. https://en.wikipedia.org/wiki/Color_difference#CMC_l:c_(1984).

Usage

CMClc(x, y, l = 1, c = 1)

Arguments

x, y

colors specified as hex strings or named R colors.

l, c

weighting factors for lightness and chromacity.

Value

A number quantifying the difference between x and y (or a vector thereof).

See Also

deltaE for another (probably more consistent) metric of difference between colors and color_distance for a numerical definition of the distance between two colors.

Examples

CMClc("pink", "hotpink")
CMClc("pink", "blue")

# NB: his definition of distance is not symetrical
CMClc("pink", "blue")
CMClc("blue", "pink")

# The computation can be vectorised
# For example to find the closest color in an array of possibilities
clrs <- rainbow(20)
show_col("pink", clrs)
d <- CMClc("pink", clrs)
show_col("pink", clrs[which.min(d)])

jiho/chroma documentation built on Nov. 26, 2022, 2:39 a.m.