glcm {ForestTools} | R Documentation |
Grey-Level Co-Occurrence Matrix
Description
Generate textural metrics using Grey-Level Co-Occurrence Matrices (GLCM). Can be applied to an entire or image or, if a coterminous raster of segments is provided, GLCM can be calculated for each segment.
Usage
glcm(image, segs = NULL, n_grey = 32, angle = 0)
Arguments
image |
SpatRaster. A single-band raster layer from which texture is measured |
segs |
SpatRaster. A segmented raster. Cell values should be equal to segment numbers. If |
n_grey |
integer. Number of grey levels into which the image will be discretized |
angle |
integer. Angle at which GLCM will be calculated. Valid inputs are 0, 45, 90, or 135 |
Details
The underlying C++ code for computing GLCMs and their statistics was originally written by Joel Carlson for the defunct [radiomics](https://github.com/cran/radiomics) library. It has been reused here with permission from the author.
Value
data.frame
References
Parmar, C., Velazquez, E.R., Leijenaar, R., Jermoumi, M., Carvalho, S., Mak, R.H., Mitra, S., Shankar, B.U., Kikinis, R., Haibe-Kains, B. and Lambin, P. (2014). Robust radiomics feature quantification using semiautomatic volumetric segmentation. PloS one, 9(7)
See Also
Examples
## Not run:
library(terra)
library(ForestTools)
chm <- rast(kootenayCHM)
image <- rast(kootenayOrtho)[[1]]
# Generate raster segments
segs <- mcws(kootenayTrees, chm, minHeight = 0.2, format = "raster")
# Get textural metrics for ortho's red band
tex <- glcm(image, segs)
## End(Not run)