Transform an ROI between pyramid levels using real image dimensions
Source:R/roi-geometry.R
sg_roi_transform.RdUnlike sg_roi_rescale() (which assumes a power-of-two pyramid), this uses
the actual level dimensions of an sg_roi_frame, so it is exact for pyramids
with any downsampling ratio.
Usage
sg_roi_transform(roi, from_level, to_level, img, call = rlang::caller_env())Arguments
- roi
An sg_roi.
- from_level, to_level
Integer source and target pyramid levels.
- img
The sg_roi_frame whose pyramid defines the level dimensions.
- call
The calling environment, for error reporting.
Value
An sg_roi with coordinates at to_level. 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_rescale(),
sg_roi_ring(),
sg_roi_rois_overlap(),
sg_roi_setops,
sg_roi_simplify(),
sg_roi_snap()
Examples
img <- sg_roi_frame(c(100, 100), list(c(100, 100), c(50, 50), c(25, 25)))
r <- sg_roi_rect(0, 0, 100, 100, label = "a")
sg_roi_transform(r, from_level = 0, to_level = 2, img = img)
#> <sg_roi> a (POLYGON)
#> id: "roi_000000054" | level: 2 | source: manual
#> bbox: [0, 0] - [25, 25]