title: Numpy Detection of region borders
body: <p>Given a 1 dimensional array of Values:</p>
  
  <p>A = [x,..,x,0,..,0,x,..,x,0,..,0,x,..,x,........]</p>
  
  <p>where:</p>
  
  <p>x,..,x  stands for for an arbitrary number of arbitrary Values</p>
  
  <p>and</p>
  
  <p>0,..,0  stands for an arbitrary number of Zeros</p>
  
  <p>I need to find a fast algorithm to find the indices of the borders 
   i.e.: ..,x,0,.. and ..,0,x..</p>
  
  <p>This problem seems to lend itself to parallelization but that is beyond my experience simple looping over the array is to slow as the data is to big</p>
  
  <p>THX
  Martin</p>