Mask Erode Region
Shrink a mask's edges inward
The README's description is the whole job in six words: "erode the boundaries of a mask." Mask Erode Region shrinks the white area of a mask inward - every white pixel's neighborhood contracts, so the masked region gets smaller and thin protrusions disappear entirely. It's the exact opposite of its sibling in the same pack, Mask Dilate Region, which grows a mask's edges outward instead.
Why you'd shrink a mask on purpose
Erosion is the tool for pulling a mask back inside its own boundary - useful when a segmentation or threshold step slightly overshot the real edge of your subject and included a sliver of background along the border. It's also the fix when you deliberately want to be conservative: shrink the mask so an edit only touches the confident interior of a region, leaving a margin of untouched original pixels around it rather than risking the edit bleeding onto something you didn't mean to change. Where Dilate is about giving an inpaint room to blend outward, Erode is about pulling the edit boundary safely inward.
It also cleans up thin, stringy artifacts. A mask with a few pixel-wide tendrils reaching off the main region will often lose those tendrils entirely after erosion, since they're too thin to survive the boundary contracting.
How it works
Standard morphological erosion: every white pixel checks its neighborhood, and if that neighborhood isn't entirely white, the pixel gets knocked out. Run over the whole mask, that shrinks every white region's boundary inward by roughly the erosion amount, and any region thin enough gets erased completely. It doesn't care what produced the mask originally - hand-drawn, SAM output, a color threshold - it just contracts whatever white region it's given.
The inputs and outputs that matter
A MASK in, an amount controlling how far the boundary contracts, and a MASK out with the white region shrunk accordingly. It's a drop-in replacement for whatever mask you were about to use - wire the output straight into your inpaint node, crop node, or mask blend in place of the original.
Installing it
ComfyUI Manager: search "WAS Node Suite," install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui
install requirements.txt against your ComfyUI Python, restart. No model - plain image morphology.
Common issues & troubleshooting
A small mask disappeared entirely. That's erosion doing exactly what it's designed to do - if a region is thin or small enough relative to the erosion amount, it gets eaten completely. Back off the amount, or if you're trying to clean noise rather than shrink your actual subject, a targeted node like Mask Dominant Region (keep only the largest blob) is the better tool than erosion.
The mask barely changed. Check you're actually looking at this node's output and not the original mask still connected elsewhere in the graph - an easy mix-up when iterating quickly with a mask preview node.
Edit looks too conservative, missed some of the subject. That's the trade-off of eroding - you're deliberately pulling the boundary inward. If you eroded to be safe and now the edit doesn't cover enough, dial the amount down, or consider whether Mask Gaussian Region (a soft feather rather than a hard contraction) fits what you actually want better.
Whole pack won't import. Pack-level, not this node. WAS Node Suite has been unmaintained since the author marked it retired in December 2023; the well-known failure mode is the entire suite throwing "Import Failed" after a ComfyUI update from a pinned dependency clash (BLIP and opencv have both been cited by users hitting this). Reinstall requirements.txt against the correct, embedded Python interpreter and restart.
Inputs (0)
No inputs
Outputs (0)
No outputs