Nodes/ComfyUI-Beyond_nodes/Round Mask 🦾
ComfyUI Node

Round Mask 🦾

The binarizer that fixes fuzzy alpha channels

By beyondprompting·Created 9 months ago·Updated 7 months ago· 0
Round Mask 🦾
  • mask
  • MASK

Masks from SAM, Florence2, rembg, or any soft matting tool come back as floating-point alpha. That means gradients, feathered edges, and faint gray spill around your subject. Sometimes that's exactly what you want. And sometimes a downstream node wants a hard, crisp binary mask - every pixel either 0 or 1 - and the fuzzy stuff makes it behave badly. Round Mask is a one-click binarizer for exactly that situation.

How it works

One input (mask), one output (MASK), and the entire mechanism is a single torch operation: mask.round(). Every value at or above 0.5 becomes 1, everything below becomes 0. Because it rounds the whole tensor at once, a whole batch of masks gets binarized in one pass - no looping over frames, no per-mask fussing.

That's genuinely all there is to it, which is the correct size for the problem.

When you'd reach for it

Inpainting, cropping, and compositing workflows are where this matters. The KB's concepts essay lays out the two inpainting approaches - and if you're doing the "regular model inpainting" route or feeding a mask into a crop-and-stitch chain, a soft mask with faint gray noise makes bounding boxes balloon out to include the noise. Round the mask first and the box hugs the actual subject. Same story for mask-to-image conversion or anything that treats alpha as a hard selection.

It's also the cleanup step after a weak matting pass. If rembg left a haze around the subject, rounding strips it to a clean silhouette. That's the sweet spot: hard-edged subjects, clean backgrounds, binary logic.

The catch

It's a fixed 0.5 threshold with no slider. If you need adjustable thresholding - "keep only pixels above 0.8" - look at a proper threshold mask node (the WAS Node Suite has one) instead. And the bigger trap: rounding destroys feathering. If your subject has soft hair, wisps of smoke, or anything with genuinely soft edges, rounding gives you a hard, jagged silhouette and it'll look cut out. Keep the soft mask for compositing where you want anti-aliased edges; reach for Round Mask where you want a hard selection. Know which you're in before you use it.

Installation

It ships in the Beyond Nodes pack:

  • ComfyUI Manager - search "ComfyUI-Beyond_nodes" (or "Beyond Nodes"), install.
  • Or manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/beyondprompting/ComfyUI-Beyond_nodes
    
    Restart after. No requirements.txt, no model files - torch and PIL, which ComfyUI already loads.

Common issues

  • Hard, jagged edges on your composite. That's this node doing exactly what it promises. If your subject has soft edges, don't round its mask.
  • Mask comes out all black or all white. Rounding can't fix a broken or near-zero-gradient source mask - garbage in, binarized garbage out. Check what you're feeding in.
  • No troubleshooting threads exist for this one. The pack is tiny and nearly invisible in the wild (essentially zero search impressions). Round Mask is simple enough that you don't need them, but know there's no community FAQ to fall back on if something does surprise you.

It's a two-pixel-deep node in a grab-bag pack, but "threshold my mask at 0.5 with zero configuration" is a surprisingly common need. When that's the need, this is the fastest way to satisfy it.

CategoryBeyond nodes/masking

Inputs (1)

NameTypeDefaultDescription
maskMASK

Outputs (1)

NameTypeDescription
MASKMASK