ComfyUI Node
CV Masks to BBoxes
One tight bounding box per mask of a MASK batch - the generic bridge from region masks (Connected Components, Labels to Masks, Region Properties + the K-Means Mask Clusters blueprint, Seg Masks, GrabCut) to anything that consumes BOUNDING_BOX: 'OpenCV Crop by BBoxes', 'CV Snap BBoxes', the core 'Draw BBoxes' / 'Crop By Bounding Boxes'. Empty masks are dropped by default; 'valid' says which input rows survived, so the boxes can be realigned with the batch. Empty input yields empty outputs and never raises.
CV Masks to BBoxes
- masks
- bboxes
- areas
- valid
- count
◄threshold0.50►
◄drop_emptytrue►
Categoryimage/CV
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | One mask per region (MASK batch). A single mask yields a single box around ALL of its white pixels - split it with 'CV Connected Components' first if you want one box per blob. | |
| thresholdopt | FLOAT | 0.500–1 | Mask values above this count as inside the region. Raise it to ignore a soft/feathered halo. |
| drop_emptyopt | BOOLEAN | true | Skip masks with no pixels above the threshold. Turn off to keep the batch rows aligned one-to-one - empty masks then emit a zero-size box at the origin. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| 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. |
| areas | NPARRAY | (B,) int32: the pixel count of each region, in the same order as the boxes. |
| valid | NPARRAY | (N,) bool, one entry per INPUT mask: True where a box was emitted. Use it to realign the boxes with the original batch when drop_empty is on. |
| count | INT | Number of boxes emitted. |