BinaryImageMask
Turn any image into a clean black-and-white mask
- image
- image
- mask
The name is the whole description: give this node an image and it hands back a strict black-and-white mask. No edge-feathering sliders, no API, no models to download. If you've got a grayscale map, a cutout's alpha, or a rendered depth pass and you need it as a hard mask with a clean boundary, this is a one-node way to get there.
Most mask workflows want hard edges somewhere. Inpainting needs to know exactly which pixels are "regenerate this" and which are "leave alone"; ControlNet conditioning wants a crisp structure map rather than a fuzzy smear of grays. Core ComfyUI can threshold too, but it's a chain of conversions and comparisons - this wraps the whole thing into one node with one knob.
How it works
It's dead simple under the hood. The image gets converted to grayscale, then every pixel whose luminance is above your threshold is pushed to pure white and everything else to pure black. That's the whole trick: a single point() pass with the threshold, then the result is exposed as a MASK. No heavy lifting, which is why it has no dependencies beyond what ComfyUI already ships.
The inputs that matter
There are exactly two, and you'll realistically touch only one:
image- any IMAGE. Works best on something that already reads as a map: a depth render, a segmentation output, a plain-color cutout, or a hand-drawn mask that got exported with soft edges.threshold(default 0.5, range 0.1–1.0) - the cutoff on brightness. It's normalized to a 0–1 scale internally (mapped to 0–255), so 0.5 means "anything brighter than 50% luminance becomes white." Crank it up if your mask comes out too noisy; drop it if the boundary is eating areas you wanted.
Outputs
image- your original image, passed through untouched. Handy if you want the same image flowing down a second branch without a Reroute node.mask- the binary mask. Wire it into anything that takes a MASK: a Set Mask node feeding an inpaint, a mask-based ControlNet workflow, or Mask to Image if you want to eyeball it as a picture.
One behavior worth knowing: this node deliberately never caches - it reports a change on every run, so anything downstream re-executes each time. That's by design, and it only matters if you were hoping it'd sit quietly while the rest of the graph changed.
Installing
This ships in ComfyUI-TrollSuite by Øyvind (oyvindg on GitHub), a small five-node utility pack. Install it like any custom node:
- Easiest: ComfyUI Manager → search "ComfyUI-TrollSuite" → Install → restart.
- Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/oyvindg/ComfyUI-TrollSuite
then restart ComfyUI. It shows up under the TrollSuite/mask submenu. No checkpoints, no model files, no declared dependencies - the pack needs only what a stock ComfyUI already has.
Where it bites
The catch is in the word "binary": every shade of gray either becomes white or black, with no in-between built in. If your source has anti-aliased or soft edges, you'll get jagged boundaries and hard stair-steps. Fix that downstream with a core Mask Blur node (radius 2–4 usually hides the worst), or upstream by raising the threshold so only confident pixels survive. And remember it's luminance-based - two different colors with the same brightness both pass or both fail, so this isn't a color-selection tool.
When you need a softer or more controllable mask, SAM (Impact Pack's segment-anything nodes) is the heavy-duty route. But when you just need "this grayscale thing, as a clean mask," BinaryImageMask is the quick, predictable answer.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| threshold | FLOAT | 0.50.1–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |