palettes: Create image palettes

palettesR Documentation

Create image palettes

Description

image_palette() creates image palettes by applying the k-means algorithm to the RGB values.

Usage

image_palette(img, npal = 5, proportional = TRUE, plot = TRUE)

Arguments

img

An image object.

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 TRUE.

plot

Plot the generated palette? Defaults to TRUE.

Value

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

Examples


library(pliman)
img <- image_pliman("sev_leaf.jpg")
pal <- image_palette(img, npal = 4)

image_combine(pal$palette_list)



pliman documentation built on Oct. 15, 2023, 1:06 a.m.

Related to palettes in pliman...