Merge Masks π₯π ₯π π ’(MergeMasks)
This node accepts two MASK-type inputs and supports multiple merging strategies (such as match A, match B, match smaller/larger) to handle cases of inconsistent dimensions.
Merge Masks
The Merge Masks π₯π ₯π π ’ node receives two inputs of type MASK and supports multiple merge strategies (such as match A, match B, match smaller/larger) to handle cases where the dimensions are inconsistent.
The Merge Masks node is a tool within the Video Helper Suite specifically designed to merge two separate masks into one. Its core functionality is to intelligently blend or combine mask information from different sources based on the user-selected strategy, providing unified mask data for subsequent image or video processing steps.
Node Functionality
This node receives two inputs of type MASK and supports multiple merge strategies (such as match A, match B, match smaller/larger) to handle cases where the dimensions are inconsistent. When the input masks have different sizes, the node will automatically adjust the size of one mask to match the other based on the selected strategy, scaling method (e.g., bilinear, nearest neighbor), and cropping method, ensuring they can be merged correctly. Its internal implementation relies on PyTorch tensor operations and ComfyUI's generic scaling functions.
Node Parameter Description - Merge Masks π₯π ₯π π ’
Inputs
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
mask_A | MASK | Yes | - | - | The first input mask image, which will serve as one of the bases or references for the merge operation. |
mask_B | MASK | Yes | - | - | The second input mask image, which will be merged with mask_A. |
merge_strategy | MERGESTRATEGIES | Yes | - | Match B (MATCH_B), Match Smaller (MATCH_SMALLER), Match Larger (MATCH_LARGER). | The strategy used to determine which mask's dimensions to match during the merge. |
scale_method | SCALEMETHODS | Yes | - | Nearest neighbor interpolation (nearest), etc. | The method used to scale the mask if resizing is required. |
crop | CROPMETHODS | Yes | - | Disabled, etc. | The cropping method applied during the scaling process. |
Outputs
| Parameter Name | Data Type | Description |
|---|---|---|
| MASK | MASK | The newly generated mask image after merging. |
| count | INT | Outputs an integer value, typically representing the number of valid regions in the merged mask or other count information. |
Usage Scenarios
This node is very practical in video processing workflows. For example, when you have an object mask from motion detection and another background mask from chroma keying, you can use this node to merge them, resulting in a composite mask that includes both the foreground object and specific background areas for more complex compositing or special effects applications.
Notes
Please note that the quality of the merge result highly depends on the quality of the input masks and the selected scaling and cropping methods. Inappropriate scaling methods may cause jagged or blurred edges on the mask, affecting the final compositing result.
Merge Masks π₯π ₯π π ’ Node Source Code Link
The Merge Masks π₯π ₯π π ’ node is from the ComfyUI-VideoHelperSuite node package.
Comments
Sign in with GitHub to join the discussion.