Nodes/ComfyUI-ReplenishNodes/Mask Levels Adjust
ComfyUI Node

Mask Levels Adjust

Photoshop-style levels, applied to a mask

By hben35096·Created 2 years ago·Updated 12 months ago· 7
Mask Levels Adjust
  • masks
  • masks
output_black_point0
output_white_point255

If you've used the Levels tool in Photoshop or GIMP, this is that exact idea applied to a ComfyUI mask instead of an image: you set a black point and a white point, and everything in the mask gets remapped between them. It's a small, sharp tool for cleaning up masks that are too soft, too faint, or not fully committing to black or white where they should.

Why a mask needs "levels" at all

Masks coming out of segmentation models, SAM-style detectors, or hand-painted alpha layers are often not clean 0-or-1 values - they can carry soft, gray, in-between pixels at the edges, or the "on" regions might not actually hit full white. That matters more than it sounds like it should: inpainting workflows lean on the mask being a genuinely reliable boundary between "regenerate this" and "leave this alone" - the whole value of masked inpainting is bit-identical unmasked pixels and full-resolution detail exactly where you asked for it, and a mushy, low-contrast mask undermines both. A mask that's technically "on" at only 60% opacity in its supposed core region will bleed the effect weaker than intended; a mask with soft, wide-gray edges will blur the boundary between what gets regenerated and what doesn't, in ways that are hard to diagnose after the fact.

Levels adjustment fixes exactly that failure mode. Push the black point up and everything below it clips to fully off; pull the white point down and everything above it clips to fully on. Between those two points, values scale linearly. The practical effect on a mask: tighten a fuzzy, gray edge into something closer to a hard boundary, or rescue a mask whose "active" region never quite reached full white.

(If what you're actually after is a segmentation mask in the first place rather than cleanup of one you already have, note that this pack's README says its earlier CLIPSeg-to-mask node was removed - the author points people to WAS Node Suite's CLIPSeg Masking node as the replacement for that specific job.)

Inputs and outputs that matter

  • masks (required) - the mask (or batch of masks) to adjust.
  • output_black_point (required, integer, 0–255, default 0) - any mask value at or below this gets remapped to fully off (0). Raise this to tighten a soft, low-value edge into a hard cutoff.
  • output_white_point (required, integer, 0–255, default 255) - any mask value at or above this gets remapped to fully on (255). Lower this if your mask's "active" region never quite reaches full white and you want it to.

The output is a single masks (MASK) - the remapped result, ready to feed into a VAE Encode (for Inpainting), a composite node, or anywhere else a mask is expected.

Installing it

ComfyUI Manager: search ComfyUI-ReplenishNodes, install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/hben35096/ComfyUI-ReplenishNodes

No model downloads or extra dependencies documented for this node.

Where people get tripped up

Setting black and white points too close together, or crossing them. Push the black point too high relative to the white point and you'll flatten most of the mask's gradient into a stark on/off boundary - sometimes exactly what you want, sometimes a loss of the soft edge that was helping your inpaint blend naturally. If your composite result develops a visible hard seam after adding this node, back the black/white points off toward their defaults and reintroduce the adjustment more gently.

Forgetting this doesn't blur or feather anything. This node only remaps existing values between two points - it doesn't soften or expand a mask's edges. If what you actually need is a softer transition rather than a harder one, you want a blur or feather step instead; this node moves in the opposite direction, toward more contrast, not less.

CategoryReplenish/Masks

Inputs (3)

NameTypeDefaultDescription
masksMASK
output_black_pointINT00–255
output_white_pointINT2550–255

Outputs (1)

NameTypeDescription
masksMASK