Nodes/comfyui_cv/CV Labels to Masks (full size)
ComfyUI Node

CV Labels to Masks (full size)

Splits a label map (per-pixel region id: HFS, superpixels, connectedComponents, k-means cluster maps) into one full-size mask per distinct label. Every present label becomes a region - including 0, unless 'background' drops it. Labels need not be contiguous; the batch rows align with 'label_values'. Empty input yields an empty MASK batch and count 0 and never raises.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Labels to Masks (full size)
  • labels
  • masks
  • label_values
  • count
sortby label value
backgroundkeep every label
Categoryimage/CV

Inputs (3)

NameTypeDefaultDescription
labelsNPARRAY(H, W) integer label map; each distinct id becomes one full-size mask. A batch of maps uses frame 0.
sortCOMBOby label valueOrder of the output masks: by label id, or by area (largest first).
backgroundoptCOMBOkeep every label'drop label 0' skips the background region, which is what a connectedComponents-style map (or any map built with 'CV Take By Index' over one) uses 0 for - without it every such map emits an extra, usually full-frame, background mask.

Outputs (3)

NameTypeDescription
masksMASKOne full-size mask per distinct label, as a MASK batch (aligned with 'label_values').
label_valuesNPARRAY(B,) int32: the label id of each mask.
countINTB, the number of distinct labels.