Skip to contents

Combine ROIs geometrically. Each accepts several annot_roi via ..., or a single annot_layer. Multi-part results are returned as one ROI with MULTIPOLYGON geometry (the return type is always a single annot_roi). When every input is a polygon the result is a POLYGON or MULTIPOLYGON; parts of lower dimension (edges or corners that ROIs only touch along) are dropped, and an empty result is an empty polygon, with a warning.

Usage

at_roi_union(..., call = rlang::caller_env(), image = NULL)

at_roi_intersect(..., call = rlang::caller_env(), image = NULL)

at_roi_difference(..., call = rlang::caller_env(), image = NULL)

at_roi_symdiff(..., call = rlang::caller_env(), image = NULL)

Arguments

...

Two or more annot_roi, or a single annot_layer.

call

The calling environment, for error reporting.

image

Optional annot_image defining actual pyramid dimensions. Required for mixed levels. With it, results use level 0; without it, all operands must share a level and the result retains that level.

Value

A single annot_roi with source = "derived".

Details

Bare ROIs at different pyramid levels are an error with code MIXED_LEVELS; pass image to combine them at level 0. The result takes the label and author of the first ROI, but not its lock, review status, QuPath object identity or shape attributes.

Examples

a <- at_roi_rect(0, 0, 6, 6, label = "x")
b <- at_roi_rect(4, 4, 10, 10, label = "x")
at_roi_area(at_roi_intersect(a, b))
#> [1] 4