qtree: Quad-tree segmentation

View source: R/qtree.R

qtreeR Documentation

Quad-tree segmentation


The quad-tree segmentation algorithm is a top-down process that makes recursive divisions in four equal parts until a condition is satisfied and stops locally. This is the usual implementation of the quad-tree algorithm, so it produces squared segments of different sizes. This particular implementation allows up to five sizes.


qtree(r, scale_parameter = 0.2)





Numeric vector of length one. Quad-tree is a top-down method. This parameter controls the stopping condition. Therefore, it allows controlling the size of the resulting segments. Ultimately, segments sizes will depend on both this parameter and the heterogeneity of r.


The algorithm starts splitting the entire image into large squared segments following, depending on the aspect ratio, grids going from 4 \times 4 to 1 \times 4/4 \times 1; then, splits each segment into four sub-segments and calculates the standard deviation of the pixels from r delimited by each of those segments. The splitting process stops locally if the sum of the standard deviation of the sub-segments minus the standard deviation of the parent segment (named delta) is less or equal than the scale_parameter. If r has more than one layer, delta is calculated separately and delta mean is used to evaluate the stopping condition.


A single layer image of the class SpatRaster with integer values.

See Also

Other Segmentation Functions: chessboard(), mask_hs(), mask_sunlit_canopy(), polar_qtree(), rings_segmentation(), sectors_segmentation(), sky_grid_segmentation()


## Not run: 
caim <- read_caim()
caim <- normalize(caim, 0, 255)
seg <- qtree(caim, scale_parameter = 0.5)
plot(extract_feature(caim$Blue, seg))
plot(extract_feature(seg, seg, length))

## End(Not run)

rcaiman documentation built on Sept. 20, 2022, 1:05 a.m.

Related to qtree in rcaiman...