Nodes/comfyui_cv/cv2.kmeans
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.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
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)

NameTypeDefaultDescription
dataNPARRAYData 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.
KINT0-2147483648–2147483647Number of clusters to split the set by.
criteria_typeCOMBOmax 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_countINT301–2147483647Maximum iterations (ignored when 'epsilon only').
criteria_epsilonFLOAT0.000–1e+38Target accuracy / smallest change worth continuing for (ignored when 'max count only').
attemptsINT0-2147483648–2147483647Flag 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).
flagsCOMBOKMEANS_PP_CENTERSFlag that can take values of cv::KmeansFlags
bestLabelsoptNPARRAYInput/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)

NameTypeDescription
retvalFLOAT
bestLabelsNPARRAY
centersNPARRAY