palettes | R Documentation |
image_palette()
creates image palettes by applying the k-means algorithm
to the RGB values.
image_palette(
img,
pattern = NULL,
npal = 5,
proportional = TRUE,
colorspace = c("rgb", "hsb"),
plot = TRUE,
save_image = FALSE,
prefix = "proc_",
dir_original = NULL,
dir_processed = NULL,
return_pal = FALSE,
parallel = FALSE,
workers = NULL,
verbose = TRUE
)
img |
An image object. |
pattern |
A pattern of file name used to identify images to be imported.
For example, if |
npal |
The number of color palettes. |
proportional |
Creates a joint palette with proportional size equal to
the number of pixels in the image? Defaults to |
colorspace |
The color space to produce the clusters. Defaults to |
plot |
Plot the generated palette? Defaults to |
save_image |
Save the image after processing? The image is saved in the
current working directory named as |
prefix |
The prefix to be included in the processed images. Defaults to
|
dir_original , dir_processed |
The directory containing the original and
processed images. Defaults to |
return_pal |
Return the color palette image? Defaults to |
parallel |
If TRUE processes the images asynchronously (in parallel) in separate R sessions running in the background on the same machine. |
workers |
A positive numeric scalar or a function specifying the number of parallel processes that can be active at the same time. By default, the number of sections is set up to 30% of available cores. |
verbose |
If |
image_palette()
returns a list with two elements:
palette_list
A list with npal
color palettes of class Image
.
joint
An object of class Image
with the color palettes
proportions
The proportion of the entire image corresponding to each color in the palette
rgbs
The average RGB value for each palette
library(pliman)
img <- image_pliman("sev_leaf.jpg")
pal <- image_palette(img, npal = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.