The closing of an input image by a structuring element is the
erosion of the dilation of the image by the structuring element.

Parameters :

input : array_like

Binary array_like to be closed. Non-zero (True) elements form
the subset to be closed.

structure : array_like, optional

Structuring element used for the closing. Non-zero elements are
considered True. If no structuring element is provided an element
is generated with a square connectivity equal to one (i.e., only
nearest neighbors are connected to the center, diagonally-connected
elements are not considered neighbors).

iterations : {int, float}, optional

The dilation step of the closing, then the erosion step are each
repeated iterations times (one, by default). If iterations is
less than 1, each operations is repeated until the result does
not change anymore.

output : ndarray, optional

Array of the same shape as input, into which the output is placed.
By default, a new array is created.

Closing[R15] is a mathematical morphology operation [R16] that
consists in the succession of a dilation and an erosion of the
input with the same structuring element. Closing therefore fills
holes smaller than the structuring element.

Together with opening (binary_opening), closing can be used for
noise removal.