dataFramePalette: Quantize RGB colours into a palette.

Description Usage Arguments Value Examples

Description

This function uses k-means clustering to extract a palette from a data.frame representing the RGB values of pixels in an image. This is not the most state-of-the-art method of extracting a palette, but works as well as most photo editing software.

Usage

1
dataFramePalette(dataframe, count)

Arguments

dataframe

A data.frame representing the colours of the pixels in the image, generated by imageToDataFrame().

count

The number of colours to try to extract

Value

A vector of colorspace library RGB objects.

Examples

1
2
3
4
5
6
7
library(CulturalAnalytics)
library(jpeg)
imgdir<-paste(system.file(package = "CulturalAnalytics"), "images", sep = "/")
imgs<-paste(imgdir, dir(path = imgdir, pattern = ".jpg"), sep = "/")
img<-readJPEG(imgs[1])
df<-imageToDataFrame(img)
palette<-dataFramePalette(df, 8)

CulturalAnalytics documentation built on May 2, 2019, 5:24 p.m.