Median filter problems about the output image
To give you a hint, here is how you can do this calculation with a PC, to check your assumptions:

import cv2
import numpy as np
import matplotlib.pyplot as plt
N = 8
n = 5
n12 = (n-1)/2

I = np.ones((N,N), dtype=np.uint8)
I[2:(2+n12),2:(2+n12)] = 0

I2 = cv2.medianBlur(I, n)

print "Input image:"
print I
print 
print "Output image"
print I2


The program output is:

Input image:
[[1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 0 0 1 1 1 1]
 [1 1 0 0 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]]

Output image
[[1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]
 [1 1 1 1 1 1 1 1]]


So, the median filter completely removes the dark area. Now, it's up to you to understand how the median filter works and why its completely removing the dark area. You can ask specific questions, on what is your problem now.