OnWorks favicon

r.texturegrass - Online in the Cloud

Run r.texturegrass in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command r.texturegrass that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator



r.texture - Generate images with textural features from a raster map.


raster, algebra, statistics, texture


r.texture --help
r.texture [-sa] input=name output=basename [size=value] [distance=value]
[method=string[,string,...]] [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Separate output for each angle (0, 45, 90, 135)

Calculate all textural measurements

Allow output files to overwrite existing files

Print usage summary

Verbose module output

Quiet module output

Force launching GUI dialog

input=name [required]
Name of input raster map

output=basename [required]
Name for output basename raster map(s)

The size of moving window (odd and >= 3)
Default: 3

The distance between two samples (>= 1)
Default: 1

Textural measurement method
Options: asm, contrast, corr, var, idm, sa, se, sv, entr, dv, de, moc1, moc2


r.texture creates raster maps with textural features from a user-specified raster map
layer. The module calculates textural features based on spatial dependence matrices at 0,
45, 90, and 135 degrees for a distance (default = 1).

r.texture assumes grey levels ranging from 0 to 255 as input. The input is automatically
rescaled to 0 to 255 if the input map range is outside of this range.

In general, several variables constitute texture: differences in grey level values,
coarseness as scale of grey level differences, presence or lack of directionality and
regular patterns. A texture can be characterized by tone (grey level intensity properties)
and structure (spatial relationships). Since textures are highly scale dependent,
hierarchical textures may occur.

r.texture reads a GRASS raster map as input and calculates textural features based on
spatial dependence matrices for north-south, east-west, northwest, and southwest
directions using a side by side neighborhood (i.e., a distance of 1), and writes out by
default the average over all angles for each measure. Optionally, using flag -s the output
consists of four images for each textural feature, one for every direction (0, 45, 90,

The user must carefully set the resolution (using g.region) before running this program,
or the computer may run out of memory.

A commonly used texture model is based on the so-called grey level co-occurrence matrix.
This matrix is a two-dimensional histogram of grey levels for a pair of pixels which are
separated by a fixed spatial relationship. The matrix approximates the joint probability
distribution of a pair of pixels. Several texture measures are directly computed from the
grey level co-occurrence matrix.

The following part offers brief explanations of texture measures (after Jensen 1996).

First-order statistics in the spatial domain
· Sum Average (SA)

· Entropy (ENT): This measure analyses the randomness. It is high when the values of
the moving window have similar values. It is low when the values are close to
either 0 or 1 (i.e. when the pixels in the local window are uniform).

· Difference Entropy (DE)

· Sum Entropy (SE)

· Variance (VAR): A measure of gray tone variance within the moving window
(second-order moment about the mean)

· Difference Variance (DV)

· Sum Variance (SV)
Note that measures "mean", "kurtosis", "range", "skewness", and "standard deviation" are
available in r.neighbors.

Second-order statistics in the spatial domain
The second-order statistics texture model is based on the so-called grey level
co-occurrence matrices (GLCM; after Haralick 1979).

· Angular Second Moment (ASM, also called Uniformity): This is a measure of local
homogeneity and the opposite of Entropy. High values of ASM occur when the pixels
in the moving window are very similar.
Note: The square root of the ASM is sometimes used as a texture measure, and is
called Energy.

· Inverse Difference Moment (IDM, also called Homogeneity): This measure relates
inversely to the contrast measure. It is a direct measure of the local homogeneity
of a digital image. Low values are associated with low homogeneity and vice versa.

· Contrast (CON): This measure analyses the image contrast (locally gray-level
variations) as the linear dependency of grey levels of neighboring pixels
(similarity). Typically high, when the scale of local texture is larger than the

· Correlation (COR): This measure analyses the linear dependency of grey levels of
neighboring pixels. Typically high, when the scale of local texture is larger than
the distance.

· Information Measures of Correlation (MOC)

· Maximal Correlation Coefficient (MCC)


Importantly, the input raster map cannot have more than 255 categories.


Calculation of Angular Second Moment of B/W orthophoto (North Carolina data set):
g.region raster=ortho_2001_t792_1m -p
# set grey level color table 0% black 100% white
r.colors ortho_2001_t792_1m color=grey
# extract grey levels
r.mapcalc "ortho_2001_t792_1m.greylevel = ortho_2001_t792_1m"
# texture analysis
r.texture ortho_2001_t792_1m.greylevel prefix=ortho_texture method=asm -s
# display
g.region n=221461 s=221094 w=638279 e=638694
d.shade color=ortho_texture_ASM_0 shade=ortho_2001_t792_1m
This calculates four maps (requested texture at four orientations): ortho_texture_ASM_0,
ortho_texture_ASM_45, ortho_texture_ASM_90, ortho_texture_ASM_135.


The program can run incredibly slow for large raster maps.


The algorithm was implemented after Haralick et al., 1973 and 1979.

The code was taken by permission from pgmtexture, part of PBMPLUS (Copyright 1991, Jef
Poskanser and Texas Agricultural Experiment Station, employer for hire of James Darrell
McCauley). Manual page of pgmtexture.

· Haralick, R.M., K. Shanmugam, and I. Dinstein (1973). Textural features for image
classification. IEEE Transactions on Systems, Man, and Cybernetics,

· Bouman, C. A., Shapiro, M. (1994). A Multiscale Random Field Model for Bayesian
Image Segmentation, IEEE Trans. on Image Processing, vol. 3, no. 2.

· Jensen, J.R. (1996). Introductory digital image processing. Prentice Hall. ISBN

· Haralick, R. (May 1979). Statistical and structural approaches to texture,
Proceedings of the IEEE, vol. 67, No.5, pp. 786-804

· Hall-Beyer, M. (2007). The GLCM Tutorial Home Page (Grey-Level Co-occurrence
Matrix texture measurements). University of Calgary, Canada

Use r.texturegrass online using onworks.net services

Free Servers & Workstations

Download Windows & Linux apps

  • 1
    Boost C++ Libraries
    Boost C++ Libraries
    Boost provides free portable
    peer-reviewed C++ libraries. The
    emphasis is on portable libraries which
    work well with the C++ Standard Library.
    See http://www.bo...
    Download Boost C++ Libraries
  • 2
    VirtualGL redirects 3D commands from a
    Unix/Linux OpenGL application onto a
    server-side GPU and converts the
    rendered 3D images into a video stream
    with which ...
    Download VirtualGL
  • 3
    Library to enable user space
    application programs to communicate with
    USB devices. Audience: Developers, End
    Users/Desktop. Programming Language: C.
    Download libusb
  • 4
    SWIG is a software development tool
    that connects programs written in C and
    C++ with a variety of high-level
    programming languages. SWIG is used with
    Download SWIG
  • 5
    WooCommerce Nextjs React Theme
    WooCommerce Nextjs React Theme
    React WooCommerce theme, built with
    Next JS, Webpack, Babel, Node, and
    Express, using GraphQL and Apollo
    Client. WooCommerce Store in React(
    contains: Products...
    Download WooCommerce Nextjs React Theme
  • 6
    Package repo for ArchLabs This is an
    application that can also be fetched
    It has been hosted in OnWorks in...
    Download archlabs_repo
  • More »

Linux commands