Skip to contents

Unlike at_roi_rescale() (which assumes a power-of-two pyramid), this uses the actual level dimensions of an annot_image, so it is exact for pyramids with any downsampling ratio.

Usage

at_transform(
  roi,
  from_level = roi$level,
  to_level,
  img,
  call = rlang::caller_env()
)

Arguments

roi

An annot_roi.

from_level

Integer source pyramid level; defaults to, and must equal, the ROI's level, because that is the level its coordinates are stored at.

to_level

Integer target pyramid level.

img

The annot_image whose pyramid defines the level dimensions.

call

The calling environment, for error reporting.

Value

An annot_roi with coordinates at to_level. Invertible within floating-point precision (relative tolerance 1e-12).

Examples

img <- at_example_image("multiplex")
r <- at_roi_rect(0, 0, 100, 100, label = "a")
at_transform(r, from_level = 0, to_level = 2, img = img)
#> <annot_roi> a (POLYGON)
#> id: "roi_000000117"  |  level: 2  |  source: manual
#> bbox: [0, 0] - [25, 25]