API Reference

Basics

All methods in ColorQuantization.jl work by calling quantize on an input and a quantizer:

ColorQuantization.quantizeFunction
quantize([T,] im, alg)

Apply color quantization algorithm alg to an iterable collection of Colorants im, e.g. an image or any AbstractArray. The return type T can be specified and defaults to the element type of cs.

source

Quantization methods

ColorQuantization.UniformQuantizationType
UniformQuantization(n::Int)

Quantize colors in RGB color space by dividing each dimension of the $[0, 1]³$ RGB color cube into n equidistant steps for a total of cubes of equal size. Each color in cs is then quantized to the center of the cube it is in. Only unique colors are returned. The amount of output colors is therefore bounded by .

source
ColorQuantization.KMeansQuantizationType
KMeansQuantization([T=RGB,] ncolors)

Quantize colors by applying the K-means method, where ncolors corresponds to the amount of clusters and output colors.

The colorspace T in which K-means are computed defaults to RGB.

Optional arguments

The following keyword arguments from Clustering.jl can be specified:

  • init: specifies how cluster seeds are initialized
  • maxiter: maximum number of iterations
  • tol: minimal allowed change of the objective during convergence. The algorithm is considered to be converged when the change of objective value between consecutive iterations drops below tol.

The default values are carried over from are imported from Clustering.jl. For more details, refer to the documentation of Clustering.jl.

source