KJNodes/maskinggenerated

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

mask
mask
x
INT
y
INT
angle
0
duplication_factor
1
roll
incremental
padding_mode
empty
KJNodes

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 NameData TypeRequiredDefault ValueValue Range/OptionsDescription
maskMASKYes--The input mask or mask batch to be transformed.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
padding_modeCOMBOYesempty"empty", "border", "reflection""empty": leaves the outer area empty (zero); "border" (extends using edge pixels); "reflection" (mirrors edge pixels).
xINTYes0-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.
yINTYes0-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.
angleINTYes0-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_factorINTYes11 - 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.
rollBOOLEANYesFalse-When enabled, parts of the mask that shift beyond the boundary re-enter the frame from the opposite side, creating a cyclic rolling effect.
incrementalBOOLEANYesFalse-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 NameData TypeDescription
maskMASKThe 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.

The Offset Mask node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…