StrataQuest Home › StrataQuest Glossary › Logical Operations
BOM Group

Logical Operations

Boolean image operations for mask combination

View
Definition
Logical Operations apply AND, OR, NOT and XOR to binary or grayscale images, one pixel position at a time. Each result is a new mask or composite image, ready for the next step of a BOM pipeline.
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
And (with value)Image, ValueBitwise AND of every pixel with one numberEach bit is 1 only where the pixel and Value both have 1
OrImage A, Image BUnion (A ∪ B)1 where either input is 1
Or (with value)Image, ValueBitwise OR of every pixel with one numberEach bit is 0 only where the pixel and Value both have 0
NotImage AComplement (Aᶜ)Inverts: 0→1, 1→0
XorImage A, Image BSymmetric Difference (A △ B)1 where inputs differ
Xor (with value)Image, ValueBitwise XOR of every pixel with one numberEach 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)
Simplified

AND keeps the pixels that are white in both images, the overlap. OR keeps pixels white in either. NOT flips black and white. XOR keeps pixels that differ.

Combine masks this way, and 'tumor AND positive-staining' gives you only the overlap.

When to Use Which

Region Intersection (AND)

AND is the most common: it restricts analysis to where two conditions both hold, as in tumor tissue AND positive staining, tissue mask AND ROI mask, or channel-A-positive AND channel-B-positive (co-expression).

Region Combination (OR)

OR combines areas from several sources: tissue masks from different detection methods, several ROI selections, or all the stain-positive areas across channels.

Exclusion (NOT)

NOT makes the inverse mask. NOT tissue is the glass, or background, and NOT tumor is stroma, normal tissue and necrosis. Paired with AND, NOT excludes: tissue AND NOT necrosis is the viable tissue.

Mutual Exclusion (XOR)

XOR finds the regions unique to each mask. Marker-A-positive XOR marker-B-positive marks cells that express one marker but not both, which separates exclusive from co-expressing populations in their spatial context.

Simplified

Use AND to find where two masks overlap; it is the most common. Use OR to combine masks, NOT to invert one, and XOR to find areas that belong to one mask but not both. Chain them for conditions like 'tumor AND stain-positive AND NOT necrosis.'

Connected Terms

Share This Term
Term Connections