image_pal: Image palette

Description Usage Arguments Examples

View source: R/scale_image.R

Description

Image palette function

Usage

1
image_pal(image, choice = mean, volume = FALSE)

Arguments

image

Matrix The image from which the palette will be extracted from. Should be a 3 (or more) dimensional matrix. The output of a function such as readJPG() or readPNG() are suitable as image.

choice

Function Defines how the color will be chosen from the final color cubes. The default choice is to take the mean value of the image cube, but other choices may return a subjectively superior scale. Try median, or min, or max, or whatever summary statistic suits your fancy.

volume

Logical volume controls the method for choosing which color cube to split at each iteration of the algorithm. The default choice (when volume = FALSE) is to choose the cube based on which cube contains the largest extent (that is, the largest range of some color). When volume = TRUE, the cube with the largest volume is chosen to split. Occasionally, setting to TRUE returns a better palette.

Examples

1
2
3
img <- jpeg::readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))
display_image(img)
scales::show_col(image_pal(img)(10))

RImagePalette documentation built on May 2, 2019, 9:19 a.m.