code: def white_tophat(
      image, footprint=None, out=None, *, mode="reflect", cval=0.0
  ):
      """Return white top hat of an image.
  
      The white top hat of an image is defined as the image minus its
      morphological opening. This operation returns the bright spots of the image
      that are smaller than the footprint.
  
      Parameters
      ----------
      image : ndarray
          Image array.
      footprint : ndarray or tuple, optional
          The neighborhood expressed as a 2-D array of 1's and 0's.
          If None, use a cross-shaped footprint (connectivity=1). The footprint
          can also be provided as a sequence of smaller footprints as described
          in the notes below.
      out : ndarray, optional
          The array to store the result of the morphology. If None
          is passed, a new array will be allocated.
      mode : str, optional
          The `mode` parameter determines how the array borders are handled.
          Valid modes are: 'reflect', 'constant', 'nearest', 'mirror', 'wrap',
          'max', 'min', or 'ignore'. See :func:`skimage.morphology.opening`.
          Default is 'reflect'.
      cval : scalar, optional
          Value to fill past edges of input if `mode` is 'constant'. Default
          is 0.0.
  
          .. versionadded:: 0.23
              `mode` and `cval` were added in 0.23.
  
      Returns
      -------
      out : array, same shape and type as `image`
          The result of the morphological white top hat.
  
      Notes
      -----
      The footprint can also be a provided as a sequence of 2-tuples where the
      first element of each 2-tuple is a footprint ndarray and the second element
      is an integer describing the number of times it should be iterated. For
      example ``footprint=[(np.ones((9, 1)), 1), (np.ones((1, 9)), 1)]``
      would apply a 9x1 footprint followed by a 1x9 footprint resulting in a net
      effect that is the same as ``footprint=np.ones((9, 9))``, but with lower
      computational cost. Most of the builtin footprints such as
      :func:`skimage.morphology.disk` provide an option to automatically generate
      a footprint sequence of this type.
  
      See Also
      --------
      black_tophat
  
      References
      ----------
      .. [1] https://en.wikipedia.org/wiki/Top-hat_transform
  
      Examples
      --------
      >>> # Subtract gray background from bright peak
      >>> import numpy as np
      >>> from skimage.morphology import square
      >>> 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]], dtype=np.uint8)
      >>> white_tophat(bright_on_gray, square(3))
      array([[0, 0, 0, 0, 0],
             [0, 0, 1, 0, 0],
             [0, 1, 5, 1, 0],
             [0, 0, 1, 0, 0],
             [0, 0, 0, 0, 0]], dtype=uint8)
  
      """
      if out is image:
          # We need a temporary image
          opened = opening(image, footprint, mode=mode, cval=cval)
          if np.issubdtype(opened.dtype, bool):
              np.logical_xor(out, opened, out=out)
          else:
              out -= opened
          return out
  
      # Else write intermediate result into output image
      out = opening(image, footprint, out=out, mode=mode, cval=cval)
      if np.issubdtype(out.dtype, bool):
          np.logical_xor(image, out, out=out)
      else:
          np.subtract(image, out, out=out)
      return out
  
file_path: scikit-image/skimage/morphology/gray.py
imports: import warnings
  import numpy
  from scipy import ndimage
  from .footprints import _footprint_is_sequence, mirror_footprint, pad_footprint
  from .misc import default_footprint
  from .._shared.utils import DEPRECATED
label_desc: Use image node_id 9 for calling a global function with example usage: white_tophat(image, footprint, out) and returns: out, out