Mask Batch Combine (C2C)
Boolean math on entire mask batches, not just single frames
- mask_a
- mask_b
- mask
You have two masks and you want the overlap, the difference, or the combination. Mask Batch Combine (C2C) is the node for that - with one important upgrade over the single-mask composite nodes: it operates on whole batches of masks at once, frame-for-frame, which is exactly what video work needs.
Think of the uses. You want the face mask minus the hair mask so you can regrade skin without touching hair. You want the union of SAM's candidate masks so the object is fully covered. You want every frame of a tracked mask XOR'd against a motion mask. All of those are one node, one operation.
How it works
Two mask inputs - mask_a and mask_b - plus an op dropdown with six operations:
union- per-pixel max. Combine both.intersect- per-pixel min. The overlap only.diff- A minus B. Everything in A that isn't in B (the "subtract hair from face" case).xor- one or the other, not both.addandsubtract- arithmetic, clamped to [0,1] so you never overshoot.
Output: a single mask batch, same shape as the inputs.
The one rule that bites: sizes must match. The description is explicit - "sizes must match" - and unlike the pack's fancier Mask Composite Advanced node, this one won't auto-resize. If you get a shape error, one of your inputs isn't the same resolution or frame count as the other. Resize with an upscale/scale node or align the batches before combining.
Where it slots in
The natural pipeline in this pack: SAM Multi-Mask Picker gives you candidate masks and you want the union; or you're combining a coarse subject mask with a luma-key mask from LuminanceKeyerMEC to force the key to stay inside the subject (intersect is perfect for that). For video, it pairs with MaskTracker - combine the propagated mask with a per-frame motion mask so you only affect moving parts of a tracked region.
Because it's pure tensor math it's effectively free, which is why it belongs in a per-frame video chain where you'd never want a model in the loop.
Install
Same pack install as everything else here:
cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
or ComfyUI Manager → search "CustomNodePacks", then restart. No extra dependencies. If you hit a shape mismatch, double-check that both inputs came from the same image dimensions - it's the number-one error on this node and it's always a wiring problem, not a bug.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask_a | MASK | — | |
| mask_b | MASK | — | |
| op | COMBO | union | 6 options: union, intersect, diff, xor, add, subtract |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |