计算 GLCM 纹理
灰度共生矩阵 (Haralick 等,1973)纹理是用于图像分析的强大图像特征。glcm 包提供了一个易于使用的功能来计算 R 中 RasterLayer 对象的这种中性特征。
library(glcm)
library(raster)
r <- raster("C:/Program Files/R/R-3.2.3/doc/html/logo.jpg")
plot(r)

在一个方向上计算 GLCM 纹理
rglcm <- glcm(r,
window = c(9,9),
shift = c(1,1),
statistics = c("mean", "variance", "homogeneity", "contrast",
"dissimilarity", "entropy", "second_moment")
)
plot(rglcm)

计算旋转不变纹理特征
纹理特征也可以在所有 4 个方向(0°,45°,90°和 135°)中计算,然后组合成一个旋转不变纹理。关键是 shift 参数:
rglcm1 <- glcm(r,
window = c(9,9),
shift=list(c(0,1), c(1,1), c(1,0), c(1,-1)),
statistics = c("mean", "variance", "homogeneity", "contrast",
"dissimilarity", "entropy", "second_moment")
)
plot(rglcm1)
