getTopCol {colouR}R Documentation

getTopCol

Description

Get top colors from an image. This function reads an image file, extracts the colors, and returns the top n colors based on their frequency in the image. Optionally, black and white shades can be excluded, and the colors can be grouped and averaged.

Usage

getTopCol(
  path,
  n = NULL,
  exclude = TRUE,
  sig = 4,
  avgCols = TRUE,
  n_clusters = 5,
  customExclude = NULL
)

Arguments

path

Character, the path to the image file (either jpg or png).

n

Integer, the number of top colors to return. If NULL (default), return all colors.

exclude

Logical, whether to exclude black and white shades. Default is TRUE.

sig

Integer, the number of decimal places for the color percentage. Default is 4.

avgCols

Logical, whether to average the colors by groups. Default is TRUE.

n_clusters

Integer, the number of clusters to use for grouping colors. Default is 5.

customExclude

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

Value

A data frame with the top colors, their frequency, and percentage in the image.


[Package colouR version 0.1.1 Index]