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 sg_roi_transform() with the
sg_roi_frame.
Usage
sg_roi_rescale(roi, from_level, to_level, call = rlang::caller_env())Arguments
- roi
An sg_roi.
- from_level, to_level
Integer source and target pyramid levels.
- call
The calling environment, for error reporting.
Value
An sg_roi with coordinates at to_level and its level field
set to to_level. The transform is exactly invertible.
See also
Other geometry:
sg_roi_buffer(),
sg_roi_check_containment(),
sg_roi_check_geometry(),
sg_roi_clamp(),
sg_roi_contains(),
sg_roi_distance(),
sg_roi_fix_geometry(),
sg_roi_flip_y(),
sg_roi_overlaps(),
sg_roi_ring(),
sg_roi_rois_overlap(),
sg_roi_setops,
sg_roi_simplify(),
sg_roi_snap(),
sg_roi_transform()
Examples
r <- sg_roi_rect(0, 0, 100, 100, label = "a")
r2 <- sg_roi_rescale(r, from_level = 0, to_level = 2)
identical(
sf::st_coordinates(sf::st_geometry(r)),
sf::st_coordinates(sf::st_geometry(sg_roi_rescale(r2, 2, 0)))
)
#> [1] TRUE