Nodes/RES4LYF/MaskEdge
ComfyUI Node Runs on cloud

MaskEdge

Extract just the boundary of a mask, for feathering hard region edges

By ClownsharkBatwing·Created 2 years ago·Updated 17 days ago· 1,222
MaskEdge
  • mask
  • edge_mask
dilation20
modepercent
internal1.00
external1.00

If you're building masks for RES4LYF's regional conditioning by painting flat, hard-edged color zones (the "traditional rigid" method the README describes, feeding into Masks-From-Color-Swatches), you inherit a real problem: a mask with a razor-sharp boundary produces a visible seam where one region's conditioning stops and the next one's starts. MaskEdge exists to fix that. It doesn't dilate or shrink your whole mask - it isolates just the boundary band around it, which you can then use to blend adjacent zones instead of leaving a hard cut between them.

How it works

Feed it a mask, and it computes a band around that mask's edge, with internal and external scaling how far that band extends inward and outward from the boundary independently - useful if you want, say, a wide feather going outward into the next region but a tight one staying inside your own. dilation sets the overall size of that band, interpreted either as a percentage of the mask (mode: percent) or as an absolute value (mode: absolute).

The inputs and outputs that matter

  • mask (required) - the source mask you're extracting an edge from.
  • dilation (default 20) - how wide the extracted edge band is.
  • mode (percent or absolute, default percent) - whether dilation scales with the mask's size or is a fixed value.
  • internal / external (both default 1) - separate multipliers for how far the edge band reaches inward versus outward from the boundary.
  • Output: edge_mask - a new mask covering just the boundary region, ready to use for feathering or blending between zones.

How to install it

Via ComfyUI Manager: search "RES4LYF" and install. Manually, from ComfyUI/custom_nodes:

git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt

Activate your venv first if you use one; on portable installs, use python_embedded\Scripts\pip.exe in place of pip. Restart ComfyUI once installed.

Common issues & troubleshooting

The edge band is barely visible, or covers almost the whole mask. That's dilation (and mode) doing exactly what they're set to - in percent mode, a small mask with a large dilation value can produce an edge band that eats most of the shape. Switch to absolute mode if you want a fixed pixel-scale band regardless of how big or small your source mask is.

Seams are still visible after feathering with the edge mask. Check that internal and external are both wide enough to actually overlap with the neighboring region's mask - if the edge band only extends a sliver in either direction, there's not enough overlap for a soft blend to hide the transition.

You extracted an edge from a mask that was already soft, not hard. MaskEdge is built for the problem hard, rigid masks create; on a mask that already has soft, feathered edges (from Mask-Sketch, for instance) it's less likely to be the tool you need - a soft mask doesn't have a sharp seam to fix in the first place.

You want a solid, non-feathered mask instead. If a downstream node needs a strict on/off selection rather than a blend zone, look at MaskFloatToBoolean instead - it converts a soft mask into a hard binary one, the opposite direction from what this node does.

CategoryRES4LYF/masks

Inputs (5)

NameTypeDefaultDescription
dilationINT20-10000–10000
modeCOMBOpercent2 options: percent, absolute
internalFLOAT1.00-1–10000
externalFLOAT1.00-1–10000
maskMASK

Outputs (1)

NameTypeDescription
edge_maskMASK