LayerMask: MaskGrow
MaskGrow
- mask
- mask
Grow the mask, shrink the mask, soften the edge. That's the whole job, and you'll use it constantly. Almost every mask you generate - from a segmenter, a background remover, a detector - needs a little adjustment before it's compositing-ready. Too tight and you get a dark halo of leftover background around your subject; too hard-edged and the paste looks cut out with scissors. MaskGrow is the quick fix that lives between "I have a mask" and "the mask actually works."
Under the hood it's morphological dilation and erosion plus a Gaussian blur - standard image-processing operations, wrapped so you don't have to think about them. Positive grow dilates the mask outward; negative grow erodes it inward. The blur then feathers the boundary so the transition is soft instead of a stair-step. Nothing exotic, but having it in one clean node beats chaining three others.
There are only three knobs and they're all you need. grow is the main one - the number of pixels to expand (positive) or contract (negative) the masked region. A common pattern: grow by a few pixels to make sure you're covering the whole subject including edge pixels, or shrink by a few to pull the mask inside the subject so an inpaint doesn't bleed onto the background. blur is the feather radius; a value in the single digits softens the edge nicely, higher values give you a big gradient falloff useful for gentle blends and relighting masks. Then there's invert_mask, and this is the one that surprises people: it defaults to true. So if your mask comes out backwards - subject transparent, background solid - that toggle is why. Flip it and you're set.
Input is a mask, output is a mask. It drops in anywhere a mask goes: before an inpaint, before a composite, after a segmenter to clean up. Dead simple, and that simplicity is the point.
Install is the pack standard: in ComfyUI Manager, search "ComfyUI Layer Style" and install, or cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt and restart. No model downloads for this one - it's pure image math, so it loads instantly and runs on anything.
The realistic trouble here isn't the node, it's the pack. LayerStyle is famous for "failed to import" errors on install, usually a transformers or dependency version conflict elsewhere in the pack dragging the whole thing down with it - even lightweight nodes like this one won't appear if the pack fails to load. If MaskGrow is missing after you installed the pack, the pack didn't import; check your console for the red traceback, hit "Try Fix" in Manager, and reinstall the requirements into your venv. Beyond that, the only real gotcha is the default-inverted invert_mask. If your grown mask looks inside-out, that's it, not a bug.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| invert_mask | BOOLEAN | true | — |
| grow | INT | 4-999–999 | — |
| blur | INT | 40–999 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |