Learn R Programming

glcm (version 0.2)

glcm: Image texture measures from grey-level co-occurrence matrices (GLCM)

Description

This function supports calculating texture statistics derived from grey-level co-occurrence matrices (GLCMs) in R.

Usage

glcm(x, n_grey = 32, window = c(3, 3), shift = c(1, 1), statistics =
c("mean", "variance", "homogeneity", "contrast", "dissimilarity", "entropy",
"second_moment", "correlation"),
min_x=NULL, max_x=NULL, na_opt="any", na_val=NA, scale_factor=1,
asinteger=FALSE)

Arguments

x
a RasterLayer or matrix
n_grey
number of grey levels to use in texture calculation
window
the window size to consider for texture calculation as a two element integer vector (number of rows, number of columns)
shift
a two element integer vector giving the shift (Q in Gonzalez and Woods, 2008).
statistics
A list of GLCM texture measures to calculate. Can include any (one or more) of the following: 'mean', 'mean_ENVI', 'variance', 'variance_ENVI', 'homogeneity', 'contrast', 'dissimilarity', 'entropy', 'second_moment', and/or 'correlation'.
min_x
minimum value of input RasterLayer (optional, glcm will calculate if not supplied). Useful when running glcm over blocks of a raster.
max_x
maximum value of input RasterLayer (optional, glcm will calculate if not supplied). Useful when running glcm over blocks of a raster.
na_opt
How to handle NA values in x. Can be set to "ignore", "any" or "center". If set to "any", all textures statistics for a given pixel will be set to NA if there are any NA values in the window around that pixel. If set
na_val
the value to use to fill NA values on edges of x where textures cannot be calculated due to the window falling outside of the image, and as necessary depending on the chosen na_opt.
scale_factor
factor by which to multiply results. Useful if rounding results to integers (see asinteger argument).
asinteger
whether to round results to nearest integer. Can be used to save space by saving results as, for example, an 'INT2S' raster.

Value

  • A RasterLayer with the requested GLCM texture measures.

encoding

UTF-8

References

Lu, D., and M. Batistella. 2005. Exploring TM image texture and its relationships with biomass estimation in Rondônia, Brazilian Amazon. Acta Amazonica 35:249--257. Gonzalez, R. C. 2008. Digital image processing. 3rd ed. Prentice Hall, Upper Saddle River, N.J, pages 830--836. Haralick, R. M., K. Shanmugam, and I. Dinstein. 1973. Textural features for image classification. IEEE Transactions on Systems, Man and Cybernetics SMC-3:610--621. Pratt, W. K. 2007. Digital image processing: PIKS Scientific inside. 4th ed. Wiley-Interscience, Hoboken, N.J pages 540--541, 563--566.

Examples

Run this code
require(raster)
textures <- glcm(raster(L5TSR_1986, layer=1))
plot(textures)

Run the code above in your browser using DataLab