Mask Attributes
Brightness, contrast, threshold, and smoothing for masks
- mask
- mask
The tone controls for masks
Most mask problems are value problems: the mask is too faint, too harsh, too noisy, or backwards. Mask Attributes is a set of image-editing tone controls applied to a mask - brightness, contrast, smoothing, binarization, inversion - all in one node with sensible defaults of "do nothing." It's the node you wire after a detector or SAM when the mask needs a quick personality adjustment rather than a rebuild.
How it works
A mask is just a grayscale image, so the operations are the standard ones, applied in a fixed order:
brightness(−1 to 1) - added to every pixel, clamped to [0,1]. Positive lifts, negative darkens.contrast(0.1 to 3) - scales values around the 0.5 midpoint. Above 1 pushes everything toward pure black or pure white; below 1 flattens.smooth_radius(0–20) - Gaussian blur for feathering. The sigma isradius / 3, so a radius of 3 is a gentle 1-pixel-ish blur and 9 is noticeable.binarize+threshold(default 0.5) - snap every pixel to 0 or 1 at the threshold. On = binary mask, off = soft.invert- flip it: 1−mask.
The two you'll actually use
binarize+threshold- the "make this a clean binary mask" move. SAM and detector masks come out with soft gray edges; for a lot of downstream nodes a hard 0/1 mask behaves far more predictably. Set the threshold where the gray fades to background.smooth_radius- the reverse: take a crunchy binary mask and soften it into something an inpaint node blends nicely.
contrast is the middle ground - crank it to 1.5–2.0 to firm up a wishy-washy mask without going fully binary. Output is a single mask socket, same size and batch as the input.
Install
Part of LK-168/comfyui_imgutils. ComfyUI Manager → search "comfyui_imgutils", or:
cd ComfyUI/custom_nodes
git clone https://github.com/LK-168/comfyui_imgutils
Restart ComfyUI. Pure numpy/PIL math - no models, no downloads. (One tiny README detail: the author's own feature list says "binarize" twice in the attribute list. It's a copy-paste wobble, not a hidden feature.)
Common issues
- Mask vanished / became solid.
thresholdis set wrong for your mask's value distribution - check the range with Mask Info first, then pick the threshold. A mask with soft 0.2–0.4 values binarized at 0.5 disappears entirely. - "Smoothing did nothing." With
smooth_radiusat 1 the sigma is 0.33 - invisible. Go to 5+. - Everything backwards. That's what
invertis for; people forget it exists and redo whole pipelines instead of flipping one toggle.
It's a utility node, unglamorous, and it quietly solves the mask-quality problems that make everything downstream worse.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| thresholdopt | FLOAT | 0.500–1 | Threshold for binarization |
| smooth_radiusopt | FLOAT | 0.00–20 | Gaussian blur radius for smoothing |
| contrastopt | FLOAT | 1.00.1–3 | Adjust mask contrast |
| brightnessopt | FLOAT | 0.00-1–1 | Adjust mask brightness |
| invertopt | BOOLEAN | false | Invert mask |
| binarizeopt | BOOLEAN | false | Convert to binary mask |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |