Image BBox Overlay by Mask
Turn a segmentation mask into a drawn bounding box
- image
- mask
- image
If you've ever tried to see what a mask is actually covering - or wanted a box drawn around every object your segmentation just found - you know the drill: export, open in an editor, draw rects by hand. Image BBox Overlay by Mask does it inline: give it an image and a mask, and it draws colored bounding boxes on the image based on the mask's connected regions.
It's part of ComfyUI 1hewNodes (solo dev 1hew, bilingual README, active v3.x, a personal-toolbox vibe). Nothing fancy here, just a clean visualization and QA utility.
How it works
The node finds the mask's foreground pixels and computes their bounding rectangle - or rectangles, plural. In separate mode (the default) it labels connected components of the mask and draws one box per region, which is exactly what you want when your mask has several distinct objects. In merge mode it collapses everything into a single box around the whole mask. The math uses scikit-image's connected-component labeling under the hood, so "one box per island" is genuinely per-object, not per-pixel-run.
Two drawing styles are available: fill on draws the box as a solid filled rectangle (useful for masking-out visualizations), fill off draws just the outline stroke. A padding value inflates the boxes, which is handy when you're planning a crop around each object.
The inputs that matter
- image - the IMAGE to draw on.
- mask - the MASK whose regions become boxes. This is the whole point of the node.
- bbox_color - preset names only: red, green, blue, yellow, cyan, magenta, white, black (default green).
- stroke_width - outline thickness when
fillis off (default 4). - fill - true = solid filled box, false = outline only.
- padding - how much to inflate each box beyond the mask bounds.
- output_mode -
separate(per-region) ormerge(one box).
Output is a single image with the boxes drawn in. From there it usually goes to a preview or a Save node. If your mask is bigger or smaller than the image (different resolution), the node resizes the mask to match before drawing - it won't just draw in the wrong place.
Installing it
ComfyUI Manager → search "1hew" / "ComfyUI 1hewNodes" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
First install is slow because the pack's requirements pull opencv, scikit-image, scikit-learn and detection-oriented deps (ultralytics, rembg, transformers) even though this node really needs PIL + scikit-image. No model downloads for it. The pack needs a current ComfyUI (modern node API), so update ComfyUI if it doesn't register.
Where people get burned
- Single giant box when you wanted per-object - you're on
merge. Flip toseparate. - Boxes hugging nothing - a mask that's all background (all black) produces no boxes; the node returns the image untouched. That's correct behavior, not a crash.
- Mask/image resolution mismatch - the mask gets resized to the image. A low-res mask will give you soft, slightly-off boxes; keep masks at image resolution for pixel-accurate QA.
- It draws over the image and discards the original in that region - if you need the clean original alongside, branch the input first.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| bbox_color | COMBO | green | 8 options: red, green, blue, yellow, cyan, magenta, +2 |
| stroke_width | INT | 41–100 | — |
| fill | BOOLEAN | true | — |
| padding | INT | 00–1000 | — |
| output_mode | COMBO | separate | 2 options: separate, merge |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |