Nodes/ComfyUI-My-Mask/Mask To Botton Half Convex Mask
ComfyUI Node

Mask To Botton Half Convex Mask

Fill a Mask's Lower Concavities, Leave the Top Alone

By jerrylongyan·Created 2 years ago·Updated 2 years ago· 4
Mask To Botton Half Convex Mask
  • mask
  • MASK

Second node in the same tiny two-node pack, same idea with a leash on it. MaskToBottonHalfConvexMask (yes, "Botton" - that's the author's spelling, and the class name carries it too, so search for it that way) does the convex-hull fill trick only on the lower half of the frame and returns the top half of your mask completely untouched.

When to reach for it

When is that what you want? When the top of your mask holds detail you'd rather not flatten and the bottom is a mess. Classic case: a person mask where the head and shoulders are clean but the lower body has gaps between legs and coat. Or a product shot where you want the top preserved exactly and the bottom turned into a solid pedestal for compositing. The whole point of convex-filling is that mask-based inpainting still owns bit-identical compositing, and it behaves better when it isn't handed a mask with concave pockets to fill on its own. This node just narrows that cleanup to the part of the frame that needs it.

How it works

Mechanically it's the sibling's code with a slice. The mask is split at height // 2 of the canvas, and only the bottom half goes through the contour → convex hull → polygon fill pipeline. The filled result is written back into a copy of the original, so the top half comes back byte-for-byte what you fed in. Two details worth knowing: if there are no white pixels in the bottom half at all, the node just hands your mask back unchanged - no crash, no empty output. And the hull is computed within the bottom crop, so the fill can bridge bottom-half regions together but never paints above the midline.

The inputs and outputs

Inputs and outputs are as simple as it gets. One required input, mask (MASK), from any mask-source node - SAM, GroundingDINO, a hand-painted mask, whatever you already have. One output, MASK, the same dimensions as the input, wired straight into whatever consumes masks: mask blur/feather, InpaintModelConditioning, ImageCompositeMasked, or the inpaint VAE encode.

Installing it

Install is identical to its sibling because they ship in the same repo. ComfyUI Manager → search "ComfyUI-My-Mask" → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/jerrylongyan/ComfyUI-My-Mask

Restart after. Dependencies are numpy, opencv-python, and torch - Manager grabs opencv-python if it's missing. No models to download, nothing to configure.

Where people get burned

The traps are the sibling's traps plus one of its own:

  • "Bottom half" means the bottom half of the canvas, not the bottom half of your subject. The split is at height // 2 of the mask tensor, which is the image height. If your subject sits high in the frame, the lower half may contain nothing and the node returns your mask unchanged. Pad or crop so the mask canvas actually covers what you want convexified.
  • Same single-frame, CPU-only rule as the sibling. squeeze(0).numpy() - one mask at a time, no batches, and the mask has to be on CPU (which is where ComfyUI masks normally live).
  • The output is hard-edged. It fills at a flat 1.0, so any feather in the bottom half is gone. Blur after this node, not before.

That's the whole review: if you only ever need to convexify a whole mask, get the sibling MaskToConvexMask; if you want to preserve the top of a shape while solidifying the lower half for an inpaint, this is the one. It isn't glamorous, but it's the kind of fiddly little geometry fix that turns a leaky inpaint into a clean one.

CategoryMaskToBottonHalfConvexMask

Inputs (1)

NameTypeDefaultDescription
maskMASK

Outputs (1)

NameTypeDescription
MASKMASK