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, to_level, call = rlang::caller_env())Arguments
- roi
An annot_roi.
- from_level, to_level
Integer source and target pyramid levels.
- call
The calling environment, for error reporting.
Value
An annot_roi with coordinates at to_level and its level field
set to to_level. 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