Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirrored shifts don't produce equivalent results #11

Open
ailich opened this issue Feb 5, 2022 · 0 comments
Open

Mirrored shifts don't produce equivalent results #11

ailich opened this issue Feb 5, 2022 · 0 comments

Comments

@ailich
Copy link

ailich commented Feb 5, 2022

The documentation states states that "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." However, I believe that is only true if the GLCM is constructed in a symmetric way (that is why ENVI averages over 8 directions). For example, if a symmetric GLCM is used, I'd expect a 45 degree shift and a 225 degree shift should produce equivalent results but I get different results. Additionally, this introduces some ambiguity to mean and variance (as well as correlation which is calculated using mean and variance) as there is µi and µj for mean and σi and σj for the variance (these are equivalent in a symmetric GLCM; see formulas in the Hall-Beyer texture tutorial).

library(raster)
library(terra)
library(glcm)

r<- raster(rast(volcano, extent= ext(2667400, 2667400 + ncol(volcano)*10, 6478700, 6478700 + nrow(volcano)*10), crs = "EPSG:27200"))

t1a<- glcm(r, statistics=c("mean", "variance", "homogeneity", "contrast", "dissimilarity", "entropy", "second_moment", "correlation"), n_grey= 32, window =c(3,3), shift= c(1, 1), na_opt = "any") #45 degree shift

t1b<- glcm(r, statistics=c("mean", "variance", "homogeneity", "contrast", "dissimilarity", "entropy", "second_moment", "correlation"), n_grey= 32, window =c(3,3), shift= c(-1, -1), na_opt = "any") #225 degree shift

plot(t1a-t1b) #ab diff

148693550-b710ebe8-27b9-4a18-bf55-bcf4b5d6def2

@ailich ailich changed the title Mirrored shifts don't poduce equivalent results Mirrored shifts don't produce equivalent results Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant