bundles / scipy latest / scipy / ndimage / _morphology / grey_opening
function
scipy.ndimage._morphology:grey_opening
Signature
def grey_opening ( input , size = None , footprint = None , structure = None , output = None , mode = reflect , cval = 0.0 , origin = 0 , * , axes = None ) Summary
Multidimensional grayscale opening.
Extended Summary
A grayscale opening consists in the succession of a grayscale erosion, and a grayscale dilation.
Parameters
input: array_likeArray over which the grayscale opening is to be computed.
size: tuple of intsShape of a flat and full structuring element used for the grayscale opening. Optional if
footprintorstructureis provided.footprint: array of ints, optionalPositions of non-infinite elements of a flat structuring element used for the grayscale opening.
structure: array of ints, optionalStructuring element used for the grayscale opening.
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 opening 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_opening: ndarrayResult of the grayscale opening of
inputwithstructure.
Notes
The action of a grayscale opening with a flat structuring element amounts to smoothen high local maxima, whereas binary opening erases small objects.
Array API Standard Support
grey_opening has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ✅ PyTorch ✅ ⛔ JAX ⚠️ no JIT ⛔ Dask ⚠️ computes graph n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
from scipy import ndimage import numpy as np a = np.arange(36).reshape((6,6)) a[3, 3] = 50 a ndimage.grey_opening(a, size=(3,3))✓
See also
Aliases
-
scipy.ndimage.grey_opening