Offset Mask(OffsetMask)
This node accepts one or more masks as input and allows the user to specify horizontal and vertical offsets (x, y), rotation angle (angle), and the number of times the mask is duplicated (duplication_factor).
Offset Mask
The Offset Mask node accepts one or more masks as input and allows users to specify horizontal and vertical offsets (x, y), rotation angle (angle), and the number of mask copies (duplication_factor).
The Offset Mask node is a tool for processing and transforming masks. Its core functionality involves spatially adjusting input masks through operations such as translation, rotation, and duplication to generate new masks. This node is particularly suitable for workflows requiring precise control over localized image processing areas.
Node Functionality
This node accepts one or more masks as input and allows users to specify horizontal and vertical offsets (x, y), rotation angle (angle), and the number of mask copies (duplication_factor). It supports three edge padding modes (padding_mode) to handle blank areas resulting from offsets and provides two special processing options, "roll" and "incremental," to achieve more complex transformation effects.
Node Parameter Description - Offset Mask
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
mask | MASK | Yes | - | - | The input mask or mask batch to be transformed. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
padding_mode | COMBO | Yes | empty | "empty", "border", "reflection" | "empty": leaves the outer area empty (zero); "border" (extends using edge pixels); "reflection" (mirrors edge pixels). |
x | INT | Yes | 0 | -4096 - MAX_RESOLUTION (step: 1) | Sets the horizontal offset (left/right) of the mask. Positive values shift right, negative values shift left. Range: -4096 to MAX_RESOLUTION. |
y | INT | Yes | 0 | -4096 - MAX_RESOLUTION (step: 1) | Sets the vertical offset (up/down) of the mask. Positive values shift down, negative values shift up. Range: -4096 to MAX_RESOLUTION. |
angle | INT | Yes | 0 | -360 - 360 (step: 1) | Sets the rotation angle of the mask in degrees. Positive values rotate counterclockwise, negative values rotate clockwise. Range: -360 to 360. |
duplication_factor | INT | Yes | 1 | 1 - 1000 (step: 1) | Specifies the number of times to duplicate the input mask to form the output batch. Range: 1 to 1000. Used to create multiple identical masks for batch processing or subsequent differential operations. |
roll | BOOLEAN | Yes | False | - | When enabled, parts of the mask that shift beyond the boundary re-enter the frame from the opposite side, creating a cyclic rolling effect. |
incremental | BOOLEAN | Yes | False | - | When enabled, the rotation angle (angle) is cumulatively applied to each mask in the batch. The first mask rotates by angle degrees, the second by 2*angle degrees, and so on. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| mask | MASK | The new mask after transformation processing such as rotation. |
Usage Scenarios
In image generation or editing workflows, you can use this node to create dynamic mask sequences. For example, by setting an incremental rotation angle (enabling the incremental option) and a duplication factor, you can generate a series of masks with progressively changing rotation angles. This can be used to control the rotation process of an object across animation frames or to apply effects at different angles to the same area.
Notes
Please note that when using large offset values or rotation angles, the main area of the mask may move outside the canvas boundary, resulting in a smaller effective mask area. Additionally, the duplication_factor parameter significantly increases the output mask batch size; system memory should be considered when processing a large number of duplicates.
Offset Mask Node Source Code Link
The Offset Mask node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.