Nodes/RuiquNodes for ComfyUI/ImageErode(腐蚀)
ComfyUI Node

ImageErode(腐蚀)

Shrink the light regions of an image

By ruiqutech·Created 2 years ago·Updated 2 years ago· 0
ImageErode(腐蚀)
  • image
  • IMAGE
kernel_height0.0050
kernel_width0.0050

The inverse of ImageDilate, and this pack's display name for it says as much directly - ImageErode(腐蚀), "corrode." Same morphological family as MaskErode, applied to a full IMAGE tensor instead of a MASK: for every pixel, look at its neighborhood and replace it with the darkest value found there, per channel. Bright regions shrink, dark regions grow.

What it's actually good for

Like its dilate counterpart, this isn't meant for editing a normal photo - applied to a full-color image it behaves more like an odd per-channel smear than a deliberate edit, because it has no concept of subject or edge, just raw pixel neighborhoods. Where erosion genuinely helps is cleaning up images that are already close to binary: it strips thin noise specks and stray bright pixels out of a thresholded map, a stencil, or a matte, shrinking anything that's too thin to survive the kernel while leaving solid regions largely intact. It's the classic complement to dilate: erode to remove noise, dilate back to restore lost size without the noise returning - a standard two-step cleanup for a rough binary image.

If what you're working with is actually a selection or region rather than a real image, reach for MaskErode instead - same operation, correct data type, more predictable results.

Inputs and outputs

  • image (IMAGE) - the source.
  • kernel_height, kernel_width (FLOAT, 0–1, default 0.005) - same fraction-of-dimension convention as the rest of this pack's morphology nodes, not a pixel count.
  • Output: IMAGE, eroded.

The same kernel gotcha

Floats from 0 to 1, not pixels. Push the value up expecting a modest pixel-scale erosion and you can eat far more of the image than intended - and unlike dilate, erosion has a hard floor: push it too far and content just disappears rather than merely shrinking a bit. Start small (0.005–0.02) and work up gradually.

Installing it

ComfyUI Manager: search RuiquNodes, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/ruiqutech/ComfyUI-RuiquNodes

then restart. No models needed.

Common issues

Regions vanish entirely. You've eroded past what was there - thin shapes go first, since they have the least to lose before the kernel eats through them completely. Back the values off and step up gradually rather than guessing a value.

Used on a photo, the result looks wrong. As above, this node is for matte/stencil/binary-image cleanup, not photo editing. For a region of a real photo, that's a mask operation, not an image one.

Cleaning up noise before compositing. If you've got a rough matte with speckled noise, try erode followed by dilate at the same kernel size - it removes the small stray bits while restoring the overall shape's size, which is more forgiving than either operation alone.

Categoryruiqu/image

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
kernel_heightFLOAT0.00500–1
kernel_widthFLOAT0.00500–1

Outputs (1)

NameTypeDescription
IMAGEIMAGE