find_peaks#
Finds the peaks in a 1D input operator.
Currently only the height and threshold parameters are supported.
-
template<typename InType>
__MATX_INLINE__ auto matx::find_peaks(const InType &in, typename InType::value_type height, typename InType::value_type threshold)# Compute peak search of input
Returns a tensor representing the indices of peaks found in the input operator. The first output parameter holds the indices while the second holds the number of indices/peaks found. The output index tensor must be large enough to hold all of the peaks found or the behavior is undefined.
- Template Parameters:
InType – Input data type
D – Number of right-most dimensions to reduce over
- Parameters:
in – Input data to reduce
height – Height threshold for peak detection. Values below this threshold are not considered peaks.
threshold – Threshold for peak detection. Neighboring values must be larger in vertical distance than this threshold
- Returns:
Operator with reduced values of peak search computed
Examples#
auto tiv = make_tensor<TestType>({32});
auto tidx = make_tensor<index_t>({32});
tiv.SetVals({ 3.9905e-01, 5.1668e-01, 2.4930e-02, 9.4008e-01, 9.4585e-01, 7.9673e-01, 4.1501e-01, 8.2026e-01, 2.2904e-01, 9.0959e-01, 1.0000e+01,
7.5222e-02, 4.0922e-01, 9.6007e-01, 2.0930e-01, 1.9395e-01, 8.9094e-01, 4.3867e-01, 3.5698e-01, 5.4537e-01, 8.2992e-01, 2.0994e-01, 7.6842e-01,
4.2899e-01, 2.1167e-01, 6.6055e-01, 1.6536e-01, 4.2499e-01, 9.9267e-01, 6.9642e-01, 2.4719e-01, 7.0281e-01});
auto num_found = make_tensor<int>({});
(mtie(tidx, num_found) = find_peaks(tiv, static_cast<TestType>(0.5), static_cast<TestType>(0.1))).run(exec);