Description Usage Arguments Details Value References Examples
This function supports calculating texture statistics derived from grey-level co-occurrence matrices (GLCMs). The default textures are calculated using a 45 degree shift. See Details for other options.
1 2 3 4 |
x |
a |
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 list or matrix specifying the shift to use. See Details. |
statistics |
A list of GLCM texture measures to calculate (see Details). |
min_x |
minimum value of input |
max_x |
maximum value of input |
na_opt |
How to handle NA values in |
na_val |
the value to use to fill NA values on edges of |
scale_factor |
factor by which to multiply results. Useful if rounding
results to integers (see |
asinteger |
whether to round results to nearest integer. Can be used to
save space by saving results as, for example, an 'INT2S' |
The statistics
parameter should be a list, and can include any (one
or more) of the following: 'mean', 'mean_ENVI', 'variance', 'variance_ENVI',
'homogeneity', 'contrast', 'dissimilarity', 'entropy', 'second_moment',
and/or 'correlation'. By default all of the statistics except for
"mean_ENVI" and "variance_ENVI" will be returned .
shift
can be one of:
a two element integer vector giving the shift (Q in Gonzalez and Woods, 2008), as (number of rows, number of columns).
a list of integer vectors of length 2 specifying multiple (row, col)
shifts over which to calculate the GLCM textures. For example:
shift=list(c(1,1), c(-1,-1))
a matrix with two columns specifying, in rows, multiple (row, col)
shifts over which to calculate the GLCM textures. For example:
shift=matrix(c(1,1,-1,-1), byrow=TRUE, ncol=2)
If multiple shifts are supplied, glcm
will calculate each texture
statistic using all the specified shifts, and return the mean value of the
texture for each pixel. To calculate GLCM textures over "all directions" (in
the terminology of commonly used remote sensing software), use:
shift=list(c(0,1), c(1,1), c(1,0), c(1,-1))
. This will calculate the
average GLCM texture using shifts of 0 degrees, 45 degrees,
90 degrees, and 135 degrees.
A RasterLayer
or RasterStack
with the requested GLCM
texture measures.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Calculate GLCM textures on a matrix
d <- matrix(seq(1:25), nrow=5, ncol=5, byrow=TRUE)
# Calculate using default 90 degree shift
glcm(d, statistics=c('variance'))
# Calculate over all directions
glcm(d, shift=list(c(0,1), c(1,1), c(1,0), c(1,-1)),
statistics=c('variance'))
## Not run:
# Calculate GLCM textures on a raster
require(raster)
# Calculate using default 90 degree shift
textures_shift1 <- glcm(raster(L5TSR_1986, layer=1))
plot(textures_shift1)
# Calculate over all directions
textures_all_dir <- glcm(raster(L5TSR_1986, layer=1),
shift=list(c(0,1), c(1,1), c(1,0), c(1,-1)))
plot(textures_all_dir)
## End(Not run)
|
, , glcm_variance
[,1] [,2] [,3] [,4] [,5]
[1,] NA NA NA NA NA
[2,] NA 99.29557 122.3303 NA NA
[3,] NA 247.83724 287.6116 NA NA
[4,] NA NA NA NA NA
[5,] NA NA NA NA NA
, , glcm_variance
[,1] [,2] [,3] [,4] [,5]
[1,] NA NA NA NA NA
[2,] NA NA 123.1304 NA NA
[3,] NA NA 288.9082 NA NA
[4,] NA NA NA NA NA
[5,] NA NA NA NA NA
Loading required package: raster
Loading required package: sp
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.