API Reference
Basics
All methods in ColorQuantization.jl work by calling quantize
on an input and a quantizer:
ColorQuantization.quantize
— Functionquantize([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
.
Quantization methods
ColorQuantization.UniformQuantization
— TypeUniformQuantization(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 n³
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 n³
.
ColorQuantization.KMeansQuantization
— TypeKMeansQuantization([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 initializedmaxiter
: maximum number of iterationstol
: 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 belowtol
.
The default values are carried over from are imported from Clustering.jl. For more details, refer to the documentation of Clustering.jl.