colorClustersHist {recolorize}R Documentation

Cluster pixel colors using histogram binning

Description

Clusters pixel colors by dividing color space up into specified bins, then taking the average color of all the pixels within that bin.

Usage

colorClustersHist(
  pixel_matrix,
  bins = 3,
  color_space = "Lab",
  ref_white = "D65"
)

Arguments

pixel_matrix

2D matrix of pixels to classify (rows = pixels, columns = channels).

bins

Number of bins for each channel OR a vector of length 3 with bins for each channel. bins = 3 will result in 3^3 = 27 bins; bins = c(2, 2, 3) will result in 223 = 12 bins (2 red, 2 green, 3 blue if you're in RGB color space), etc.

color_space

Color space in which to cluster colors, passed to grDevices{convertColor}. One of "sRGB", "Lab", or "Luv". Default is "Lab", a perceptually uniform (for humans) color space.

ref_white

Reference white for converting to different color spaces. D65 (the default) corresponds to standard daylight.

Details

Called by colorClusters. See that documentation for examples.

Value

A list with the following elements:

  1. pixel_assignments: A vector of color center assignments for each pixel.

  2. centers: A matrix of color centers.

  3. sizes: The number of pixels assigned to each cluster.


[Package recolorize version 0.1.0 Index]