Description Usage Arguments Details Value Examples
create_pal
creates a palette using
colors extracted from an image.
1 2 3 4 5 6 7 8 9 10 11 |
image |
a file path/URL to the raster image (JPG, JPEG, PNG, TIFF) from which the colors are to be extracted. |
n |
a positive integer. The number of colors to be returned in the palette. |
resize |
a number between 0 and 1. This indicates the fraction by which
the width and height (in pixels) of the original image is resized through
|
method |
the classification method for grouping the image pixels based
on the RGB values. Options are |
colorblind |
logical. Whether to render the palette colorblind-friendly.
Default to |
sort |
a character indicating how the colors in the palette should be sorted.
Available options are |
show.pal |
logical. Whether to display the palette or not. Default to |
title |
a character string giving the title of the displayed palette. |
... |
additional arguments passed to |
Two clustering methods are available. For method = "kmeans"
,
image pixels are partitioned into clusters using kmeans
,
and the RGB values of the cluster centers are converted into the corresponding
hexadecimal color codes. For method = "Gaussian_mix"
, pixel components
are identified via multivariate Gaussian mixture modeling using ClusterR::GMM
,
and the RGB values of the component centroids are converted into the
corresponding hexadecimal color codes.
If "colorblind = TRUE"
, the original colors returned in the palette
are converted into their colorblind-friendly counterparts using
colorBlindness::replacePlotColor
.
The colors returned in the palette can be ordered in the HSV color space.
If sort = "hue"
, the colors are sorted by hue in an ascending order.
If sort = "saturation"
, the colors are sorted by saturation in a descending order.
If sort = "value"
, the colors are sorted by value in a descending order.
A vector of hexadecimal color codes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
library(PalCreatoR)
image_path <- system.file("Mountain.JPG", package = "PalCreatoR")
My_pal <- create_pal(image = image_path,
n = 5,
resize = 0.1,
method = "kmeans",
colorblind = FALSE,
sort = "value",
show.pal = TRUE,
title = "My Palette")
print(My_pal)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.