Remap Mask Range
Stretching or squashing a mask's intensity
- mask
- mask
A mask that only ever reaches 0.6 grey instead of full white will make every downstream effect that reads it weaker than you intended - an inpaint that doesn't fully commit, an IPAdapter weight map that never hits full strength, a blend that always looks partial. Remap Mask Range fixes that by rescaling a mask's values to whatever min and max you actually want.
Why you'd want this
Masks coming out of detectors, blurred edges, or other generated sources frequently don't span the full 0–1 range you'd expect. Maybe a segmentation model's confidence never quite reaches 1.0 in the areas you care about, or a soft-edged mask you built has a lot of its content bunched in the 0.2–0.7 band instead of using the whole scale. This node stretches (or compresses) whatever range your mask currently occupies into a new target range, so you can push weak masks to full strength, soften an already-strong mask for gentler blending, or generally correct for a source that doesn't output the range you need.
It's a small node, but it's the kind of thing worth reaching for before you start second-guessing your actual effect strength settings elsewhere in the graph - if a mask-driven effect looks too weak or too strong, check whether the mask itself is using the range you assume it is before tweaking anything downstream.
How it works
It takes your mask's values and linearly remaps them so that whatever the new floor and ceiling are, the mask's content is stretched or compressed to fit between them - the same idea as a levels adjustment in image editing, applied to a mask channel instead of an image.
The inputs and outputs that matter
mask- the mask to remap.min(default 0, range -10 to 1) - the new floor. Note this can go negative, which is worth knowing if you're feeding the result somewhere that expects a strictly 0–1 mask - negative values there could behave unexpectedly downstream.max(default 1, range 0 to 10) - the new ceiling.
One output: mask, remapped.
How to install it
- ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, thenpip install -r ComfyUI-KJNodes/requirements.txt(portable:python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-KJNodes\requirements.txt), then restart.
No models involved - this is a pure numerical operation on tensor values.
Common issues & troubleshooting
Effect still looks too weak after remapping. Double-check you actually raised max toward 1 (or beyond, if your downstream node tolerates it) - it's easy to leave max at its default of 1 and change only min, which won't help if the problem was the ceiling, not the floor.
Values outside 0–1 cause weirdness downstream. If you set min below 0 or max above 1, you're producing a mask outside the normal 0–1 range. Some nodes clamp automatically, some don't - if something downstream starts behaving oddly after adding this node, that's the first thing to check.
Mask looks inverted or wrong after remapping. This node stretches the range, it doesn't invert anything - if min ends up numerically larger than max, the mapping direction flips, which can look like an accidental invert. Keep min less than max unless you're deliberately going for that.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| min | FLOAT | 0.00-10–1 | — |
| max | FLOAT | 1.000–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |