ComfyUI Node

DP Mask Settings

Grow, shrink, and feather a mask in one node

By DesertPixelAi·Created 2 years ago·Updated about a year ago· 25
DP Mask Settings
  • mask
  • image_input
  • mask
  • image
expand0
blur0

Any time you're doing something mask-based - inpainting, compositing a cutout, feeding a region into conditioning - you end up needing the same two adjustments over and over: nudge the mask edge in or out, and soften it so the seam doesn't look like it was cut with scissors. DP Mask Settings is that pair of dials in one node, instead of you hunting down a grow node and a blur node and wiring them in sequence every single time.

How it works

Nothing exotic here, which is exactly the point. Expand grows or shrinks the mask boundary - positive values push the edge outward so the mask covers more, negative values pull it inward. Blur softens that edge afterward, turning a hard binary line into a gradient. This is the same grow-then-feather sequence you'd build by hand with two separate utility nodes, just collapsed into one.

Why both matter together: a mask straight off a segmentation tool or a hand-painted region is usually too tight and too hard-edged to composite or inpaint cleanly. Growing it a little gives the generation room to blend past the exact boundary you drew, and feathering the result is what actually hides the seam - the standard advice for mask blur is 4-12px for most work; too little and you get a visible ring, too much and the effect bleeds into pixels you didn't mean to touch.

Inputs and outputs

Required, both integers with straightforward ranges:

  • expand (-256 to 256, default 0) - grow (positive) or shrink (negative) the mask.
  • blur (0 to 256, default 0) - feather the edge after expanding.

Optional inputs let you feed in a mask and, if you have one, an image_input - the image just rides along and comes back out unchanged, so you don't need a separate reroute to keep the mask and its source image traveling together through the rest of the graph. Outputs are the adjusted mask and the passthrough image.

Installing it

Through ComfyUI Manager: search ComfyUI-Desert-Pixel-Nodes (or "Desert Pixel"), install, restart. By hand:

cd ComfyUI/custom_nodes
git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes

Restart ComfyUI. The pack is pure Python logic - no model downloads, nothing to fetch on first run - so once it imports, every node in it including this one is ready. It's a big pack (100+ nodes), and everything lands under the DP category, so search "DP Mask" if the node browser feels crowded.

Where people get tripped up

Nothing about this node itself is fragile - it's a thin wrapper over grow/blur math. The mistakes happen upstream and downstream of it:

  • Expanding too aggressively before inpainting. A big positive expand value looks harmless until you notice the generation is now regenerating clean background pixels well outside the region you actually wanted changed. Start small (8-16px) and increase only if you still see a seam.
  • Blurring instead of expanding to fix a too-tight mask. Feathering doesn't grow the editable region, it just softens the transition at whatever boundary you already have - if the mask itself needs to cover more, that's expand's job, not blur's.
  • Forgetting the image passthrough is optional. If you don't wire anything into image_input, you simply won't get an image out - that's expected, not a bug; the node still returns a valid mask either way.

If the whole pack fails to show up after install, that's a pack-level import issue rather than anything specific to this node - check the ComfyUI console on startup for a Python traceback naming Desert Pixel, which usually points at a missing dependency rather than this node's own (dependency-free) logic.

CategoryDP/mask

Inputs (4)

NameTypeDefaultDescription
expandINT0-256–256
blurINT00–256
maskoptMASK
image_inputoptIMAGE

Outputs (2)

NameTypeDescription
maskMASK
imageIMAGE