Nodes/RuiquNodes for ComfyUI/ImageDilate(膨胀)
ComfyUI Node

ImageDilate(膨胀)

Grow the light regions of an image

By ruiqutech·Created 2 years ago·Updated 2 years ago· 0
ImageDilate(膨胀)
  • image
  • IMAGE
kernel_height0.0050
kernel_width0.0050

Same operation as this pack's MaskDilate - 膨胀, "expand" - but applied to a full IMAGE tensor instead of a single-channel MASK. It's classic morphological dilation, borrowed straight from image-processing toolkits like OpenCV: for every pixel, look at its neighborhood (sized by the kernel) and replace it with the brightest value found there, per channel. Do that everywhere and bright regions grow, dark regions shrink.

What it's actually for

This isn't a node for touching up a normal photograph - run it on a full-color photo and you'll get something closer to an ugly directional smear than a meaningful edit, because dilation operates on each channel's pixel neighborhoods independently with no idea what a "subject" or an "edge" is supposed to mean semantically. Where it earns its keep is on images that are already effectively binary or near-binary: a thresholded edge map, a line-art extraction, a stencil, a matte you're about to composite with something else. On those, dilation is a genuinely useful cleanup step - it fills small gaps and thin holes, thickens thin lines, and closes up minor breaks in an otherwise-continuous shape.

If what you actually have is a selection or a region rather than a genuine image, use MaskDilate instead - it does the same underlying operation on the data type built for it, and you'll get more predictable results.

Inputs and outputs

  • image (IMAGE) - the source.
  • kernel_height, kernel_width (FLOAT, 0–1, default 0.005) - the same fraction-of-dimension convention as MaskDilate, not a pixel count. Default spans about half a percent of the corresponding dimension.
  • Output: IMAGE, same shape, dilated.

The same kernel gotcha as MaskDilate

kernel_height/kernel_width are floats from 0 to 1 - a fraction of the image's dimension, not pixels. Typing 8 expecting an 8-pixel dilate (the convention most similar nodes elsewhere use) clamps you near the top of the range instead, spanning nearly the whole image. Stay in the 0.005–0.02 range for a normal cleanup pass and adjust from there.

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 to download - this is a pure image-processing operation, nothing to fetch.

Common issues

Running it on a photo looks bad. Expected - see above. This node is for matte/stencil/edge-map cleanup, not photo editing. If you wanted to grow a region of a photo, that's a mask operation, not an image one.

Barely any visible effect. You're likely still under 1% of the dimension. Nudge in small steps rather than large jumps - this node's useful range is much narrower than a pixel-based dilate you might be used to.

Colors bleed or shift at edges. Dilation on a multi-channel image dilates each channel independently, so at a boundary between two different colors you can get unexpected color mixing that wouldn't happen on a true single-channel matte. If that's a problem, convert to a mask or a single-channel representation first, then dilate that.

Categoryruiqu/image

Inputs (3)

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

Outputs (1)

NameTypeDescription
IMAGEIMAGE