BBox Lower Mask 2
The mask for 'everything below the box' — BBox Lower Mask 2
- bbox
- mask
The name says "lower," but the trick is it'll slice along any edge of a bounding box. BBox Lower Mask 2 is a tiny utility that turns one side of a detected box into a hard cut line and outputs a binary mask: black on one side of the line, white on the other. No models, no downloads, no dependencies beyond what ComfyUI already ships - it's about a page of numpy. Obscure, sure. Also the fastest way I know to build a "keep everything above this person's feet" mask without painting a single pixel.
What it's actually for
This node lives at the boundary between detection and inpainting. The modern "ground-then-mask" pattern - point a VLM or detector at an image, get a box around the object, turn that box into a mask, inpaint - almost always wants the object's rectangle. But sometimes you want the opposite of a rectangle: everything on one side of the object. Classic case: you detected a person standing on a floor, and you want to regenerate the floor and shadow below them without touching the person. Grab their box, pick y2 (their feet), and everything below the feet goes black. Swap in the sky, clean up a shadow, replace a tabletop that a cup-detector found - same move, different edge.
Masked inpainting is the one place that still beats instruction-editing models (bit-identical unmasked pixels, full-resolution detail in the masked region), and this node is a cheap way to build the mask without hand-painting.
How it works
Feed it a bounding box as four numbers - [x1, y1, x2, y2] - and the boundary enum decides which of those four becomes the cut line:
x1- everything left of the box's left edge goes blacky1- everything above the top edge goes blackx2- everything right of the right edge goes blacky2- everything below the bottom edge goes black (the default, and why it's called "lower")
offset pushes the line: positive values eat more of the image, negative keep more - handy when the grounding box wraps the cup and not the saucer, which is exactly the "boxes come out tighter than you expect" trap the inpainting crowd warns about. Internally the floats get truncated to ints and the line is a razor-sharp threshold, so sub-pixel precision isn't a thing here. The output is a standard MASK tensor (1×H×W, float32) that plugs into anything mask-shaped: Set Latent Noise Mask, ConditioningSetMask, or a blur node if you want soft edges.
Inputs that matter
Most of the five inputs are self-explanatory, and two are where people stumble:
image_width/image_height- the size of the generated mask. Match these to your actual image. The default is 512×512, so a mask dropped onto an SDXL 1024×1024 image will be half-size and misaligned.bbox- the four numbers. Here's the gotcha: it's a plainLIST, not Impact Pack'sBBOXtype, so you can't wire an Impact detector straight into it. You type the numbers in, or feed it a list from a node that outputs one.boundaryandoffset- the cut edge and the nudge. That's the whole show.
Installing it
Painless, which is the point of this pack. ComfyUI Manager → search "BBoxLowerMask2" → install, or from a terminal:
cd ComfyUI/custom_nodes
git clone https://github.com/jqy-yo/Comfyui-BBoxLowerMask2
Restart ComfyUI. That's it - no requirements.txt, no model files, nothing heavy to babysit.
Where it bites
- Hard edges. The cut is one pixel thick. If you're inpainting, run the mask through a blur (4–12px is the usual range) or you'll see a seam.
- Wrong dimensions. Forgetting to set width/height to match the image is the number one "why is this misaligned" cause.
- Type mismatch. Remember the
bboxinput takes a plain list, so Impact Pack'sBBOXoutput won't plug in - copy the numbers or convert. - All black or all white. Push the offset past the image edge and numpy quietly clamps; nothing crashes, you just get a useless mask.
It's a one-trick node, but it's a clean trick: when you need a half-plane cut anchored to a detected object, nothing else in core ComfyUI does it in one step.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image_width | INT | 5121–8192 | — |
| image_height | INT | 5121–8192 | — |
| bbox | LIST | 439.81,252.41,503.29,337.41 | — |
| boundary | COMBO | y2 | 4 options: x1, y1, x2, y2 |
| offset | INT | 0-1024–1024 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |