code: def peak_local_max(
      image,
      min_distance=10,
      threshold_abs=0,
      threshold_rel=0.1,
      num_peaks=np.inf,
  ):
      """Find peaks in an image, and return them \
      as coordinates or a boolean array.
  
      Peaks are the local maxima in a region of `2 * min_distance + 1`
      (i.e. peaks are separated by at least `min_distance`).
  
      Parameters
      ----------
      image : ndarray of floats
          Input image.
  
      min_distance : int, default=10
          Minimum number of pixels separating peaks in a region of `2 *
          min_distance + 1` (i.e. peaks are separated by at least
          `min_distance`). To find the maximum number of peaks, use
          `min_distance=1`.
  
      threshold_abs : float, default=0
          Minimum intensity of peaks.
  
      threshold_rel : float, default=0.1
          Minimum intensity of peaks calculated as `max(image) * threshold_rel`.
  
      num_peaks : int, default=np.inf
          Maximum number of peaks. When the number of peaks exceeds `num_peaks`,
          return `num_peaks` peaks based on highest peak intensity.
  
      Returns
      -------
      output : ndarray or ndarray of bools
          Boolean array shaped like `image`, with peaks represented by True
          values.
  
      Notes
      -----
      If peaks are flat (i.e. multiple adjacent pixels have identical
      intensities), the coordinates of all such pixels are returned.
  
      The peak local maximum function returns the coordinates of local peaks
      (maxima) in a image. A maximum filter is used for finding local maxima.
      This operation dilates the original image. After comparison between
      dilated and original image, peak_local_max function returns the
      coordinates of peaks where dilated image = original.
  
      This code is mostly adapted from scikit image 0.11.3 release.
      Location of file in scikit image: peak_local_max function in
      skimage.feature.peak
  
      """
      out = np.zeros_like(image, dtype=bool)
  
      if np.all(image == image.flat[0]):
          return out
  
      image = image.copy()
  
      size = 2 * min_distance + 1
      image_max = maximum_filter(image, size=size, mode="constant")
  
      mask = image == image_max
      image *= mask
  
      # find top peak candidates above a threshold
      peak_threshold = max(
          np.max(image.ravel()) * threshold_rel, threshold_abs
      )
  
      # get coordinates of peaks
      coordinates = np.argwhere(image > peak_threshold)
  
      if coordinates.shape[0] > num_peaks:
          intensities = image.flat[
              np.ravel_multi_index(coordinates.transpose(), image.shape)
          ]
          idx_maxsort = np.argsort(intensities)[::-1]
          coordinates = coordinates[idx_maxsort][:num_peaks]
  
      nd_indices = tuple(coordinates.T)
      out[nd_indices] = True
      return out
  
imports: import numpy
  from scipy.ndimage import label, maximum_filter
label_desc: Use image node_id 3 for calling a global function with example usage: peak_local_max(image, min_distance, threshold_abs, threshold_rel, num_peaks) and returns: out, out