Video Helper Suite πŸŽ₯πŸ…₯πŸ…—πŸ…’/maskgenerated

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

mask_A
mask_B
MASK
count
merge_strategy
COMBO
scale_method
COMBO
crop
COMBO
VideoHelperSuite

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 NameData TypeRequiredDefault ValueRange/OptionsDescription
mask_AMASKYes--The first input mask image, which will serve as one of the bases or references for the merge operation.
mask_BMASKYes--The second input mask image, which will be merged with mask_A.
merge_strategyMERGESTRATEGIESYes-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_methodSCALEMETHODSYes-Nearest neighbor interpolation (nearest), etc.The method used to scale the mask if resizing is required.
cropCROPMETHODSYes-Disabled, etc.The cropping method applied during the scaling process.

Outputs

Parameter NameData TypeDescription
MASKMASKThe newly generated mask image after merging.
countINTOutputs 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.

The Merge Masks πŸŽ₯πŸ…₯πŸ…—πŸ…’ node is from the ComfyUI-VideoHelperSuite node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…