Subtract Mask Regions
Mask A, minus mask B
- masks_a
- masks_b
- MASKS
Sometimes what you want isn't "this mask" or "that mask" - it's "this mask, except for that part." Say a segmentation model gives you a mask of an entire person, and a face-detection pass gives you a separate mask of just their face; subtract the face mask from the person mask and you're left with "everything except the face," which is exactly the selection you want for a detail pass that should leave the face alone. SaltMaskSubtract does that boolean subtraction directly, without you having to combine masks manually with math nodes.
How it works
Straightforward: wherever masks_b is "on," those pixels get removed from masks_a, regardless of what masks_a originally contained there. Where masks_b is "off," masks_a passes through unchanged. It's the mask equivalent of a Boolean difference operation - A minus B, not the intersection and not the union.
The inputs and outputs that matter
masks_a(required, MASK) - the base mask you're subtracting from.masks_b(required, MASK) - the mask being removed. Wherever this one is "on," the output goes "off," even ifmasks_awas fully on there.
Both inputs are required and there's no threshold or blend parameter - this reads as a direct value subtraction rather than a hard binary operation, so if either mask has soft/partial values, expect the result to reflect that (a 50%-opacity region in masks_b presumably reduces, rather than fully zeroes, the corresponding area of masks_a - worth confirming on a test mask if your workflow depends on the exact edge behavior).
Output: MASKS - masks_a with masks_b's footprint removed.
How to install it
SaltMaskSubtract ships in get-salt-AI/SaltAI ("SaltAI-Open-Resources"), from Salt AI (getsalt.ai) - a company that launched in March 2024 running ComfyUI workflows as hosted Discord bots and, later, an API. This masking family was the general-purpose part of that repo, and this particular node is one of the most broadly useful ones in it - mask arithmetic comes up in almost any non-trivial masking workflow.
The install catch, same as its siblings: github.com/get-salt-AI/SaltAI currently returns a 404. It's gone from the org's repo list and it's not indexed in ComfyUI Manager, so a fresh git clone or a Manager search for "SaltAI" both come up empty right now. If subtraction is all you need and you can't get this pack, it's worth knowing that basic mask-math nodes (add, subtract, multiply) are common enough that several other general-purpose packs - and ComfyUI's own core in more recent versions - cover the same ground. If SaltAI's already installed for you, no action needed; it's plain arithmetic with no models or platform dependency.
Common issues & troubleshooting
The subtraction "ate" more than you expected. Check that masks_b doesn't have soft, feathered edges bleeding further than you think - a blurred mask has partial values well outside its visually "solid" area, and those partial values will partially erode masks_a too, not just the obviously-white core of masks_b.
Result came out fully empty. If masks_b fully covers the area where masks_a had content, subtracting leaves nothing - that's correct behavior, not a bug, though it's worth double-checking you didn't swap masks_a and masks_b by accident, since this operation isn't symmetric (A minus B is not the same as B minus A).
You actually wanted the overlap, not the difference. This node gives you A-minus-B specifically. If what you're after is where two masks agree (the intersection) rather than where they diverge, you need a multiply-style combine instead - this isn't that operation.
Resolution or batch mismatch between masks_a and masks_b. Like most binary mask operations, this presumably expects both inputs to share dimensions; if your two masks came from different source images or different processing steps, verify they're the same size before wiring them in, since a resolution mismatch is a common source of silent, confusing results in mask-math graphs generally.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| masks_a | MASK | — | |
| masks_b | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASKS | MASK | — |