Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Mask Expand XY
ComfyUI Node

EmAySee Mask Expand XY

Grow a mask, X and Y separately — expand-only edition

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Mask Expand XY
  • mask
  • MASK
expand_x0
expand_y0

The simpler half of the expand/shrink pair

EmAySee_MaskExpandXY is EmAySee_MaskExpandShrinkXY with the shrink half amputated: expand_x and expand_y only go from 0 up to 1024, never negative. You grow a mask horizontally and vertically by an independent pixel count, and that's the whole feature set. If you've ever needed a selection to reach just a bit further past the subject before an inpaint pass - the most common mask tweak there is - this is a one-node answer.

It exists because the expand-only case is so common it deserves a stripped-down variant without the shrink branch. In practice, the full expand/shrink node covers this and more, so the honest question is why you'd reach for this one: if you want the input range to prevent you from accidentally shrinking a mask, or you're building a template graph and want the semantics obvious at a glance, this is the cleaner widget. Functionally, for any positive value, both nodes are identical.

How it works

Zero on both axes returns the mask untouched. Otherwise it applies a max_pool2d with a kernel of 2n+1 along each dimension - standard morphological dilation that grows the white region by n pixels in that axis. It handles 2D and batched masks, and it's deterministic and cheap. Nothing clever, nothing to misconfigure.

Inputs and output

  • mask (MASK) - the selection to grow.
  • expand_x (INT, 0–1024, default 0) - horizontal growth in pixels.
  • expand_y (INT, 0–1024, default 0) - vertical growth in pixels.

Output: MASK - the expanded mask.

Install

From ComfyUI_EmAySee_CustomNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
# restart ComfyUI

Or via ComfyUI Manager → "ComfyUI_EmAySee_CustomNodes". No dependencies.

Gotchas

Remember the expansion is at the mask's own resolution, not the final image's - a mask held at latent scale gets pixel counts in latent space. And hard-edged max-pool growth leaves blocky boundaries, so pair with a blur node if seams are a problem. If you ever want to shrink a mask instead of grow it, this node can't - that's EmAySee_MaskExpandShrinkXY's job. This is the "grow only" twin, and it's honest about it.

CategoryEmAySee/Mask

Inputs (3)

NameTypeDefaultDescription
maskMASK
expand_xINT00–1024
expand_yINT00–1024

Outputs (1)

NameTypeDescription
MASKMASK