ScientiaLux
strataquest Glossary Logical Operations
BOM Group

Logical Operations

Boolean image operations for mask combination

View
Definition
Bitwise Boolean operations — AND, OR, NOT, and XOR — applied pixel-by-pixel to binary or grayscale images for combining masks, computing region intersections and unions, and creating composite spatial logic in BOM pipelines.
Four Boolean Operations
AND, OR, NOT, XOR for spatial set logic
Binary Mask Algebra
Combine spatial regions with set operations
Grayscale Bitwise
Operations work on integer bit representations
Pipeline Logic Building Blocks
Create complex spatial conditions from simple masks

Operations Reference

OperationInputsSet OperationTruth Table
ANDImage A, Image BIntersection (A ∩ B)1 only where both inputs are 1
ORImage A, Image BUnion (A ∪ B)1 where either input is 1
NOTImage AComplement (Aᶜ)Inverts: 0→1, 1→0
XORImage A, Image BSymmetric Difference (A △ B)1 where inputs differ

For binary mask images (0/1 values), these correspond exactly to set operations on the foreground regions. Common compound expressions:

  • A AND NOT B — Region A excluding region B (set difference)
  • NOT (A OR B) — Everything outside both regions
  • (A OR B) AND NOT (A AND B) — Equivalent to XOR (exclusive regions)
Simplified

AND keeps only pixels that are white in both images (overlap). OR keeps pixels white in either image (combined). NOT flips black↔white. XOR keeps pixels that differ between images. Use these to combine masks: 'tumor AND positive-staining' gives you only the overlap region.

When to Use Which

Region Intersection (AND)

The most common use: restrict analysis to where two conditions are both true. Examples: tumor tissue AND positive staining, tissue mask AND ROI mask, channel-A-positive AND channel-B-positive (co-expression).

Region Combination (OR)

Combine areas from multiple sources. Examples: merge tissue detection masks from different methods, combine multiple ROI selections, create a union of all stain-positive areas across channels.

Exclusion (NOT)

Create inverse masks. Examples: NOT tissue = glass/background region. NOT tumor = stromal + normal + necrosis. Combined as AND NOT: tissue AND NOT necrosis = viable tissue.

Mutual Exclusion (XOR)

Find regions unique to each mask. Examples: marker-A-positive XOR marker-B-positive identifies cells expressing one marker but not both — useful for identifying exclusive vs. co-expressing populations in a spatial context.

Simplified

Use AND to find overlap between two masks (most common). Use OR to combine masks. Use NOT to create the inverse. Use XOR to find areas that belong to one mask but not both. Chain operations for complex conditions like 'tumor AND stain-positive AND NOT necrosis.'

Connected Terms

Share This Term
Term Connections