I have an NxNxN matrix the elements of which is either zero or one. For example in the 2x2x2 case,
I am trying to group the neighbouring elements which are '1'. For the matrix above
N(1,1,1) and N(2,2,2) are nonzero and they are the neighbor of each other. So the output should be two distinct matrices, the first matrix should carry the indices (1,1,1) and the second matrix (2,2,2).
Does anyone know of an algorithm which carries out this operation?