ComfyUI Node
cv2.kmeans
Raw wrapper of cv2.kmeans(data, K, bestLabels, criteria, attempts, flags). Parameters marked '?' are optional; blank means OpenCV default. See the OpenCV documentation for details.
cv2.kmeans
- data
- bestLabels
- retval
- bestLabels
- centers
◄K0►
◄criteria_typemax count or epsilon (whichever first)►
◄criteria_max_count30►
◄criteria_epsilon0.00►
◄attempts0►
◄flagsKMEANS_PP_CENTERS►
Categoryimage/CV/low-level/cv2 K
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| data | NPARRAY | Data for clustering. An array of N-Dimensional points with float coordinates is needed. Examples of this array can be: - Mat points(count, 2, CV_32F); - Mat points(count, 1, CV_32FC2); - Mat points(1, count, CV_32FC2); - std::vector\ points(sampleCount); A data array (points / matrix), NOT an image - only an NPARRAY link is accepted here. | |
| K | INT | 0-2147483648–2147483647 | Number of clusters to split the set by. |
| criteria_type | COMBO | max count or epsilon (whichever first) | When to stop iterating: after max_count iterations, when the change drops below epsilon, or whichever comes first. |
| criteria_max_count | INT | 301–2147483647 | Maximum iterations (ignored when 'epsilon only'). |
| criteria_epsilon | FLOAT | 0.000–1e+38 | Target accuracy / smallest change worth continuing for (ignored when 'max count only'). |
| attempts | INT | 0-2147483648–2147483647 | Flag to specify the number of times the algorithm is executed using different initial labellings. The algorithm returns the labels that yield the best compactness (see the last function parameter). |
| flags | COMBO | KMEANS_PP_CENTERS | Flag that can take values of cv::KmeansFlags |
| bestLabelsopt | NPARRAY | Input/output integer array that stores the cluster indices for every sample. Optional - leave unconnected for the OpenCV default (None). A data array (points / matrix), NOT an image - only an NPARRAY link is accepted here. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| retval | FLOAT | — |
| bestLabels | NPARRAY | — |
| centers | NPARRAY | — |