Skip to contents

Combine rasterised layer masks into the derived training mask state WHERE anatomy == keep_label AND artefact == 0 AND state != background. This is the cross-layer operation the four-layer HSI scheme relies on: it keeps a state (class) label only where the anatomy layer marks the region of interest, no artefact bit is set, and the state is actually labelled.

Usage

at_mask_derive(
  state,
  anatomy,
  artefact = NULL,
  keep_label = "wound",
  background = 0L,
  call = rlang::caller_env()
)

Arguments

state

An annot_mask of state (class) codes.

anatomy

An annot_mask of anatomy codes, sharing state's dimensions and level.

artefact

Optional annot_mask (bitfield); pixels with any artefact bit set are dropped. NULL (default) applies no artefact exclusion.

keep_label

The anatomy label whose region is kept (e.g. "wound").

background

Integer background/unlabeled value. Default 0.

call

The calling environment, for error reporting.

Value

An annot_mask (multiclass) of the surviving state codes, with the state legend restricted to those classes and pixel counts recomputed.

Examples

proj <- at_example_project()
# A single-layer project derives trivially; the four-layer HSI workflow passes
# separate anatomy/state/artefact masks. See the masks vignette.
m <- at_mask(proj, "multiclass")
at_mask_derive(m, m, keep_label = at_mask_legend(m)$label[1])
#> <annot_mask> multiclass  |  512 x 512 px  |  level 0
#> values: 1
#> # A tibble: 1 × 6
#>   value label  layer   roi_id  n_px colour 
#>   <int> <chr>  <chr>   <chr>  <int> <chr>  
#> 1     1 tumour regions NA     19600 #999999