Create Gradient Mask(CreateGradientMask)
This node internally generates a two-dimensional floating-point tensor using the NumPy and PyTorch libraries.
Create Gradient Mask
The Create Gradient Mask node internally generates a two-dimensional floating-point tensor using the NumPy and PyTorch libraries.
The Create Gradient Mask node is used to generate a linear gradient mask from black to white. It can batch-create grayscale images based on specified dimensions and frame counts. These images can be used as masks in image processing workflows to control the intensity or area of other effects.
Node Functionality
This node internally generates a two-dimensional floating-point tensor using the NumPy and PyTorch libraries. Its core mechanism creates a linear gradient value from 1.0 (white) to 0.0 (black) along the width of the image. When multiple frames are set, the gradient for each frame shifts over time, producing a dynamic effect. The final output is a MASK type tensor with a shape of [frames, height, width].
Node Parameter Description - Create Gradient Mask
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
invert | BOOLEAN | Yes | False | - | : Inverts the gradient direction of the mask. When set to True, the black and white areas are swapped. The default value is False. |
frames | INT | Yes | 0 | 0 - 255 (Step: 1) | : Specifies the number of mask frames to generate, used for creating batch sequences. The value range is 0 to 255, with a step of 1. |
width | INT | Yes | 256 | 16 - 4096 (Step: 1) | : Sets the width in pixels for the generated mask. The value range is 16 to 4096, with a step of 1. |
height | INT | Yes | 256 | 16 - 4096 (Step: 1) | : Sets the height in pixels for the generated mask. The value range is 16 to 4096, with a step of 1. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| MASK | MASK | : The output gradient mask, a single-channel grayscale tensor. |
Usage Scenarios
In video generation or image sequence processing workflows, you can connect the gradient mask generated by this node to nodes such as "Apply Mask" or "Blend Images." For example, use it to control the intensity of a transition effect, achieving a smooth left-to-right fade, or to apply filters with varying intensities to different areas.
Notes
Please note that the mask generated by this node is a single-channel grayscale image. When the frames parameter is greater than 0, it outputs a batch sequence of masks. You need to ensure that downstream nodes can handle batch input.
Create Gradient Mask Node Source Code Link
The Create Gradient Mask node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.