def white_tophat(input, size=None, footprint=None, structure=None, output=None, mode='reflect', cval=0.0, origin=0):
 tmp = grey_erosion(input, size, footprint, structure, None, mode, cval, origin)
 if isinstance(output, numpy.ndarray):
  grey_dilation(tmp, size, footprint, structure, output, mode, cval, origin)
  return numpy.subtract(input, output, output)
 else:
  tmp = grey_dilation(tmp, size, footprint, structure, None, mode, cval, origin)
  return (input - tmp)

def white_tophat ( input , size = None , footprint = None , structure = None , output = None , mode = 'reflect' , cval = 0.0 , origin = 0 ) : tmp = grey_erosion ( input , size , footprint , structure , None , mode , cval , origin ) if isinstance ( output , numpy . ndarray ) : grey_dilation ( tmp , size , footprint , structure , output , mode , cval , origin ) return numpy . subtract ( input , output , output ) else : tmp = grey_dilation ( tmp , size , footprint , structure , None , mode , cval , origin ) return ( input - tmp )
return white top hat of an image .