Calculate Textures from Grey-Level Co-Occurrence Matrices (GLCMs)

Enables calculation of image textures (Haralick 1973) from grey-level co-occurrence matrices (GLCMs). Supports processing images that cannot fit in memory.

Build Status


The glcm package enables calculating image textures derived from grey-level co-occurrence matrics (GLCMs) in R. The texture calculation is coded in C++ to optimize computation time. The glcm function in the package can compute the following texture statistics: mean (using either of two definitions), variance (using either of two definitions), homogeneity, contrast, dissimilarity, entropy, second_moment, and, correlation. The window size, shift, and grey-level quantization are user determined. See the help file for glcm (included in the package) for details.

Package Installation

To install the latest stable version of glcm from CRAN, fire up R and run:


Installing glcm Development Version

If you want the very latest version of glcm, you can install the development version. Be aware this version might not install as it is not as well tested as the stable version.

NOTE: If you are installing on Windows, you will need to install the appropriate version of Rtools for your version of R (as glcm contains C++ code) before you follow the below steps.

The easiest way to install the development version of the glcm package is using the devtools package by Hadley Wickham. After installing devtools from CRAN, type:


Author Contact Information

Alex Zvoleff
Postdoctoral Associate
Tropical Ecology Assessment and Monitoring (TEAM) Network
Conservation International
2011 Crystal Dr. Suite 500
Arlington, VA 22202


glcm 1.6.4

  • Correct EPSG references to use lower case ('epsg') when defining CRS rather than upper case.

glcm 1.6.3

  • Add doi reference to DESCRIPTION file where methods for package are referenced.

  • Added executable example in glcm.Rd that doesn't require loading the raster package (which is not required).

  • Added an executable example in calc_texture.Rd.

glcm 1.6.2

  • Update for new r requirement of registration of symbols (added init.c).

  • Use https for CRAN urls in docs per CRAN requirements.

glcm 1.6

  • Docs for "glcm" stated that the default direction was 90 degrees. This is incorrect - the default is 45 degrees. Fixed docs accordingly.

  • Fix error that arose when handling large images due to usage of "stack" from wrong namespace in "glcm" function. Thanks to Wenjuan Shen, Dennis O. Ojwang', and others for reporting.

glcm 1.4

  • Fix handling of images small enough to process as a single block.

  • Fix case of very small final block.

  • Misc doc fixes and CRAN check fixes.

glcm 1.2

  • Fix abs usage in C++ code per Proj. Ripley's request.

glcm 1.0

  • Support calculation of average textures over multiple shifts (glcm in "all directions". Thanks to Matthias Weigand for testing.

  • Automatically process rasters block-by-block when cannot process in memory.
    Thanks to Santosh Bhandari for testing.

  • Upgrade to roxygen2 > 4.0.2.

  • Various minor doc fixes.

glcm 0.3.2

  • Fix proj4string for example image.

  • Upgrade to roxygen2 > 4.0.0.

glcm 0.3.1

  • Remove RcppArmadillo from imports in glcm.R (only list it in linking-to) per CRAN request.

glcm 0.3

  • Reformat tests for testthat >= 0.8.

  • Fix handling of window sizes other than 3 x 3 (issue #2).

  • Rename test image to end in 3x3_1x1 (as it was run with a 3x3 window size and 1 row x 1 column shift).

  • Add additional test cases.

  • Add additional validation of user input to "glcm" function.

  • Update website address.

  • Various fixes to docs.

glcm 0.2

  • Require Rcpp >= 0.11.0 (as Makevars and are no longer included in package).

  • Minor fixes to docs.

glcm 0.1

  • Initial release to CRAN.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.6.5 by Alex Zvoleff, 2 years ago

Report a bug at

Browse source code at

Authors: Alex Zvoleff [aut, cre]

Documentation:   PDF Manual  

GPL (>= 3) license

Imports raster, Rcpp

Suggests testthat

Linking to Rcpp, RcppArmadillo

See at CRAN