title: Discrete Laplacian (del2 equivalent) in Python
body: <p>I need the Python / Numpy equivalent of Matlab (Octave) discrete Laplacian operator (function) del2(). I tried couple Python solutions, none of which seem to match the output of del2. On Octave I have</p>
  
  <pre><code>image = [3 4 6 7; 8 9 10 11; 12 13 14 15;16 17 18 19]
  del2(image)
  </code></pre>
  
  <p>this gives the result</p>
  
  <pre><code>   0.25000  -0.25000  -0.25000  -0.75000
    -0.25000  -0.25000   0.00000   0.00000
     0.00000   0.00000   0.00000   0.00000
     0.25000   0.25000   0.00000   0.00000
  </code></pre>
  
  <p>On Python I tried </p>
  
  <pre><code>import numpy as np
  from scipy import ndimage
  import scipy.ndimage.filters
  
  image =  np.array([[3, 4, 6, 7],[8, 9, 10, 11],[12, 13, 14, 15],[16, 17, 18, 19]])
  stencil = np.array([[0, 1, 0],[1, -4, 1], [0, 1, 0]])
  print ndimage.convolve(image, stencil, mode='wrap')
  </code></pre>
  
  <p>which gives the result</p>
  
  <pre><code>[[ 23  19  15  11]
   [  3  -1   0  -4]
   [  4   0   0  -4]
   [-13 -17 -16 -20]]
  </code></pre>
  
  <p>I also tried </p>
  
  <pre><code>scipy.ndimage.filters.laplace(image)
  </code></pre>
  
  <p>That gives the result</p>
  
  <pre><code>[[ 6  6  3  3]
   [ 0 -1  0 -1]
   [ 1  0  0 -1]
   [-3 -4 -4 -5]]
  </code></pre>
  
  <p>So none of the outputs seem to match eachother. Octave code del2.m suggests that it is a Laplacian operator. Am I missing something?</p>