def medfilt(volume, kernel_size=None):
 volume = atleast_1d(volume)
 if (kernel_size is None):
  kernel_size = ([3] * volume.ndim)
 kernel_size = asarray(kernel_size)
 if (kernel_size.shape == ()):
  kernel_size = np.repeat(kernel_size.item(), volume.ndim)
 for k in range(volume.ndim):
  if ((kernel_size[k] % 2) != 1):
   raise ValueError('Each element of kernel_size should be odd.')
 domain = ones(kernel_size)
 numels = product(kernel_size, axis=0)
 order = (numels // 2)
 return sigtools._order_filterND(volume, domain, order)

def medfilt ( volume , kernel_size = None ) : volume = atleast_1d ( volume ) if ( kernel_size is None ) : kernel_size = ( [ 3 ] * volume . ndim ) kernel_size = asarray ( kernel_size ) if ( kernel_size . shape == ( ) ) : kernel_size = np . repeat ( kernel_size . item ( ) , volume . ndim ) for k in range ( volume . ndim ) : if ( ( kernel_size [ k ] % 2 ) != 1 ) : raise ValueError ( 'Each element of kernel_size should be odd.' ) domain = ones ( kernel_size ) numels = product ( kernel_size , axis = 0 ) order = ( numels // 2 ) return sigtools . _order_filterND ( volume , domain , order )
perform a median filter on an n-dimensional array .