## calculate contrast of arbitrary GLCM
# define arbitrary GLCM
x <- matrix(1:16, nrow = 4)
# normalize
n_x <- normalize_glcm(x)
# calculate contrast
contrast(n_x)
# calculate contrast of fitness landscape, assuming 2 discrete gray levels
vals <- runif(64)
vals <- array(vals, dim = rep(4, 3))
my_landscape <- fitscape::FitLandDF(vals)
my_glcm <- get_comatrix(my_landscape, discrete = equal_discrete(2))
contrast(my_landscape, nlevels = 2)
## confirm value of contrast for fitness landscape
# extract normalized GLCM from fitness landscape
contrast(my_glcm) # should match value of above contrast function call
Run the code above in your browser using DataLab