extractClusters: Extract cluster values and sizes from kmeans fit objects

Description Usage Arguments Value Note Examples

View source: R/02c_kmeans_color_clustering.R

Description

Extract a list of dataframes with the same format as those returned by getHistList, where each dataframe has 3 color attributes (R, G, B or H, S, V) and a size attribute (Pct) for every cluster.

Usage

1
extractClusters(getKMeansListObject, ordering = TRUE, normalize = FALSE)

Arguments

getKMeansListObject

A list of kmeans fit objects (especially as returned by getKMeansList).

ordering

Logical. Should clusters by reordered by color similarity? If TRUE, the Hungarian algorithm via solve_LSAP is applied to find the minimum sum of Euclidean distances between color pairs for every pair of cluster objects and colors are reordered accordingly.

normalize

Logical. Should each cluster be normalized to show R:G:B or H:S:V ratios rather than absolute values? Can be helpful for inconsistent lighting, but reduces variation. See normalizeRGB.

Value

A list of dataframes (same length as input list), each with 4 columns: R, G, B (or H, S, V) and Pct (cluster size), with one row per cluster.

Note

Names are inherited from the list passed to the function.

Examples

1
2
3
4
clusterList <- colordistance::getKMeansList(system.file("extdata",
"Heliconius/Heliconius_A", package="colordistance"), bins=3)

colordistance::extractClusters(clusterList)

colordistance documentation built on March 21, 2021, 1:06 a.m.