convert_colour

0th

Percentile

Convert between colour spaces

This function lets you convert between different representations of colours. The API is reminiscent of grDevices::convertColor(), but the performance is much better. It is not assured that grDevices::convertColor() and convert_colour() provide numerically equivalent conversion at 16bit level as the formula used are potentially slightly different. For all intend and purpose, the resulting colours will be equivalent though.

Usage
convert_colour(colour, from, to, white_from = "D65",
  white_to = white_from)
Arguments
colour

A numeric matrix (or an object coercible to one) with colours encoded in the rows and the different colour space values in the columns. For all colourspaces except 'cmyk' this will mean a matrix with three columns - for 'cmyk' it means four columns.

from, to

The input and output colour space. Allowed values are: "cmy", "cmyk", "hsl", "hsb", "hsv", "lab", "hunterlab", "lch", "luv", "rgb", "xyz", "yxy"

white_from, white_to

The white reference of the from and to colour space. Will only have an effect for relative colour spaces such as Lab and luv. Any value accepted by as_white_ref() allowed.

Value

A numeric matrix with the same number of rows as colour and either 3 or 4 columns depending on the value of to. If colour is given as a data.frame the output will be a data.frame as well

Note

This function and convertColor() are not numerically equivalent due to rounding errors, but for all intend and purpose they give the same results.

See Also

grDevices::convertColor(), grDevices::col2rgb()

Aliases
  • convert_colour
Examples
# NOT RUN {
spectrum <- t(col2rgb(rainbow(10)))
convert_colour(spectrum, 'rgb', 'lab')

# }
Documentation reproduced from package farver, version 1.1.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.