Learn R Programming

colouR (version 0.1.1)

img2pal: Create a Colour Palette from an Image

Description

This function generates a colour palette based on the most prominent colors in an image..

Usage

img2pal(
  path,
  n = NULL,
  avgCols = FALSE,
  exclude = FALSE,
  n_clusters = NULL,
  customExclude = NULL
)

Value

A colour palette generated from input image.

Arguments

path

Character string. The path to the image file.

n

Integer. The number of most frequent colours in input image to consider.

avgCols

Logical. Whether to average colours within clusters.

exclude

Character vector. List of colours in HEX format to exclude from the palette.

n_clusters

Integer. The number of clusters for colour grouping.

customExclude

Character vector. Optional vector of custom color codes in HEX format to be excluded.

Examples

Run this code
pal<-img2pal(path = "https://raw.githubusercontent.com/AlanInglis/colouR/master/images/bender.png",
             n = 10,
             avgCols = TRUE,
             exclude = TRUE,
             n_clusters = 15,
             customExclude = NULL)
pal

Run the code above in your browser using DataLab