GLCM {agrifeature} | R Documentation |
Gray Level Co-occurrence Matrix(GLCM).
Description
This function calculate Gray Level Co-occurrence Matrix(GLCM), which can be used to describe texture of the image. The default parameters is distance = 1, angle = 0, gray level = 8
Usage
GLCM(x, d = 1, angle = 0, ngray = 8, grayscale = c(0,255), symmetric = TRUE, prob = FALSE)
Arguments
x |
A numeric matrix. |
d |
an integer value, the distance between the current pixel, and the pixel to which it is compared. |
angle |
one of "0", "45", "90" or "135", the pixel to which the current pixel is compared. |
ngray |
an integer value, the number of gray levels to use in calculate GLCM. |
grayscale |
a vector which contain c(min,max) to set the range of value , if NULL grayscale will be set into the min and max value in x. |
symmetric |
Logical value, if TRUE (default) the matrix will be turn into a symmetric GLCM. |
prob |
Logical value, if TRUE (default) the matrix will be normalized such that the sum of it's components is 1. |
Value
A GLCM with dimension ngray*ngray table. Each column and row represent a gray level in the image matrix.
References
Hall-Beyer, M. (2000). GLCM texture: a tutorial. National Council on Geographic Information and Analysis Remote Sensing Core Curriculum, 3, 75.
Examples
# generate an image data matrix with range 0~255
set.seed(100)
m <- matrix(sample(0:255,64), nrow=8, ncol=8)
# calculate GLCM with defalut parameters
GLCM.m <- GLCM(m)
# calculate probability GLCM
GLCM.m.p <- GLCM(m,prob = TRUE)