Grow Mask With Blur(GrowMaskWithBlur)
This node implements mask dilation based on morphological operations from the Kornia library, supporting processing of a single mask or a batch of masks.
Grow Mask With Blur
The Grow Mask With Blur node implements mask expansion based on morphological operations from the Kornia library, supporting processing of single masks or mask batches.
GrowMaskWithBlur is a node for processing and enhancing masks. Its core functionality is to expand or contract the input mask region and optionally apply a blur effect, thereby generating smooth masks or masks with specific shape variations.
Node Functionality
This node implements mask expansion based on morphological operations from the Kornia library, supporting processing of single masks or mask batches. Its core mechanism involves adjusting pixel boundaries to change the mask size, with the option to apply Gaussian blur to soften edges. It also provides interpolation and decay factors for handling transitions between sequence frames.
Node Parameter Description - Grow Mask With Blur
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
mask | MASK | Yes | - | - | Input mask or mask batch. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
expand | INT | Yes | 0 | -MAX_RESOLUTION - MAX_RESOLUTION (Step: 1) | expand (Input Parameter): Controls the number of pixels to expand or contract the mask. Range is -MAX_RESOLUTION to MAX_RESOLUTION, step is 1. Positive values expand, negative values contract. |
incremental_expandrate | FLOAT | Yes | 0.0 | 0.0 - 100.0 (Step: 0.1) | incremental_expandrate (Input Parameter): Incrementally increases the expansion amount for each frame in a sequence at this rate. Range 0.0 to 100.0, step 0.1. |
tapered_corners | BOOLEAN | Yes | True | - | tapered_corners (Input Parameter): When enabled, uses tapered corners for morphological operations; otherwise uses standard rectangles. Enabled by default. |
flip_input | BOOLEAN | Yes | False | - | flip_input (Input Parameter): When enabled, inverts the input mask (swaps black and white) before processing. |
blur_radius | FLOAT | Yes | 0.0 | 0.0 - 100 (Step: 0.1) | blur_radius (Input Parameter): The radius for applying Gaussian blur to the processed mask. Takes effect when value > 0. Range 0.0 to 100, step 0.1. |
lerp_alpha | FLOAT | Yes | 1.0 | 0.0 - 1.0 (Step: 0.01) | lerp_alpha (Input Parameter): Alpha value used for linear interpolation between frames. Range 0.0 to 1.0, step 0.01. |
decay_factor | FLOAT | Yes | 1.0 | 0.0 - 1.0 (Step: 0.01) | decay_factor (Input Parameter): Decay factor used for interpolation between frames. Range 0.0 to 1.0, step 0.01. |
fill_holes | BOOLEAN | No | False | - | Fill holes in the mask (slow). |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| mask | MASK | mask (Output Parameter): Outputs the final processed mask. |
| mask_inverted | MASK | mask_inverted (Output Parameter): Outputs the inverted version of the processed mask. |
Usage Scenarios
This node is very useful in image generation or video processing workflows. For example, when creating a gradually appearing animation effect, you can connect an initial object mask to this node. By incrementally increasing the expand value frame by frame and combining it with blur_radius, you can create an animated mask sequence where the object's edges softly diffuse.
Notes
Please note that the fill_holes (fill holes) feature is marked as a slower operation. It should be used with caution when processing high-resolution masks or large batches of data to avoid impacting workflow execution efficiency.
Grow Mask With Blur Node Source Code Link
The Grow Mask With Blur node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.