Learn R Programming

ForestTools (version 0.2.5)

glcm: Grey-Level Co-Occurrence Matrix

Description

Generate textural metrics for a segmented raster using Grey-Level Co-Occurrence Matrices (GLCM). It will return a series of GLCM statistics for each segment (segs) based on an underlying single-band raster image (image) in the form of a data.frame.

Usage

glcm(
  segs,
  image,
  n_grey = 32,
  angle = 0,
  clusters = 1,
  showprog = FALSE,
  roundCoords = 4
)

Arguments

segs

RasterLayer. A segmented raster. Cell values should be equal to segment numbers

image

RasterLayer. A single-band raster layer from which texture is measured

n_grey

integer. Number of grey levels the image should be quantized into

angle

integer. Angle at which GLCM will be calculated. Valid inputs are 0, 45, 90, or 135

clusters

integer. Number of clusters to use during parallel processing

showprog

logical. Display progress in terminal

roundCoords

integer. Errors in coordinate precision can trigger errors in this function. Internally, the coordinates are rounded to this decimal place. Default value of 4 decimals.

Value

data.frame

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.

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)

Examples

Run this code
# NOT RUN {
# Generate raster segments
segs <- mcws(kootenayTrees, kootenayCHM, minHeight = 0.2, format = "raster")

# Get textural metrics for ortho's red band
tex <- glcm(segs, kootenayOrtho[[1]])
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab