Nodes/ComfyUI-LTXVideo/πŸ…›πŸ…£πŸ…§ LTXV Dilate Video Mask
ComfyUI Node Runs on cloud

πŸ…›πŸ…£πŸ…§ LTXV Dilate Video Mask

Grow a mask in space and across frames

By LightricksΒ·Created 2 years agoΒ·Updated about a month agoΒ· 3,956
πŸ…›πŸ…£πŸ…§ LTXV Dilate Video Mask
  • mask
  • image_as_mask
  • mask
β—„spatial_radius1β–Ί
β—„temporal_radius0β–Ί

Masks for video inpainting almost always need to be a little bigger than the thing you're masking. Too tight and the edit leaves a hard seam or misses the edges of a moving subject; grow it a touch and the result blends. This node does that growing - spatially, so the mask expands outward in each frame, and temporally, so it expands across frames to keep a moving object covered. That temporal part is the bit generic image-mask tools can't do, and it's exactly what video needs.

How it works

Per the description, it dilates a video mask using separable max-pooling and then thresholds the result. In plain terms: max-pooling with a given radius is how you grow a mask (any pixel near a masked pixel becomes masked), and doing it separately in the spatial and temporal directions lets you control each independently. The threshold cleans the grown mask back into a solid region. So you get a mask that's fatter in exactly the dimensions you asked for, ready to feed an inpaint or region-conditioning path.

The inputs and output

  • spatial_radius (default 1) - how far the mask grows within each frame. Bump this up when your edit is clipping the subject's edges or leaving a hard border.
  • temporal_radius (default 0) - how many frames forward and back the mask spreads. Default 0 means "don't touch time," but for a moving subject a value of 1–2 keeps coverage as it travels.

You feed it either a mask or an image_as_mask (both optional inputs - one or the other). The output is the dilated mask.

Installing it

  • ComfyUI Manager - search LTXVideo, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/Lightricks/ComfyUI-LTXVideo, then restart.

Common issues

The edit still clips the subject. Raise spatial_radius. A radius of 1 is a very gentle grow; a fast-moving or fuzzy subject often wants more.

A moving object gets left behind by the mask. That's what temporal_radius is for. At 0 the mask is frozen per-frame; give it 1 or 2 so the coverage extends across time and tracks the motion. Don't overdo it - too much temporal growth smears the mask over frames where the object isn't.

The edit region got way too big. You over-grew it. Dilation is easy to overshoot; pull both radii back down. And mind the order of operations - dilate first, then run the result through LTXV Preprocess Masks to pool it into latent space, not the other way around, so the growth happens at full resolution where it's precise.

CategoryLightricks/mask_operations

Inputs (4)

NameTypeDefaultDescription
spatial_radiusINT10–300Half-size of the spatial dilation kernel. Kernel = 2*radius+1.
temporal_radiusINT00–10Half-size of the temporal dilation kernel. Kernel = 2*radius+1.
maskoptMASKVideo mask to dilate. Either this or image_as_mask must be provided.
image_as_maskoptIMAGEImage to use as mask (channel-averaged). Either this or mask must be provided.

Outputs (1)

NameTypeDescription
maskMASKβ€”