title: How exactly does the "reflect" mode for scipys ndimage filters work?
body: <p>I'm failing to understand exactly how the reflect mode handles my arrays. I have this very simple array:</p>
  
  <pre><code>import numpy as np
  from scipy.ndimage.filters import uniform_filter
  from scipy.ndimage.filters import median_filter
  
  vector = np.array([[1.0,1.0,1.0,1.0,1.0],[2.0,2.0,2.0,2.0,2.0],[4.0,4.0,4.0,4.0,4.0],[5.0,5.0,5.0,5.0,5.0]])
  
  print(vector)
  </code></pre>
  
  <p>[[ 1.  1.  1.  1.  1.]
   [ 2.  2.  2.  2.  2.]
   [ 4.  4.  4.  4.  4.]
   [ 5.  5.  5.  5.  5.]]</p>
  
  <p>Applying a uniform (mean) filter with a window size of 3 I get the following:</p>
  
  <pre><code>filtered = uniform_filter(vector, 3, mode='reflect')
  
  print(filtered)
  </code></pre>
  
  <p>[[ 1.33333333  1.33333333  1.33333333  1.33333333  1.33333333]
   [ 2.33333333  2.33333333  2.33333333  2.33333333  2.33333333]
   [ 3.66666667  3.66666667  3.66666667  3.66666667  3.66666667]
   [ 4.66666667  4.66666667  4.66666667  4.66666667  4.66666667]]</p>
  
  <p>If I try to replicate the exercise by hand I can get to this result. Original matrix in green, window in orange and result in yellow. White are "reflected" observations.</p>
  
  <p><img src="https://i.stack.imgur.com/rcOIE.png" alt="enter image description here"></p>
  
  <p>Result is:</p>
  
  <p><img src="https://i.stack.imgur.com/EWj1d.png" alt="enter image description here"></p>
  
  <p>But when I try a window size of 4 or 5 I fail to be able to replicate the results.</p>
  
  <pre><code>filtered = uniform_filter(vector, 4, mode='reflect')
  
  print(filtered)
  </code></pre>
  
  <p>[[ 1.5  1.5  1.5  1.5  1.5]
   [ 2.   2.   2.   2.   2. ]
   [ 3.   3.   3.   3.   3. ]
   [ 4.   4.   4.   4.   4. ]]</p>
  
  <p>Doing it by hand:</p>
  
  <p><img src="https://i.stack.imgur.com/dGMz8.png" alt="enter image description here"></p>
  
  <p>And I get:</p>
  
  <p><img src="https://i.stack.imgur.com/VIm73.png" alt="enter image description here"></p>
  
  <p>How is the window handled if its size is even? But anyway, If I try to replicate the results of a window of size 5 and mode reflect I cant either. Even though I would think the behavior is analogous to that of size 3.</p>