Function: kmeans()
kmeans(
__named_parameters):Promise<{labels:Int32Array;pixels:Uint8ClampedArray; }>
Defined in: safeWasmWrappers.js:151
Parameters
__named_parameters
any
The input options.
Returns
Promise<{ labels: Int32Array; pixels: Uint8ClampedArray; }>
Clustered pixels and labels.
Description
Apply a standard K-Means clustering algorithm to the input image in the specified color_space
(default is 0: CIE LAB, but 1: sRGB can be use) using pre-specified maximum color and iteration counts.
You can provide the out_pixels and out_labels arrays,
however this is atypical in JavaScript (since it is modified in-place and you will need to allocate a sufficiently large array),
so it is recommended to use the default arguments and returns.
Async
kmeans
Throws
If the WASM function fails or iterations do not converge.
Example
const { pixels: clusteredPixels, labels } = await kmeans({ pixels, width, height, num_colors: 8 });
Variation
K-means clustering with default color space
Since
0.0.0