ComfyUI Node

Mask Stroke

Feather, expand, and soften masks until your seams disappear

By supElement·Created 9 months ago·Updated about 11 hours ago· 10
Mask Stroke
  • mask
  • MASK
stroke_in5
stroke_out5
blur_in2.0
blur_out2.0
backToWhite0.000
invert_maskfalse

Mask Stroke is a mask-editing utility with a deceptively simple job: it adds a stroke around your mask's edges and lets you blur the inside and outside edges independently. That sounds small, but soft edges are the difference between a mask that works and a mask that leaves a visible seam. Inpainting masks with hard edges produce hard boundaries; stroke-and-blur gives you the graduated falloff that actually blends.

How it works

Feed it a mask and you get a new MASK out. The controls are all about the edge treatment:

  • stroke_in (0–500, default 5) and stroke_out (0–500, default 5) - how far the stroke extends into the masked area and outside it. Want the mask to reach slightly past the object so no edge shows? Crank stroke_out. Want to keep the edit tightly inside the region? stroke_in does the opposite.
  • blur_in and blur_out (0–100, default 2) - independent feathering on each side. Different blur on each side is the trick for asymmetric edges, like a mask that should be soft where it meets the background but crisp where it meets a hard object.
  • backToWhite (0–1, default 0) - this is the interesting one. It adds weight to the non-stroked area, so the output mask has no region at weight 0. That's the difference between a mask that's "everything except the stroke" and one that's uniformly usable. When you don't want any fully-black (zero-weight) zone in the output, raise this.
  • invert_mask - flip the mask before processing, so you can stroke the inverse region without an extra invert node.

When you'd use it

This is a "make the mask behave" node - the kind you slot in after a segmentation mask or a hand-drawn mask and before anything that consumes it (inpaint conditioning, ControlNet, compositing). The classic move is stroke_out a few pixels plus a modest blur_out: the edit region now overlaps the source slightly and feathers out, so the boundary between regenerated and original pixels isn't a hard line. And if you're chaining to another mask tool that chokes on zero-weight regions, backToWhite is your fix.

Installing it

It's part of supElement/ComfyUI_Element_easy:

cd ComfyUI/custom_nodes
git clone https://github.com/supElement/ComfyUI_Element_easy.git

Restart ComfyUI, or install via ComfyUI Manager by searching ComfyUI_Element_easy.

Gotchas

The classic beginner move is to set stroke_in and stroke_out but forget the blurs, then wonder why the mask still has a hard edge - the stroke widens the mask, the blurs are what actually soften it. Also, remember backToWhite defaults to 0, so the output mask does contain zero-weight regions unless you raise it; if a downstream node seems to ignore parts of your mask, check that first.

CategoryElement_easy/image

Inputs (7)

NameTypeDefaultDescription
maskMASK
stroke_inINT50–500
stroke_outINT50–500
blur_inFLOAT2.00–100
blur_outFLOAT2.00–100
backToWhiteFLOAT0.0000–1
invert_maskBOOLEANfalse

Outputs (1)

NameTypeDescription
MASKMASK