def binary_closing(input, structure=None, iterations=1, output=None, origin=0):
 input = numpy.asarray(input)
 if (structure is None):
  rank = input.ndim
  structure = generate_binary_structure(rank, 1)
 tmp = binary_dilation(input, structure, iterations, None, None, 0, origin)
 return binary_erosion(tmp, structure, iterations, None, output, 0, origin)

def binary_closing ( input , structure = None , iterations = 1 , output = None , origin = 0 ) : input = numpy . asarray ( input ) if ( structure is None ) : rank = input . ndim structure = generate_binary_structure ( rank , 1 ) tmp = binary_dilation ( input , structure , iterations , None , None , 0 , origin ) return binary_erosion ( tmp , structure , iterations , None , output , 0 , origin )
return fast binary morphological closing of an image .