Pixelwise(MASK & MASK)
Keep only where two masks overlap
- mask1
- mask2
- MASK
Pixelwise(MASK & MASK) in the node picker, and the name tells you the whole operation: a pixelwise AND between mask1 and mask2. Only the pixels where both masks agree survive; anything covered by just one of them gets dropped. It's the intersection, not the union.
The classic reason to reach for this: you've got a crude mask (a bounding-box detection, say) and a precise mask (a hand-painted region or a SAM silhouette), and you want the accuracy of the second constrained to the area of the first. AND the two together and you keep only the part that's both roughly where you meant and precisely shaped.
How it works
Both masks are grayscale, white for "included." This node computes a pixelwise AND - practically, the minimum of the two values at each pixel - so a spot only stays covered if it had meaningful coverage in both inputs. Regions unique to one mask or the other are removed entirely. If the two masks don't overlap at all, you get an empty (all-black) result.
The inputs and outputs that matter
Two required inputs, nothing to configure:
mask1,mask2- the two masks to intersect. Symmetric, so which one you callmask1vsmask2doesn't change the result.
Output is a single MASK - the overlap, ready for a detailer, an inpaint, or another mask op.
How to install it
Part of the Impact Pack. ComfyUI Manager: search ComfyUI Impact Pack, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
cd comfyui-impact-pack
pip install -r requirements.txt
then restart. No models or extra dependencies - pure mask math.
Common issues & troubleshooting
Output is completely empty. Your two masks don't actually overlap. Check they're derived from the same image at the same resolution, and that the regions they mark genuinely coincide - if one mask is a face detection and the other is a hand mask, ANDing them will correctly give you nothing.
The result is smaller than either input. Expected - an intersection can only shrink, never grow, relative to its inputs. If the kept region is too tight, dilate one of the source masks before combining, or use AddMask (Pixelwise MASK + MASK) instead if you actually wanted the union.
Sizes mismatch. Both masks need identical resolution. Resize one to match upstream if they came from different sources.
Working with SEGS instead of plain masks? This node is for raw MASK type only. If your two sets of regions are SEGS objects (from detectors), the SEGS-level equivalent is BitwiseAndMaskForEach - Pixelwise(SEGS & SEGS) - which intersects region-by-region rather than as flat masks. Wrong type for the socket and it simply won't connect.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask1 | MASK | — | |
| mask2 | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |