Nodes/comfyui_cv/CV Reduce Values By Label
ComfyUI Node

CV Reduce Values By Label

Collapses a labeled value array (e.g. the per-point angles of 'CV Points To Polar' + the labels of the 'CV K-Means Points' blueprint) to one number per cluster: the mean, the median, or the mode - the center of the densest window of the cluster's value distribution. The mode is the robust choice when a minority of contaminating members sits to one side (a numeral fused to a clock hand shifts the mean AND the median, but the hand's collinear pixels still form the densest spike). Rows follow the label order (0, 1, ...), aligned with 'CV Reduce Points By Label' over the same labels. Empty input yields empty outputs. For an IMAGE-scale reduction (multi-channel, a 2-D label map, rows indexed by label value) use 'CV Reduce Array By Label' instead - this one is a per-POINT reducer and its mode path is quadratic in the cluster size.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Reduce Values By Label
  • values
  • labels
  • values
  • support
  • count
reductionmean
bandwidth2.00
circular_period0.00
Categoryimage/CV/points

Inputs (5)

NameTypeDefaultDescription
valuesNPARRAY(N,) numeric array, one value per point.
labelsNPARRAY(N,) integer label per value.
reductionCOMBOmeanPer-cluster summary. mode (densest window) is the robust choice when a minority of contaminating values skews the mean and median.
bandwidthFLOAT2.000.000001–1000000Mode only: half-width of the density window. The value with the most neighbors within +/-bandwidth wins; the result is the mean of that window.
circular_periodFLOAT0.000–1000000Treat values as circular with this period (360 for angles in degrees, so 359 and 1 are 2 apart); 0 = plain numbers.

Outputs (3)

NameTypeDescription
valuesNPARRAY(K,) float32, one value per label.
supportNPARRAY(K,) int32: members inside the winning mode window (= cluster size for mean/median). Low support relative to the cluster size means no clear spike.
countINTK, the number of labels.