ComfyUI Node
CV Connected Components (Split Mask)
Splits a mask into its separate regions (cv2.connectedComponentsWithStats): one MASK per blob as a batch, plus bounding boxes. Chain into 'CV Crop by Masks' to process each region individually (e.g. schedule one inpainting per region); visualize with 'OpenCV Overlay Masks' or the core 'Draw BBoxes' node.
CV Connected Components (Split Mask)
- mask
- region_masks
- bboxes
- count
◄connectivity8►
◄min_area16►
◄max_regions64►
◄sortlargest first►
Categoryimage/CV
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | Mask to split. A batch is merged (union) before splitting. | |
| connectivity | COMBO | 8 | 8 also connects diagonal pixels; 4 only direct neighbors. |
| min_area | INT | 161–2147483647 | Regions smaller than this many pixels are dropped (removes noise specks). |
| max_regions | INT | 641–1024 | Keep at most this many regions (after sorting). |
| sort | COMBO | largest first | Order of the output region masks/boxes: by area (largest first), left-to-right, or top-to-bottom. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| region_masks | MASK | One full-size mask per region, as a MASK batch. |
| bboxes | BOUNDING_BOX | Core BOUNDING_BOX data: per-frame lists of {x, y, width, height} dicts - compatible with Draw BBoxes, Crop By Bounding Boxes, Image Crop, etc. |
| count | INT | — |