bundles / scipy 1.17.1 / scipy / ndimage / _morphology / white_tophat
function
scipy.ndimage._morphology:white_tophat
Signature
def white_tophat ( input , size = None , footprint = None , structure = None , output = None , mode = reflect , cval = 0.0 , origin = 0 , * , axes = None ) Summary
Multidimensional white tophat filter.
Parameters
input: array_likeInput.
size: tuple of intsShape of a flat and full structuring element used for the filter. Optional if
footprintorstructureis provided.footprint: array of ints, optionalPositions of elements of a flat structuring element used for the white tophat filter.
structure: array of ints, optionalStructuring element used for the filter.
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 filter 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 is 0.axes: 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
output: ndarrayResult of the filter of
inputwithstructure.
Notes
Array API Standard Support
white_tophat 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
Subtract gray background from a bright peak.from scipy.ndimage import generate_binary_structure, white_tophat import numpy as np square = generate_binary_structure(rank=2, connectivity=3) bright_on_gray = np.array([[2, 3, 3, 3, 2], [3, 4, 5, 4, 3], [3, 5, 9, 5, 3], [3, 4, 5, 4, 3], [2, 3, 3, 3, 2]]) white_tophat(input=bright_on_gray, structure=square)✓
See also
Aliases
-
scipy.ndimage.white_tophat