qtree: Do quad-tree segmentation

View source: R/qtree.R

qtreeR Documentation

Do 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. Depending on the aspect ratio, starting grids will going from 4 \times 4 to 1 \times 4 or 4 \times 1. Then, it splits each segment into four sub-segments and calculates the standard deviation of the pixels from r delimited by each of those sub-segments and segment. The splitting process stops locally if delta, the sum of the standard deviation of the sub-segments minus the standard deviation of the parent segment, 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() %>% normalize()
seg <- qtree(caim, scale_parameter = 0.05)
plot(extract_feature(caim$Blue, seg))
plot(extract_feature(seg, seg, length))

## End(Not run)

rcaiman documentation built on Nov. 15, 2023, 1:08 a.m.