title: How does Opencv MedianBlur actually work?
body: <p>I've been working with a grayscale image that has a lot of Salt and Pepper noise and came to know that MedianBlur is very useful. So I used the Python version of Opencv(<code>cv2.medianBlur()</code>). It worked but didn't work in the way I wanted. So I was looking for the actual algorithm it worked on and got the following explanation:</p>
  
  <p>If you have a kernel size(k) of 5, then for every 5(row count)x5(column count) square window, the central pixel of this window will get replaced by the Median value of all the elements in it. So, for instance, consider this window:</p>
  
  <pre><code>      [[11,  4, 17,  1,  5],
         [ 6, 14,  0, 12, 16],
         [24, 19, 13, 18, 23],
         [ 7, 11, 11, 10,  5],
         [10, 13, 23,  3,  0]] 
  </code></pre>
  
  <p>Here, the central element, 13 will get replaced by the Median of all these elements, i.e. 11. Is this correct? If yes, what happens to the first 2 rows, since there can't be elements in the first two rows which are the central element for ANY window? As per my observation(comparing the original and processed image), the first two rows change too.</p>