| Operation | Inputs | Set Operation | Truth Table |
|---|---|---|---|
| And | Image A, Image B | Intersection (A ∩ B) | 1 only where both inputs are 1 |
| And (with value) | Image, Value | Bitwise AND of every pixel with one number | Each bit is 1 only where the pixel and Value both have 1 |
| Or | Image A, Image B | Union (A ∪ B) | 1 where either input is 1 |
| Or (with value) | Image, Value | Bitwise OR of every pixel with one number | Each bit is 0 only where the pixel and Value both have 0 |
| Not | Image A | Complement (Aᶜ) | Inverts: 0→1, 1→0 |
| Xor | Image A, Image B | Symmetric Difference (A △ B) | 1 where inputs differ |
| Xor (with value) | Image, Value | Bitwise XOR of every pixel with one number | Each bit is 1 where the pixel and Value differ |
On binary masks, compound expressions build on these. Three come up often:
- A AND NOT B: region A without region B (set difference)
- NOT (A OR B): everything outside both regions
- (A OR B) AND NOT (A AND B): the same as XOR (exclusive regions)