EnergySpectrumAnalyer/src/DataCalcProcess/Poly2FindPeaks.h

54 lines
2.1 KiB
C
Raw Normal View History

2026-03-17 10:50:33 +08:00
#ifndef POLY2FINDPEAKS_H
#define POLY2FINDPEAKS_H
#include <algorithm>
#include <cmath>
#include <vector>
class Poly2FindPeaks {
public:
// 峰值结构体,存储峰值特征
typedef struct {
int index; // 峰值在数据中的索引
double position; // 峰值的精确位置(插值计算)
double height; // 峰值高度(相对于基线)
double amplitude; // 峰值的绝对幅度
double fwhm; // 半高宽Full Width at Half Maximum
} Peak;
// 滑动平均平滑(去噪预处理)
static std::vector<double> SmoothData(const std::vector<double>& data, int window_size);
// 计算基线(使用百分位法,假设大部分数据为基线)
static double calculateBaseline(const std::vector<double>& data, double percentile = 0.1);
// 检测峰值
static std::vector<Peak> findPeaks(
const std::vector<double>& data,
double height_threshold = 0.0, // 峰值高度阈值(相对于基线)
int min_distance = 3, // 峰之间的最小距离(索引)
int smooth_window = 3 // 平滑窗口大小
);
};
/*******************************************************************************
1
2线
3
4
5
* heightThreshold线
* minDistance
* smoothWindow
* position线
* height线
* amplitude
* fwhm
*******************************************************************************/
#endif // POLY2FINDPEAKS_H