def medfilt2d(input, kernel_size=3):
 image = asarray(input)
 if (kernel_size is None):
  kernel_size = ([3] * 2)
 kernel_size = asarray(kernel_size)
 if (kernel_size.shape == ()):
  kernel_size = np.repeat(kernel_size.item(), 2)
 for size in kernel_size:
  if ((size % 2) != 1):
   raise ValueError('Each element of kernel_size should be odd.')
 return sigtools._medfilt2d(image, kernel_size)

def medfilt2d ( input , kernel_size = 3 ) : image = asarray ( input ) if ( kernel_size is None ) : kernel_size = ( [ 3 ] * 2 ) kernel_size = asarray ( kernel_size ) if ( kernel_size . shape == ( ) ) : kernel_size = np . repeat ( kernel_size . item ( ) , 2 ) for size in kernel_size : if ( ( size % 2 ) != 1 ) : raise ValueError ( 'Each element of kernel_size should be odd.' ) return sigtools . _medfilt2d ( image , kernel_size )
median filter a 2-dimensional array .