ThresholdMask_motorway_edition
Turn a soft mask into a hard cut
- MOTORWAY ππ¨
- MOTORWAY ππ¨
Mask math in ComfyUI is full of gradients - blur a mask and suddenly your "select the person" mask has a soft gray edge that decides mid-values. ThresholdMask is the node that puts its foot down: anything at or above your threshold becomes full white, anything below becomes full black. No in-between. This is the Motorway edition, so the mask comes out of the pipe by key and the binarized result goes back in.
When do you actually want that? Whenever a downstream step needs a definite yes/no rather than a "mostly." Inpainting regions where a soft edge would mean "regenerate half of this pixel," masking operations that composite onto a background, or cleaning up a depth or alpha map before it gets fed to a ControlNet preprocessor. It's a blunt instrument - you're throwing away all the gray information - but that's exactly the point. Used after a blur, ThresholdMask is how you get a clean hard-edged mask from something messy.
What to set
INPUT_mask_key(defaultmask) - the Motorway key holding the MASK you want to binarize.value(default0.5, 0β1) - the cut point. Pixels at or above this become 1 (white), below become 0 (black). Move it up to keep only the strongest parts of the mask.OUTPUT_MASK_key(defaultMASK) - where the thresholded mask is written.
Output is the MOTORWAY with the hard-edged MASK stored under the output key.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway
Restart; it's under agilly1989 Nodes β Motorway-ed β mask. ComfyUI Manager has the pack. No pip dependencies.
Where people get burned
The value threshold interacts with everything upstream. Blur a mask, then threshold at 0.5, and you've silently shrunk the region because the blur spread the intensity. If your inpainted area comes out smaller than your original selection, the threshold isn't wrong - it's doing its job, and you need to re-blur with a lower threshold or adjust.
And the Motorway standard: keys are case-sensitive and exact; 'MotorwayClass' object has no attribute 'hash_' means the key in INPUT_mask_key isn't in the pipe - check the spelling on the node that wrote mask. Finally, the pack is beta and the auto-cloned motorway-ed nodes have been enabled and disabled across releases. If an update makes the node vanish from the menu, that's the pack changing, not a broken install.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| MOTORWAY ππ¨ | MOTORWAY ππ¨ | β | |
| INPUT_mask_key | STRING | mask | β |
| value | FLOAT | 0.500β1 | β |
| OUTPUT_MASK_key | STRING | MASK | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MOTORWAY ππ¨ | MOTORWAY ππ¨ | β |