closest.color.from.palette | R Documentation |
Find closest color from a palette for given colors. The similarity method used to define 'closest' is deltaE, and the input RGB colors are transformed to LAB space for the computation, assuming they are given in sRGB space.
closest.color.from.palette(colors_rgb, fixed_palette_rgb)
colors_rgb |
n x 3 integer matrix, the truecolor (arbitrary) input RGB colors for which you want to find the most similar colors included in the fixed palette. Range 0..255. |
fixed_palette_rgb |
the fixed palette, an n x 3 matrix of integers, representing the fixed palette colors in RGB values in range 0..255. |
vector of n integers, the index of the closest color into the palette for each of the colors_rgb
.
colors_rgb = matrix(c(255, 0, 0, 100, 100, 100, 10, 10, 10, 5, 5, 5),
ncol = 3, byrow = TRUE);
fixed_palette_rgb = matrix(c(255, 0, 0, 255, 5, 0, 11, 11, 11, 0, 0, 0,
255, 255, 255), ncol = 3, byrow = TRUE);
pal_similar_colors = closest.color.from.palette(colors_rgb,
fixed_palette_rgb);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.