bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / ndimage / _morphology / grey_closing
function
scipy.ndimage._morphology:grey_closing
source: build-install/usr/lib/python3.14/site-packages/scipy/ndimage/_morphology.py:1541
Signature
def grey_closing(input, size = None, footprint = None, structure = None, output = None, mode = reflect, cval = 0.0, origin = 0, *, axes = None)Summary
Multidimensional grayscale closing.
Extended Summary
A grayscale closing consists in the succession of a grayscale dilation, and a grayscale erosion.
Parameters
input: array_likeArray over which the grayscale closing is to be computed.
size: tuple of intsShape of a flat and full structuring element used for the grayscale closing. Optional if
footprintorstructureis provided.footprint: array of ints, optionalPositions of non-infinite elements of a flat structuring element used for the grayscale closing.
structure: array of ints, optionalStructuring element used for the grayscale closing.
structuremay be a non-flat structuring element. Thestructurearray applies offsets to the pixels in a neighborhood (the offset is additive during dilation and subtractive during erosion)output: array, optionalAn array used for storing the output of the closing may be provided.
mode: {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optionalThe
modeparameter determines how the array borders are handled, wherecvalis the value when mode is equal to 'constant'. Default is 'reflect'cval: scalar, optionalValue to fill past edges of input if
modeis 'constant'. Default is 0.0.origin: scalar, optionalThe
originparameter controls the placement of the filter. Default 0axes: tuple of int or NoneThe axes over which to apply the filter. If None,
inputis filtered along all axes. If anorigintuple is provided, its length must match the number of axes.
Returns
grey_closing: ndarrayResult of the grayscale closing of
inputwithstructure.
Notes
The action of a grayscale closing with a flat structuring element amounts to smoothen deep local minima, whereas binary closing fills small holes.
Examples
from scipy import ndimage import numpy as np a = np.arange(36).reshape((6,6)) a[3,3] = 0 a ndimage.grey_closing(a, size=(3,3))✓
array([[ 7, 7, 8, 9, 10, 11],
[ 7, 7, 8, 9, 10, 11],
[13, 13, 14, 15, 16, 17],
[19, 19, 20, 20, 22, 23],
[25, 25, 26, 27, 28, 29],
[31, 31, 32, 33, 34, 35]])
See also
Aliases
scipy.ndimage.grey_closing