Nodes/comfyui_imgutils/Imgutils BBox Segmenter
ComfyUI Node

Imgutils BBox Segmenter

Cut one subject out of a crowd, automatically

By LK-168·Created about a year ago·Updated about a year ago· 1
Imgutils BBox Segmenter
  • image
  • bbox_mask
  • segmented_image_with_bbox
  • segment_mask_from_bbox
segment_mode
scale1024

When auto-segmentation isn't enough

Imgutils Auto Segmenter does one thing: subject out, background gone. But "the subject" isn't always what you want - in a group shot, the whole crowd is the subject, and you wanted the girl on the left. That's the gap Imgutils BBox Segmenter fills. Give it a mask that marks a region of interest (a bounding-box mask), and it cuts out the main subject inside that region only, then crops the result down to the box. It's the "one character from the middle of a scene" node.

How it works

The mechanism is a clever bit of mask math rather than a second model. It runs the same ISNet foreground/background segmentation over the whole image, binarizes that mask, then multiplies it by your bbox_mask. The intersection is the subject-shaped region inside your box. It then:

  • composites that region onto the chosen background (rgba_transparent, rgb_white_bg, rgb_black_bg), and
  • crops both the image and the mask to the box's bounds.

So you get a clean, tightly-cropped cutout of just what was in the box. Note the output naming tells you what changed: segmented_image_with_bbox (cropped) and segment_mask_from_bbox (also cropped to the box).

Inputs that matter

  • image and segment_mode / scale - same trio as Auto Segmenter.
  • bbox_mask - the interesting one. It's a MASK, not a raw box, so you can feed it the detection_mask output of Imgutils Generic Detector (filled rectangles - perfect), or BBox to Mask, or even a hand-drawn mask. Anything that marks the region works; the segmenter will respect its shape.

Install

Part of LK-168/comfyui_imgutils. ComfyUI Manager → search "comfyui_imgutils", or:

cd ComfyUI/custom_nodes
git clone https://github.com/LK-168/comfyui_imgutils

Restart ComfyUI. It uses the same auto-downloading ISNet model as Auto Segmenter - first run pulls it into $HF_HOME, so set that env var per the README (run_nvidia_gpu.bat on official Windows builds; the Aki package is already fine).

Gotchas

  • Empty bbox_mask → the node returns the original image and an empty mask with a warning. If your detector found nothing, the whole pipeline silently produces nothing useful.
  • The crop is hard. Output is cropped to the box exactly, so edges of the subject at the box boundary get sliced. Give the region some breathing room (expand the box) if you see cut-off hair or shoulders.
  • Foreground-only. Like its sibling, it's a binary segmenter - it can't pick "this person, not the person behind them" inside the box. If they overlap too much, the intersection includes both.

If you've got the detector wired up anyway, this node turns "detect all characters" into "cleanly extract character #3" with two wires. That's a surprisingly rare capability to find in a one-node package.

Categoryimgutils/segmentation

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
bbox_maskMASK
segment_modeCOMBO3 options: rgba_transparent, rgb_white_bg, rgb_black_bg
scaleINT1024128–2048

Outputs (2)

NameTypeDescription
segmented_image_with_bboxIMAGE
segment_mask_from_bboxMASK