cupyx.scipy.signal.argrelmax#

cupyx.scipy.signal.argrelmax(data, axis=0, order=1, mode='clip')[源代码]#

计算 data 的相对最大值。

参数:
  • data (ndarray) – 要查找相对最大值的数组。

  • axis (int, 可选) – 从 data 中选择的轴。默认为 0。

  • order (int, 可选) – 用于比较两侧多少个点以认为 comparator(n, n+x) 为 True。

  • mode (str, 可选) – 向量边缘的处理方式。可用选项有 'wrap'(环绕)或 'clip'(将溢出视为与最后一个(或第一个)元素相同)。默认为 'clip'。请参阅 cupy.take。

返回:

extrema – 整数数组中最大值的索引。extrema[k]data 的轴 k 的索引数组。请注意,即使 data 是一维的,返回值也是一个元组。

返回类型:

tuple 的 ndarrays

注意

此函数使用 argrelextrema 并以 cupy.greater 作为比较器。因此,要将其视为最大值,它需要值两侧都存在严格的不等式。这意味着不会检测到平坦的最大值(宽度超过一个样本)。对于一维 data,可以使用 find_peaks 来检测所有局部最大值,包括平坦的最大值。

示例

>>> from cupyx.scipy.signal import argrelmax
>>> import cupy
>>> x = cupy.array([2, 1, 2, 3, 2, 0, 1, 0])
>>> argrelmax(x)
(array([3, 6]),)
>>> y = cupy.array([[1, 2, 1, 2],
...               [2, 2, 0, 0],
...               [5, 3, 4, 4]])
...
>>> argrelmax(y, axis=1)
(array([0]), array([1]))