data(forestgap)
rmat <- matrix(rnorm(100) > .1, ncol = 10)
display_matrix(label(rmat))
# With 8-way neighborhood mask and no wrapping around borders
display_matrix(label(rmat, "moore", wrap = FALSE))
# On real data:
display_matrix(label(forestgap[[5]], "moore", wrap = FALSE))
Run the code above in your browser using DataLab