Functions to map vectors/matrices/arrays of colors between color spaces.
THESE FUNCTIONS REQUIRE THE colorspace PACKAGE TO BE INSTALLED AND LOADED.
One exception to this requirement is mapping numeric values to strings, if the "from" color space equals the "to" color space.
mapcol (colv, …, as.list = is.list(colv), as.string=FALSE,
from="sRGB", to=from, correction=TRUE)
mapcol3 (x, y, z, alpha, …, as.list=FALSE, as.string=FALSE,
from="sRGB", to=from, correction=TRUE)
A numeric array with two or more dimensions. (Such as the result of standardize.cols with as.array=TRUE. The last dimension should have three or four levels, which represent channels.
Numeric vectors. Alternative way of specifying color.
Logical, if true, return a list or string, see value section.
String, the input color space.
String, the output color space. Ignored, if as.string is true.
Logical, correct the sRGB values. Ignored, unless converting HCL to sRGB.
Ignored.
By default, these functions return arrays. Where the last dimension corresponds to channel.
If as.string is true, a character vector/matrix/array is returned. If as.list is true, a list is returned, with one element per channel.
The functions wrap functions from the colorspace package.
The to and from arguments, use names of color spaces from the colorspace package.
This includes: "XYZ", "RGB", "sRGB", "LAB", "polarLAB", "HSV", "HLS", "LUV" and "polarLUV".
In addition to HCL, with is the same as polarLUV, but the the arguments in a different order.
The same labels are used for three channel and four channel images.
# NOT RUN {
library (colorspace)
cols <- standardize.cols (
c ("black", "white", "#000000", "#FFFFFF"),
as.array=TRUE)
#hues
mapcol (cols, to="HCL")[,1]
# }
Run the code above in your browser using DataLab