% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/glcm.R
\name{glcm}
\alias{glcm}
\title{Grey-Level Co-Occurrence Matrix}
\usage{
glcm(image, segs = NULL, n_grey = 32, angle = 0)
}
\arguments{
\item{image}{SpatRaster. A single-band raster layer from which texture is measured}

\item{segs}{SpatRaster. A segmented raster. Cell values should be equal to segment numbers. If \code{segs} are not provided,
GLCM will be calculated for the entire image.}

\item{n_grey}{integer. Number of grey levels into which the image will be discretized}

\item{angle}{integer. Angle at which GLCM will be calculated. Valid inputs are 0, 45, 90, or 135}
}
\value{
data.frame
}
\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.
}
\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.
}
\examples{
\dontrun{
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)
}

}
\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).
\emph{Robust radiomics feature quantification using semiautomatic volumetric segmentation. PloS one, 9}(7)
}
\seealso{
\code{\link{mcws}}
}
