FUNCTION REFERENCE
imsegkmeans
Segment image channels using k-means clustering.
Segment image channels using k-means clustering.
Syntax
[L, centers] = imsegkmeans(I, k)Syntax
[L, centers] = imsegkmeans(I, k, 'NumAttempts', n, 'MaxIterations', m, 'Threshold', t, 'NormalizeInput', flag)I is single, uint8, uint16, int8 or int16; use im2single for double images. Pixels are observations and image planes are features. Defaults: 3 attempts, 100 iterations, threshold 1e-4, per-channel zero-mean/unit-variance normalization enabled. Each center must move less than Threshold to stop. Centers are restored to input units and class, in a k-by-channels matrix. L matches the first two input dimensions and is uint8 for k<=255, uint16 for k<=65535, then uint32. Uses the engine rng stream and k-means++ core.
Example
rng(1); [L,C]=imsegkmeans(uint8([10 10 200; 10 200 200]),2)Differences from MATLAB: rng controls reproducibility as required by MatRust; repeated calls advance the stream. Pixel-by-cluster workspace is limited to 2097152 elements.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.