r.texture(1)
π r.texture(1) β GRASS GIS User's Manual π
okay bestie, settle in, because this one is a whole personality. it's r.texture from the GRASS GIS User's Manual, and it's about to make your raster maps look absolutely textured β¨
β¨ NAME β¨
r.texture β generate images with textural features from a raster map. that's it, that's the whole job, and it ate. π
πΈ KEYWORDS πΈ
raster, algebra, statistics, texture
π¦ SYNOPSIS π¦
r.texture
r.texture --help
r.texture [-san] input=name output=basename [size=value]
[distance=value] [method=string[,string,...]] [--overwrite]
[--help] [--verbose] [--quiet] [--ui]
π Flags
-sβ separate output for each angle (0, 45, 90, 135). and just so we're clear, angles are counterclockwise from east: 0 is East to West, 45 is North-East to South-West. it's giving compass but make it fashion π§-aβ calculate all textural measurements. go big or go home, no notes.-nβ allow NULL cells in a moving window. this will also avoid cropping along edges of the current region. lowkey a glow-up for your edges π--overwriteβ allow output files to overwrite existing files (yes, it will absolutely replace them, be normal about it)--helpβ print usage summary--verboseβ verbose module output (it will tell you everything, main character energy)--quietβ quiet module output--uiβ force launching GUI dialog
π Parameters
input=name[required] β name of input raster mapoutput=basename[required] β name for output basename raster map(s)size=valueβ the size of moving window (odd and >= 3). Default:3distance=valueβ the distance between two samples (>= 1). the distance must be smaller than the size of the moving window. Default:1method=string[,string,...]β textural measurement method. Options:asm,contrast,corr,var,idm,sa,sv,se,entr,dv,de,moc1,moc2
π DESCRIPTION π
so. r.texture creates raster maps with textural features from a raster map layer that you specify. the module calculates textural features based on spatial dependence matrices at 0, 45, 90, and 135 degrees. four angles, four vibes, one iconic output β¨
now, because texture is a scale thing (we love a scale-dependent queen), r.texture lets you define the size of the moving window and the distance at which to compare pixel grey values. by default the module averages the results over the 4 orientations β but bestie, if you want the texture variables in 4 different orientations, just hit flag -s and it's yours. π
quick reminder on the angles, because this trips everyone: angles are defined in degrees of east and they increase counterclockwise, so0is East - West,45is North-East - South-West,90is North - South,135is North-West - South-East. memorise it, it's giving geometry homework but cuter π§
you can either choose one or several texture measures (descriptions below, keep reading, they're right there) using the method parameter, or you can request the creation of maps for all available methods with the -a flag. dealer's choice, babes.
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. and to reduce noise in the input data (which generally reinforces the textural features, slay) and to speed up processing, it's recommended that you recode the data using equal-probability quantization. quantization rules for r.recode can be generated with r.quantile -r using e.g 16 or 32 quantiles (there's an example below). π«Ά
π NOTES π
texture is a feature of specific land cover classes in satellite imagery. it's especially useful when the spectral differences between classes are small but the classes are still distinguishable by how they're organised on the ground β often natural vs human-made spaces, like cultivated fields vs meadows or golf courses, palm tree plantations vs natural rain forest. but texture can also be a natural phenomenon: dune fields, different canopies due to different tree species. honestly, range. π
the usefulness and use of texture is highly dependent on the resolution of satellite imagery and on the scale of the human intervention or the phenomenon that created the texture (there's also a discussion of scale dependency below, iykyk). you should observe the phenomenon visually in order to determine an adequate setting of the size parameter. yes, actually look at your data. it's a vibe check for your raster. π
the output of r.texture can be very useful additional variables as input for image classification or image segmentation (object recognition). it can be used in supervised classification algorithms such as i.maxlik or i.smap, or for the identification of objects in i.segment, and/or for the characterization of these objects β and thus, for example, as one of the raster inputs of the i.segment.stats addon. so many glow-ups, so little time. π₯
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). and since textures are highly scale dependent, hierarchical textures may occur. it's layers, bestie, always layers. π§
r.texture uses the common texture model based on the so-called grey level co-occurrence matrix, as described by Haralick et al (1973). 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 (GLCM). the provided measures can be categorized under first-order and second-order statistics, with each playing a unique role in texture analysis. first-order statistics consider the distribution of individual pixel values without regard to spatial relationships, while second-order statistics β particularly those derived from the Grey Level Co-occurrence Matrix (GLCM) β consider the spatial relationship of pixels. two orders, two eras, both iconic. β¨
the following part offers brief explanations of the Haralick et al texture measures (after Jensen 1996). π
π First-order statistics in the spatial domain
- Sum Average (SA) β Sum Average measures the average gray level intensity of the sum of pixel pairs within the moving window. it reflects the average intensity of pixel pairs at specific distances and orientations, highlighting the overall brightness level within the area. basically: how bright are we, on average? β
- 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
0or1(i.e. when the pixels in the local window are uniform). chaos vs calm, the eternal battle π - Difference Entropy (DE) β this metric quantifies the randomness or unpredictability in the distribution of differences between the grey levels of pixel pairs. it's a measure of the entropy of the pixel-pair difference histogram, capturing texture granularity. granularity!! like a sugar scrub for your data π
- Sum Entropy (SE) β similar to Difference Entropy, Sum Entropy measures the randomness or unpredictability, but in the context of the sum of the grey levels of pixel pairs. it evaluates the entropy of the pixel-pair sum distribution, providing insight into the complexity of texture in terms of intensity variation.
- Variance (VAR) β a measure of gray tone variance within the moving window (second-order moment about the mean). math said "spread" and meant it π
- Difference Variance (DV) β this is a measure of the variance or spread of the differences in grey levels between pairs of pixels within the moving window. it quantifies the contrast variability between pixels, indicating texture smoothness or roughness. smooth or rough, pick a lane (or don't, it's fine).
- Sum Variance (SV) β in contrast to Difference Variance, Sum Variance measures the variance of the sum of grey levels of pixel pairs. it assesses the variability in the intensity levels of pairs of pixels, contributing to an understanding of texture brightness or intensity variation. it's the mirror twin, the twin flame, the β¨contrastβ¨
note that measures "mean", "kurtosis", "range", "skewness", and "standard deviation" are available inr.neighbors. so if you were looking for those hereβ¦ they're not here. they're atr.neighbors. go say hi. π
π¦ 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). okay now we're in the advanced part, keep up bestie π
- 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. cute nickname, honestly. β‘
- 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. the way it's just contrast's oppositeβ¦ π
- 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 distance.
- 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. yes it's basically the same sentence as CON up there, and no I will not be editing it, that's what the manual says π«Ά
- Information Measures of Correlation (MOC) β these measures evaluate the complexity of the texture in terms of the mutual dependence between the grey levels of pixel pairs. they quantify how one pixel value informs or correlates with another, offering insight into pattern predictability and structure regularity. it's giving "tell me about your neighbour without telling me about your neighbour" π
- Maximal Correlation Coefficient (MCC) β this statistic measures the highest correlation between any two features of the texture, providing a single value that summarizes the degree of linear dependency between grey levels in the texture. it's often used to assess the overall correlation in the image, indicating how predictable the texture patterns are from one pixel to the next. one number, whole story, main character energy π
the computational region should be set to the input map with g.region raster=<input map>, or aligned to the input map with g.region align=<input map> if only a subregion should be analyzed.
β οΈ important, bestie: note that the output of r.texture will always be smaller than the current region, as only cells for which there are no null cells and for which all cells of the moving window are within the current region will contain a value. the output will thus appear cropped at the margins. no, you didn't break it. yes, that's just how it is. π
π¨ also important: importantly, the input raster map cannot have more than 255 categories. that's the limit, that's the vibe, don't test it. π
β¨ EXAMPLE β¨
Okay bestie, let's get into the fun part β actual runs π First up: calculating the Angular Second Moment of a B/W orthophoto (North Carolina data set, iconic):
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 output=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
So this one calculates four maps β the requested texture at four orientations, no cap: ortho_texture_ASM_0, ortho_texture_ASM_45, ortho_texture_ASM_90, ortho_texture_ASM_135. β¨
Now, reducing the number of gray levels (aka equal-probability quantizing π):
g.region -p raster=ortho_2001_t792_1m
# enter as one line or with \
r.quantile input=ortho_2001_t792_1m quantiles=16 -r | r.recode \
input=ortho_2001_t792_1m output=ortho_2001_t792_1m_q16 rules=-
The recoded raster map can then be used as input for r.texture as before. Easy peasy π
Second example, bestie: analysis of IDM (homogeneity) on a simple raster with a North-South line pattern. Let's go π€
# import raster
r.in.ascii in=- output=lines << EOF
north: 9
south: 0
east: 9
west: 0
rows: 9
cols: 9
0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1 0
EOF
# adjust region to raster
g.region raster=lines
# calculate IDM (homogeneity) in all directions
r.texture -s lines method=idm output=text_lines
The following image shows the original map, the result in East-West direction and the result in North-South direction β showing how texture can depend on direction, with texture perfectly homogeneous (value=1) in the North-South direction, but quite heterogeneous in East-West direction, except for those areas where there are three columns of equal values (as size=3). The overlaid grid highlights that the texture measures output maps are cropped at the margins. π₯
IDM textures according to direction
π KNOWN ISSUES π
The program can run incredibly slow for large raster maps and large moving windows (size option). Like, not me waiting forever for a giant raster to finish... π
π REFERENCES π
The algorithm was implemented after Haralick et al., 1973 and 1979.
The original 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. Over the years, the source code of r.texture was further improved.
- Haralick, R.M., K. Shanmugam, and I. Dinstein (1973). Textural features for image classification. IEEE Transactions on Systems, Man, and Cybernetics, SMC-3(6):610-621.
- 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 0-13-205840-5
- 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
π SEE ALSO π
i.maxlik, i.gensig, i.smap, i.gensigset, i.segment.stats, i.pca, r.neighbors, r.rescale
π AUTHORS π
- G. Antoniol - RCOST (Research Centre on Software Technology - Viale Traiano - 82100 Benevento)
- C. Basco - RCOST (Research Centre on Software Technology - Viale Traiano - 82100 Benevento)
- M. Ceccarelli - Facolta di Scienze, Universita del Sannio, Benevento
- Markus Metz (correction and optimization of the initial version)
- Moritz Lennert (documentation)
π SOURCE CODE π
Available at: r.texture source code (history)
Accessed: Saturday Jan 17 05:41:03 2026
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
And that's the whole page, bestie π«Ά this manual is from GRASS GIS 8.4.2 and the source/version line at the bottom says exactly that β GRASS 8.4.2 with r.texture(1) β and the access date was Saturday Jan 17 05:41:03 2026. Slay β¨π
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms