polar_qtree: Generate polar quadtree segmentation

View source: R/polar_qtree.R

polar_qtreeR Documentation

Generate polar quadtree segmentation

Description

Segment a hemispherical image into large circular trapezoids and recursively split them into four trapezoids of equal angular size whenever brightness heterogeneity exceeds a predefined threshold.

Usage

polar_qtree(r, z, a, scale_parameter, angle_width = 30, max_splittings = 6)

Arguments

r

numeric terra::SpatRaster. One or more layers used to drive heterogeneity.

z

terra::SpatRaster generated with zenith_image().

a

terra::SpatRaster generated with azimuth_image().

scale_parameter

numeric vector of length one. Threshold on delta controlling splits (see Details).

angle_width

numeric vector of length one. Angle in deg that must divide both 0–360 and 0–90 into an integer number of segments. Retrieve a set of valid values by running lapply(c(45, 30, 18, 10), function(a) vapply(0:6, function(x) a/2^x, 1)).

max_splittings

numeric vector of length one. Maximum recursion depth.

Details

A circular trapezoid, hereafter referred to as a cell, is the intersection of a ring (zenith‑angle band) and a sector (azimuth‑angle band). Heterogeneity within a cell is measured as the standard deviation of pixel values (a first‑order texture metric). The change in heterogeneity due to splitting is delta, defined as the sum of the standard deviations of the four subcells minus the standard deviation of the parent cell. A split is kept where delta > scale_parameter. For multi‑layer r, delta is computed per layer and averaged to decide splits. Angular resolution at level i is angle_width / 2^i.

Value

Single-layer terra::SpatRaster with integer values and the same number of rows and columns as r.

Examples

## Not run: 
# Find large patches of white ---------------------------------------------
caim <- read_caim()
r <- caim$Blue
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)

bin <- binarize_with_thr(r, thr_isodata(r[]))
plot(bin)

seg <- polar_qtree(bin, z, a, 0, 30, 3)
plot(extract_feature(bin, seg) == 1)

## End(Not run)

rcaiman documentation built on Sept. 9, 2025, 5:42 p.m.