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.
CV Labels to Masks (full size)
- labels
- masks
- label_values
- count
◄sortby label value►
◄backgroundkeep every label►
Categoryimage/CV
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| labels | NPARRAY | (H, W) integer label map; each distinct id becomes one full-size mask. A batch of maps uses frame 0. | |
| sort | COMBO | by label value | Order of the output masks: by label id, or by area (largest first). |
| backgroundopt | COMBO | keep 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)
| Name | Type | Description |
|---|---|---|
| masks | MASK | One full-size mask per distinct label, as a MASK batch (aligned with 'label_values'). |
| label_values | NPARRAY | (B,) int32: the label id of each mask. |
| count | INT | B, the number of distinct labels. |