Transform an ROI's coordinates from one pyramid level to another, assuming a
power-of-two pyramid. For an exact transform against a real image pyramid
(which need not be power-of-two), use at_transform() with the
annot_image.
Usage
at_roi_rescale(
roi,
from_level = roi$level,
to_level,
call = rlang::caller_env()
)Arguments
- roi
An annot_roi.
- from_level
Integer source pyramid level. Defaults to the ROI's own
level; any other value is an error, because the coordinates are stored at that level.- to_level
Integer target pyramid level.
- call
The calling environment, for error reporting.
Value
An annot_roi with coordinates at to_level and its level field
set to to_level. Power-of-two scaling is exact in floating point, so the
transform is exactly invertible.
Examples
r <- at_roi_rect(0, 0, 100, 100, label = "a")
r2 <- at_roi_rescale(r, from_level = 0, to_level = 2)
identical(
sf::st_coordinates(sf::st_geometry(r)),
sf::st_coordinates(sf::st_geometry(at_roi_rescale(r2, 2, 0)))
)
#> [1] TRUE