make_palette {colorfindr}R Documentation

Create a color palette from an image.

Description

make_palette creates a color palette from colors extracted from Windows BMP, JPEG, PNG, TIFF, and SVG format images with the get_colors function.

Usage

make_palette(data, n = 10, clust_method = "kmeans",
  extract_method = "hex_freq", show = TRUE)

Arguments

data

a data.frame from a get_colors call consisting of the columns col_hex, col_freq, col_share.

n

the number of discrete colors to be extracted from the data.

clust_method

specifies the method used to cluster the pixels. By default, the colors are clustered by the k-means method. Alternatively, a median cut approach "median_cut" can be used.

extract_method

specifies the process for extracting the colors from the clusters obtained. By default "hex_freq", the most common hex colors per cluster are returned. Alternatively, the cluster-specific"mean", "median" or "mode" of the RGB values can be used to define the desired number of hex colors.

show

by default "TRUE", the generated color palette is displayed.

Value

A character vector with hex color codes, sorted by the weight of the associated clusters.

Examples

# Create palette from image
img <- system.file("extdata", "pic6.png", package = "colorfindr")
colors <- get_colors(img)
make_palette(colors)


[Package colorfindr version 0.1.4 Index]