Per-value statistics of a mask
Usage
sg_roi_mask_stats(mask, pixel_size = NULL, call = rlang::caller_env())Value
A tibble::tibble with one row per mask value: value, label,
n_px, area_px, area_physical, frac_total, bounding box
(bbox_xmin, bbox_ymin, bbox_xmax, bbox_ymax), and centroid
(centroid_x, centroid_y). A 0-row tibble when the mask is empty.
Examples
lyr <- sg_roi_layer_add(sg_roi_layer("tissue"),
sg_roi_rect(2, 2, 8, 8, label = "tissue"))
proj <- sg_roi_project(sg_roi_frame(c(20, 20)), lyr)
sg_roi_mask_stats(sg_roi_mask(proj, "labelled"))
#> # A tibble: 1 × 12
#> value label n_px area_px area_physical frac_total bbox_xmin bbox_ymin
#> <int> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 tissue 36 36 NA 0.09 2 2
#> # ℹ 4 more variables: bbox_xmax <dbl>, bbox_ymax <dbl>, centroid_x <dbl>,
#> # centroid_y <dbl>