Read a NumPy integer array (e.g. a ground-truth annotation mask) into a
lossless annot_mask – values are preserved exactly, including composite
bitfield codes. Use this (not at_read_mask(), which polygonises) when the
raw integer matrix is what you need, for example to derive a training mask or
compute agreement against another mask.
Usage
at_read_npy(
path,
level = 0L,
transpose = FALSE,
legend = NULL,
call = rlang::caller_env()
)Arguments
- path
Path to a
.npyfile.- level
Integer pyramid level to record. Default
0.- transpose
Logical; transpose the array on read, for files stored in the native cube order
(width, height)=[x, y](e.g. TIVITA/HyperGui masks) so the result lands in annotatR's[y, x]convention. DefaultFALSEassumes the standard image convention(height, width).- legend
Optional legend tibble (
value,label) overriding the sidecar / pixel-value labelling.- call
The calling environment, for error reporting.
Examples
m <- at_mask(at_example_project(), "labelled")
f <- tempfile(fileext = ".npy")
at_write_npy(m, f)
at_read_npy(f)
#> <annot_mask> labelled | 512 x 512 px | level 0
#> values: 3
#> # A tibble: 3 × 6
#> value label layer roi_id n_px colour
#> <int> <chr> <chr> <chr> <int> <chr>
#> 1 1 tumour regions roi_000000049 19600 #999999
#> 2 2 necrosis regions roi_000000050 72704 #E69F00
#> 3 3 stroma regions roi_000000051 34200 #56B4E9