{ } Raw JSON

bundles / scipy 1.17.1 / scipy / ndimage / _morphology / grey_closing

function

scipy.ndimage._morphology:grey_closing

source: /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_like

Array over which the grayscale closing is to be computed.

size : tuple of ints

Shape of a flat and full structuring element used for the grayscale closing. Optional if footprint or structure is provided.

footprint : array of ints, optional

Positions of non-infinite elements of a flat structuring element used for the grayscale closing.

structure : array of ints, optional

Structuring element used for the grayscale closing. structure may be a non-flat structuring element. The structure array applies offsets to the pixels in a neighborhood (the offset is additive during dilation and subtractive during erosion)

output : array, optional

An array used for storing the output of the closing may be provided.

mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional

The mode parameter determines how the array borders are handled, where cval is the value when mode is equal to 'constant'. Default is 'reflect'

cval : scalar, optional

Value to fill past edges of input if mode is 'constant'. Default is 0.0.

origin : scalar, optional

The origin parameter controls the placement of the filter. Default 0

axes : tuple of int or None

The axes over which to apply the filter. If None, input is filtered along all axes. If an origin tuple is provided, its length must match the number of axes.

Returns

grey_closing : ndarray

Result of the grayscale closing of input with structure.

Notes

The action of a grayscale closing with a flat structuring element amounts to smoothen deep local minima, whereas binary closing fills small holes.

Array API Standard Support

grey_closing 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-arrayapi for more information.

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))

See also

binary_closing
generate_binary_structure
grey_dilation
grey_erosion
grey_opening

Aliases

  • scipy.ndimage.grey_closing