Image texture in R
In this post I will show you how to calculate image texture in R. These textures have been used to model diversity and structural attributes of different forests with intermediate to very high R^2 values. Image textures are metrics that summarise the pixel’s tone variability in neighboring pixels using a particular window size. Thus, most of these metrics can be thought of variables sensing tone heterogeneity (or homogeneity) in space.
Image data
First we will create some dummy data just to make everything reproducible.
Here’s a preview of the dummy image: imgR.
FOTO
Fourier transformed ordination is a method to calculate image texture that first uses the Fourier transform to summarise the spatial variation using harmonic waves (similar to sin and cos functions). Then, it applies a principal components analysis (PCA) over the previous data and usually works with the first three. Then, the PCA scores of the images are used as independent variables to model the forest attributes (usually measured in-field).
After doing these steps, you will get an object containing three entries: 1) zones, 2) radial spectra and 3) rgb. The first one contains the zones in which the image was divided to calculate the FOTO, the second one contains the radial spectra of the FOTO and finally, the third one contains the three first PCA components. The latter one, the PCA image, contains the information to model the forest’s attributes, so that image is the one that is going to be exported as raster.
Here’s a preview of the FOTO image.
GLCM
Gray level co-ocurrence matrix texture is another apporach to calculate image texture. In this approach, the spatial heterogeneity is summarised by eight possible metrics: mean, variance, homogeneity, dissimilarity, contrast, entropy, asymptotic second moment and correlation. Each metric summarises a differnt aspect of image texture. The used approach will calculate these textures in the four possible directions (0°, 45°, 90° and 135 °) from a focal pixel. The other possible directions (180° - 360°) are mirrors of the previous directions. Then, the metrics calculated for each direction are averaged to obtain a single directionless metric.
Here’s a preview of the GLCM image.