title: What does scipy.signal.convolve2d calculate?
body: <p>I am currently a bit confused by the output of</p>
  
  <pre><code>#!/usr/bin/env python
  
  import scipy.signal
  
  image = [[1, 2, 3, 4, 5, 6, 7],
           [8, 9, 10, 11, 12, 13, 14],
           [15, 16, 17, 18, 19, 20, 21],
           [22, 23, 24, 25, 26, 27, 28],
           [29, 30, 31, 32, 33, 34, 35],
           [36, 37, 38, 39, 40, 41, 42],
           [43, 44, 45, 46, 47, 48, 49]]
  
  filter_kernel = [[-1, 1, -1],
                   [-2, 3, 1],
                   [2, -6, 0]]
  
  res = scipy.signal.convolve2d(image, filter_kernel,
                                mode='same', boundary='fill', fillvalue=0)
  print(res)
  </code></pre>
  
  <p>It was</p>
  
  <pre><code>[[  -2   -8   -7   -6   -5   -4   28]
   [   3   -7  -10  -13  -16  -19   14]
   [ -18  -28  -31  -34  -37  -40    0]
   [ -39  -49  -52  -55  -58  -61  -14]
   [ -60  -70  -73  -76  -79  -82  -28]
   [ -81  -91  -94  -97 -100 -103  -42]
   [-101  -61  -63  -65  -67  -69  -57]]
  </code></pre>
  
  <p>I expected the top left element to be <code>3*1 + 1*2 + (-6) *8 + 0*9 = -43</code> (ommitting the padded zeros).</p>
  
  <p>I thought this would expand the matrix image \in R^{7x7} to R^{9x9} by adding one 0 to the left / right and top / bottom. Then I thought the <code>filter_kernel</code> would be calculated by "sliding" it over the <code>image</code>. At each position, the numbers from the image are point-wise multiplied with the numbers from the kernel. The nine products are the summed up and written into <code>res</code>.</p>
  
  <p>However, it is <code>-2</code>. Obviously, something different happens.</p>