Nodes/Akatz Custom Nodes/Dilate Mask Linear | Akatz
ComfyUI Node

Dilate Mask Linear | Akatz

Grow a mask outward, a few pixels at a time, forever

By akatz-ai·Created 2 years ago·Updated 9 months ago· 32
Dilate Mask Linear | Akatz
  • mask
  • MASK
shape
dilate_per_frame1
delay0

Dilate Mask Linear is the foundation node of the whole Akatz mask-animation family: it takes a mask and inflates it by a fixed number of pixels per frame, so a subject mask slowly swells outward over a clip. It's the simplest "animated mask" you can build, and a bunch of the pack's other nodes are fancier versions of exactly this idea.

Where you'd use it: you have a subject cut out as a mask - a person, a logo, a shape - and you want a clean, mechanical grow effect on it, like a reveal that spreads from the inside out. It's also the classic input for "dilate the inpaint region over time" or for making a glow/fill region expand as a video plays. Because it's linear and per-frame, it's predictable: the growth is the same every frame, no easing, no audio, no surprises.

How it works

For each frame after a delay you set, the mask is dilated with a structural element of increasing radius - dilate_per_frame pixels are added per frame. Choose circle for a shape-accurate, smooth edge (that's the author's recommendation for final output) or square for a fast approximation while you're testing. There's a nicety baked in: once a mask is fully saturated (all pixels white), the node stops trying to grow it and just passes it through, so you don't waste cycles dilating a fully-white frame. Frames before delay pass through unchanged, which is how you build a "hold, then grow" motion.

Inputs and output

  • mask - the input MASK (single mask or a batch, one per frame).
  • shape - circle or square, as above.
  • dilate_per_frame - pixels of growth per frame, default 1. This is the speed dial; crank it for fast reveals.
  • delay - number of frames to wait before growth starts, default 0.

Output is a MASK batch at the same length as the input. Feed it into an inpaint, a composite, or a masking effect.

Installing it

Part of akatz-ai/ComfyUI-AKatz-Nodes. Install via ComfyUI Manager (search "AKatz") or:

cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-AKatz-Nodes
cd ComfyUI-AKatz-Nodes
pip install -r requirements.txt

Restart ComfyUI after. No model downloads; the pack's requirements are numpy, torch, opencv-python and pydub.

Common issues

If your mask batch has fewer frames than your video, you'll get a short mask batch that downstream nodes will complain about - pad or loop it first. And remember dilate_per_frame is per frame, so the total growth is dilate_per_frame × (frames − delay). A common gotcha is setting a big dilate_per_frame expecting slow growth; it's actually fast growth per frame, so the mask saturates in a handful of frames. When you want the growth to be smooth at the edges, keep circle; square is noticeably blocky on curved subjects.

Category💜Akatz Nodes/Mask

Inputs (4)

NameTypeDefaultDescription
maskMASK
shapeCOMBO2 options: circle, square
dilate_per_frameINT10–9999
delayINT00–99999999

Outputs (1)

NameTypeDescription
MASKMASK