This R-code serves as a practical complement to our paper, "Lacunarity exponent and Moran index: A complementary methodology to analyze AFM images and its application to chitosan films".
The Global moran index, GMI, is a two-dimensional extension of Pearson’s linear correlation coefficient for quantifying spatial autocorrelation in matrices [1]. Mathematically, it reads,
where 𝑤_𝑖𝑗 is the spatial weights matrix; ℎ_𝑖 is the value of the variable (e.g. heights) at location 𝑖, while ̄ℎ and 𝜎² are the mean and variance of the ℎ, respectively. The GMI ranges from −1 to 1, provided the weights are normalized. We use the neighborhood queen-type contiguity based on the eight nearest neighbors. We also provide a test matrix with a random height distribution for validation. The expected GMI for a completely random surface is zero, indicating the absence of spatial autocorrelation. Below, we present an illustration of the control panel in the RStudio interface.
The only input data are the image matrix (txt format) and its side length "L", which must be an integer. The main output data are: the reconstructed image, the link histogram, the Moran scatter plot, and the Moran correlogram (Moran's index versus lags). The number of "lags" in the correlogram and the type of neighborhood contiguity can also be adjusted as needed.
References
[1] A. Cliff, J. Ord, Spatial autocorrelation, 1981.