title: How to go through the elements of a matrix, layer by layer
body: <p>It is difficult to explain what I want. Lets say I have a matrix of 0 and 1</p>
  
  <p>000000<br>
  000000<br>
  001100<br>
  000000<br>
  000000   </p>
  
  <p>I want to start from a certain group of ones (this is given in the beginning, and then I want to go outwards.</p>
  
  <p>000000,,,,,,,  000000<br>
  011110 OR 001100<br>
  010010,,,,,,,    010010<br>
  011110,,,,,,,    001100<br>
  000000,,,,,,,    000000   </p>
  
  <p>The difference is not important, as long as I will go through everything, outwards.</p>
  
  <p>The reason I want to do this is, this matrix of 1 and 0 corresponds to a matrix of some 2D function, and I want to examine the points in that function going outwards. I want to </p>