Peak-valley value detection method and system, electronic equipment and storage medium
By dynamically adjusting the window length and evaluation weight value, the optimal window length is automatically screened and the significance of the target data point is quantified, which solves the accuracy and efficiency problems of the existing peak and valley value detection method and realizes efficient and accurate peak and valley value detection.
Patent Information
- Application Number
- CN202511280723.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-09-09
AI Technical Summary
Existing peak-valley detection methods have deficiencies in accuracy and efficiency, especially in noise resistance and parameter setting, resulting in inaccurate or inefficient detection results.
By traversing and comparing the amplitude of each candidate data point with the data points within the window length on its left and right sides, the evaluation weight value of the window length is dynamically adjusted. The optimal window length is screened in the first cycle, and the local significance of the target data point is quantified in the second cycle to automatically screen the peak and valley values.
It significantly improves the accuracy and efficiency of peak-valley detection, adapts to different signal scenarios, accurately captures weak peaks and suppresses pseudo-peak interference, and maintains low computational complexity to meet real-time processing requirements.
Smart Images

Figure CN120761691A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of signal processing, and in particular to a peak-valley value detection method and system, an electronic device and a storage medium. BACKGROUND
[0002] In electronic measurement testing, real-time measured signals are complex and changeable, and contain rich information. The peak value is the maximum amplitude of the signal within a certain time period, reflecting the extreme strength or upper limit of energy of the signal. The valley value is the minimum amplitude of the signal within a certain time period, reflecting the minimum strength or lower limit of energy of the signal. Both of them together describe the fluctuation range and stability of the signal, and are commonly used to evaluate the impact of the signal on the equipment or analyze the characteristics of the signal. Therefore, finding the peak value and valley value of the real-time measured signal plays an important role in analyzing the quality of the test, and also has a great influence on the research and development efficiency and quality of electronic products.
[0003] The existing peak-valley value detection methods include derivative method, simple comparison method, linear fitting method and constant false alarm rate method. Among them, the derivative method is to smooth the signal, calculate the multi-order derivative of the signal waveform, then take the average value of the data, set a threshold according to the average value, and then screen the peak-valley value; the simple comparison method is to smooth the signal, then compare the maximum value to obtain the result; the linear fitting method is to calculate the linear function coefficient by least square method, then obtain the fitting curve according to the fitting function, and finally calculate the corresponding peak-valley value and the corresponding index; the constant false alarm rate method is to first set left and right window functions, then smooth the signal by windowing, then take the average value of the optimized curve, set a threshold according to the average value, and finally screen the peak-valley value.
[0004] However, the derivative method and the simple comparison method have poor noise resistance, and in actual test scenarios, many false peak-valley values are detected, or real peak-valley values are missed, and the accuracy is not high. The linear fitting method and the constant false alarm rate method need to set too many parameters, and different parameters need to be set for different scenarios, which is not efficient. SUMMARY
[0005] The present application provides a peak-valley value detection method, system, electronic device and storage medium to solve the problem of low accuracy and efficiency of the prior art for peak-valley value detection.
[0006] In a first aspect, the present application provides a peak-valley value detection method, comprising: Traversing and comparing the amplitudes of each candidate data point with the data points within the window length on its left and right sides to determine a first target evaluation weight value of the window length; the candidate data point is determined based on the window length and the array length, and the array is composed of amplitudes corresponding to multiple data points contained in the real-time measured signal; the first target evaluation weight value is used to reflect the effectiveness of detecting peaks or valleys under the condition of the window length; gradually increasing the window length, iteratively performing the steps of traversing and comparing the amplitude of each candidate data point with the data points within the window lengths on its left and right sides, and determining a first target evaluation weight value of the window length until the window length reaches a preset length, and selecting an optimal window length from each window length based on the first target evaluation weight value of each window length; Traversing and comparing the amplitudes of each target data point with the data points within the optimal window length on its left and right sides to determine a second target evaluation weight value for each target data point; the target data point is determined based on the optimal window length and the array length; the second target evaluation weight value is used to reflect the local significance of the target data point as a peak or valley value; Based on the second target evaluation weight value of each target data point, a peak value or a valley value in the real-time measured signal is determined from each target data point.
[0007] In one embodiment, the traversal compares the amplitude of each candidate data point with the data points within the window length on its left and right sides to determine the first target evaluation weight value of the window length, and for peak detection, includes: Traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides; In the process of traversing all candidate data points, if the amplitude of the current candidate data point is greater than the amplitude of the data points within the window length on its left and right sides, the first initial evaluation weight value of the window length is reduced until the traversal is completed and the first target evaluation weight value of the window length is obtained.
[0008] In one embodiment, selecting the optimal window length from each window length based on the first target evaluation weight value of each window length includes: The window length corresponding to the minimum first target evaluation weight value among the first target evaluation weight values of each window length is determined as the optimal window length.
[0009] In one embodiment, the determining of the peak value or valley value in the real-time measured signal from each target data point based on the second target evaluation weight value of each target data point includes: determining a plurality of peaks from each target data point based on a second target evaluation weight value of each target data point; If the difference between the index values of two adjacent peaks is smaller than a preset value, the two adjacent peaks are merged into one peak to obtain multiple peaks in the real-time measured signal.
[0010] In one embodiment, after determining the peak value in the real-time measured signal, the method further includes: Jump to the highest peak and mark its corresponding peak feature information; According to the target sorting result, jump from the highest peak to each peak detected in real time in sequence, and mark the corresponding peak feature information each time jumping to a peak; the target sorting result is updated based on multiple peaks detected in real time at each jump; the target sorting result is obtained by sorting the peaks with equal amplitudes in ascending order according to the index values corresponding to the peaks with equal amplitudes under the condition that there are at least two peaks with equal amplitudes in the initial sorting result; the initial sorting result is obtained by sorting the peaks in descending order based on the amplitudes corresponding to the peaks.
[0011] In one embodiment, after determining the peak value in the real-time measured signal, the method further includes: Jump from the highest peak to the rightmost peak among the multiple peaks detected in real time, and mark the corresponding peak feature information; According to the order of the index values of each peak, jump from the rightmost peak to each peak detected in real time, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the leftmost peak among the multiple peaks detected in real time and stops.
[0012] In one embodiment, after determining the peak value in the real-time measured signal, the method further includes: Jump from the highest peak to the leftmost peak among the multiple peaks detected in real time, and mark the corresponding peak feature information; According to the order of the index values of each peak, jump from the leftmost peak to the peaks detected in real time in sequence, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the rightmost peak among the multiple peaks detected in real time and stops.
[0013] In a second aspect, the present invention further provides a peak-valley value detection system, comprising: A first determination module is configured to traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides to determine a first target evaluation weight value of the window length; the candidate data point is determined based on the window length and the array length, and the array is composed of the amplitudes corresponding to the plurality of data points contained in the real-time measured signal; the first target evaluation weight value is used to reflect the effectiveness of detecting peaks or valleys under the condition of the window length; a window selection module configured to gradually increase the window length, iteratively perform the steps of comparing the amplitude of each candidate data point with the data points within the window lengths on its left and right sides, and determining a first target evaluation weight value for the window length until the window length reaches a preset length, and select an optimal window length from each window length based on the first target evaluation weight value for each window length; a second determination module, configured to traverse and compare the amplitude of each target data point with the data points within the optimal window length on its left and right sides to determine a second target evaluation weight value for each target data point; the target data point is determined based on the optimal window length and the array length; the second target evaluation weight value is used to reflect the local significance of the target data point as a peak or valley value; The peak-valley value detection module is used to determine the peak value or valley value in the real-time measured signal from each target data point based on the second target evaluation weight value of each target data point.
[0014] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the peak-valley value detection methods described above are implemented.
[0015] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of any of the peak-valley value detection methods described above are implemented.
[0016] The peak-valley detection method, system, electronic device and storage medium provided by the present invention dynamically evaluate the effectiveness of peak-valley detection with different window lengths by traversing the increasing window length and calculating the first target evaluation weight value in the first cycle, and automatically screen out the optimal window length adapted to the current signal characteristics without relying on manual parameter setting, thereby significantly improving the universality in different signal scenarios; the second cycle compares the left and right neighborhood amplitudes of the target data point based on the optimal window length, and quantifies its local significance as a peak-valley value through the second target evaluation weight value, which can not only accurately capture weak peaks, but also effectively suppress pseudo-peak interference; the synergy of the two cycle scoring makes the window adaptability performance of peak-valley detection extremely high, while maintaining low computational complexity to meet real-time processing requirements, thereby improving the accuracy and efficiency of peak-valley detection as a whole. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 This is one of the flow charts of the peak-valley value detection method provided by the present invention.
[0019] Figure 2 This is the second flow chart of the peak-valley value detection method provided by the present invention.
[0020] Figure 3 This is a logical diagram of the peak jump provided by the present invention.
[0021] Figure 4 This is a logical diagram of the valley jump provided by the present invention.
[0022] Figure 5 It is a schematic diagram of the peak detection effect of a common signal provided by the present invention.
[0023] Figure 6 It is a schematic diagram of the valley detection effect of a common signal provided by the present invention.
[0024] Figure 7 It is a schematic diagram of the peak detection effect of the square wave signal provided by the present invention.
[0025] Figure 8 It is a structural schematic diagram of the peak-valley value detection system provided by the present invention.
[0026] Figure 9 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0027] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0028] The terms "first," "second," and the like in the present invention are used to distinguish similar objects and are not used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present invention can be implemented in orders other than those illustrated or described herein.
[0029] The following combination Figures 1-9 The present invention describes a peak-valley value detection method, system, electronic device, and storage medium.
[0030] The peak-valley value detection method provided in the embodiment of the present invention is implemented based on the peak-valley value detection system. Therefore, the embodiment of the present invention uses the peak-valley value detection system as the execution subject to specifically describe the peak-valley value detection method.
[0031] Combine Figure 1 and Figure 2 , Figure 1 This is one of the flow charts of the peak-valley value detection method provided by the present invention. Figure 2 This is the second flow chart of the peak-valley value detection method provided by the present invention.
[0032] like Figure 1 As shown, the peak-valley value detection method includes the following steps: Step 101: traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides to determine the first target evaluation weight value of the window length; Step 102: gradually increase the window length, iteratively perform the steps of comparing the amplitude of each candidate data point with the data points within the window lengths on its left and right sides, and determining a first target evaluation weight value for the window length until the window length reaches a preset length, and select an optimal window length from each window length based on the first target evaluation weight value for each window length; Step 103: traverse and compare the amplitude of each target data point with the data points within the optimal window length on its left and right sides to determine the second target evaluation weight value of each target data point; Step 104 : Based on the second target evaluation weight value of each target data point, determine the peak value or valley value in the real-time measured signal from each target data point.
[0033] Specifically, the measured signal refers to the raw physical quantity or electrical signal that needs to be collected, analyzed, or recorded during measurement, monitoring, or experimentation. Real-time measured signals often contain transient changes, such as bursts, short-duration peaks, and instantaneous fluctuations. These characteristics may only last for a very short time. If non-real-time acquisition or offline recording and post-analysis is used, critical peak and valley values may be lost due to excessive sampling intervals or data transmission delays. Peak and valley value detection of real-time measured signals can ensure that the transient characteristics of the signal are captured and the authenticity of the data is guaranteed.
[0034] The real-time measured signal is converted into an analog electrical signal by a sensor, and then discretely sampled at a fixed sampling frequency by an analog-to-digital converter to obtain a series of data points arranged in time sequence, forming an array. Each element (data point) in the array corresponds to the signal amplitude at a specific time, and the array length N is determined by the sampling time length and the sampling frequency.
[0035] The real-time measured signal is processed in two cycles in this embodiment. In the first cycle, the optimal window length is calculated, and in the second cycle, the peak or valley value is detected based on the optimal window length determined in the first cycle.
[0036] In the first cycle, the window length k is initialized, and the first initial evaluation weight value w1 of the window length k is determined.
[0037] The range of candidate data points is determined based on the window length and the array length. The candidate data points need to satisfy that there are at least k valid data points on both sides, i.e., the edge data points of the array are excluded to ensure the integrity of the subsequent neighborhood comparison.
[0038] Optionally, the array length is N, the window length is k, and the selected candidate data points are the data points within the range of (k+1) to (N-k). The cycle range of the candidate data points for subsequent neighborhood comparison is from (k+1) to (N-k). In addition, multiple consecutive data points within the range of (k+1) to (N-k) can also be selected as candidate data points. The specific selection method of the candidate data points can be set according to the actual situation. This embodiment takes all data points within the range of (k+1) to (N-k) as candidate data points as an example to describe the subsequent process.
[0039] The amplitude values of each candidate data point and the data points within the window length k on both sides are compared. It can be understood that for each candidate data point, the amplitude value of the candidate data point is compared with the amplitude values of the k data points on the left and the k data points on the right. If the comparison result satisfies the peak condition (i.e., the amplitude value of the candidate data point is greater than the amplitude values of all k data points on both sides), the first initial evaluation weight value w1 of the window length k is reduced. The cycle range is from the (k+1) th data point to the (N-k) th data point. After the cycle process is completed, the accumulated first initial evaluation weight value is called the first target evaluation weight value, which is used to reflect the effectiveness of detecting the peak value under the condition of the window length k.
[0040] The algorithm traverses and compares the amplitude of each candidate data point with the data points on its left and right within a window of length k. This can also be understood as comparing the amplitude of each candidate data point with the amplitudes of the k data points to its left and right. If the comparison result satisfies the valley condition (i.e., the amplitude of the candidate data point is less than the amplitudes of all k data points on its left and right), the first initial evaluation weight w1 for the window length k is reduced. This process is repeated from the k+1th data point to the Nkth data point. The accumulated first initial evaluation weight value after the cycle is called the first target evaluation weight W1, which is also used to reflect the effectiveness of valley detection under the condition of window length k.
[0041] The step size is 1, and the window length is gradually increased. The above loop traversal process is repeated for each window length until the window length reaches the preset length, and the first target evaluation weight value W1 corresponding to different window lengths can be obtained. The preset length is set according to the actual situation. Optionally, if the array length N is an odd number, the preset length is N / 2; if the array length N is an even number, the preset length is (N / 2)-1. Of course, it can also be set to a smaller value.
[0042] Based on the comparison of the first target evaluation weight values of each window length, the optimal window length L is selected from each window length.
[0043] Based on the optimal window length L, the target data point range is re-determined, and the array edge data points are also excluded to ensure that each target data point has complete left and right neighborhoods for subsequent neighborhood comparison.
[0044] During the second cycle, the second initial evaluation weight value w2 of the target data point is initialized first.
[0045] Optionally, the array length is N, the optimal window length is L, and the target data points selected are data points in the range of (L+1) to (NL). The target data points' subsequent neighborhood comparison loop range is from (L+1) to (NL). Furthermore, multiple consecutive data points in the range of (L+1) to (NL) can be selected as target data points. The specific method for selecting target data points can be set based on actual circumstances. This embodiment uses all data points in the range of (L+1) to (NL) as target data points as an example to describe the subsequent process.
[0046] The amplitude of each target data point is compared with the data points on its left and right sides within the optimal window length L. This can be understood as comparing the amplitude of each target data point with the amplitudes of the L data points to its left and right. If the comparison result meets the peak condition (i.e., the amplitude of the target data point is greater than the amplitudes of all L data points on its left and right sides), the second initial evaluation weight value w2 for the optimal window length L is increased. This process is cyclical from the L+1th data point to the NLth data point. After the cycle, the accumulated second initial evaluation weight value is called the second target evaluation weight value W2, which is used to reflect the local significance of the target data point as a peak.
[0047] The amplitude of each target data point is compared with the amplitudes of the data points on its left and right sides within the optimal window length L. This can also be understood as comparing the amplitude of each target data point with the amplitudes of the L data points to its left and right. If the comparison result meets the valley condition (i.e., the amplitude of the target data point is less than the amplitudes of all L data points on its left and right sides), the second initial evaluation weight value w2 for the optimal window length L is increased. This process is cyclical from the L+1th data point to the NLth data point. The accumulated second initial evaluation weight value after the cycle is called the second target evaluation weight value W2, which is used to reflect the local significance of the target data point as a valley value.
[0048] After completing the above loop traversal process, the second target evaluation weight value W2 of each target data point can be obtained. Based on the comparison of the second target evaluation weight values of each target data point, the peak or valley value in the real-time measured signal is determined from each target data point.
[0049] The peak-valley detection method provided by the present invention dynamically evaluates the effectiveness of peak-valley detection with different window lengths in the first cycle by traversing the increasing window length and calculating the first target evaluation weight value, and automatically selects the optimal window length adapted to the current signal characteristics without relying on manual parameter setting, which significantly improves the universality in different signal scenarios; the second cycle compares the left and right neighborhood amplitudes of the target data point based on the optimal window length, and quantifies its local significance as a peak-valley value through the second target evaluation weight value, which can not only accurately capture weak peaks, but also effectively suppress pseudo-peak interference; the synergy of the two cycle scoring makes the window adaptability performance of peak-valley detection extremely high, while maintaining low computational complexity to meet real-time processing requirements, thereby improving the accuracy and efficiency of peak-valley detection as a whole.
[0050] In some embodiments, the traversal compares the amplitude of each candidate data point with the data points within the window length on its left and right sides to determine the first target evaluation weight value of the window length, which includes: Traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides; In the process of traversing all candidate data points, if the amplitude of the current candidate data point is greater than the amplitude of the data points within the window length on its left and right sides, the first initial evaluation weight value of the window length is reduced until the traversal is completed and the first target evaluation weight value of the window length is obtained.
[0051] Specifically, during the first cycle, the window length k and the first initial evaluation weight value w1 of the window length k are initialized.
[0052] Traverse and compare the amplitude of each candidate data point with the data points within the window length k on its left and right sides.
[0053] During the traversal and loop comparison process, if the amplitude of the currently traversed candidate data point is greater than the amplitudes of the k data points on its left and greater than the amplitudes of the k data points on its right, the current first initial evaluation weight value w1 of the window length k is reduced; if the amplitude of the currently traversed candidate data point is less than or equal to the amplitude of any data point among all the k data points on its left and right sides, the current first initial evaluation weight value w1 of the window length k is not adjusted.
[0054] Optionally, the first initial evaluation weight value of the window length k is reduced, that is, the first initial evaluation weight value minus the preset adjustment value. Assuming that the preset adjustment value is 1, then, when the comparison result meets the peak condition, ,in, is the first initial evaluation weight value adjusted according to the comparison result, It is the first initial evaluation weight value after adjustment in the previous round of comparison.
[0055] By traversing and comparing the amplitudes and adjusting the first initial evaluation weight value in the above manner until all candidate data points are traversed, the first initial evaluation weight value of each round is accumulated to obtain the first target evaluation weight value W1 of the window length k.
[0056] As can be deduced from the above, the traversal compares the amplitude of each candidate data point with the data points within the window length on its left and right sides to determine the first target evaluation weight value of the window length. When detecting valley values, it includes: Traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides; In the process of traversing all candidate data points, if the amplitude of the current candidate data point is smaller than the amplitude of the data points within the window length on its left and right sides, the first initial evaluation weight value of the window length is reduced until the traversal is completed and the first target evaluation weight value of the window length is obtained.
[0057] During the first cycle, the traversal comparison process for valley values is the same as that for peak values, except that the amplitude of the candidate data point traversed during amplitude comparison must be smaller than the amplitudes of all data points in the comparison range. The detailed process is the same as the above-mentioned traversal comparison process for peak values and will not be repeated here.
[0058] The embodiment of the present invention dynamically adjusts the evaluation weight value of the window length, quantifies the applicability of the window length, and effectively balances the detection sensitivity and anti-interference ability, thereby realizing adaptive detection of peak and valley values in the real-time measured signal, and improving the accuracy and robustness of peak and valley value detection.
[0059] In some embodiments, based on step 103, the selecting the optimal window length from each window length based on the first target evaluation weight value of each window length includes: The window length corresponding to the minimum first target evaluation weight value among the first target evaluation weight values of each window length is determined as the optimal window length.
[0060] Specifically, the first target evaluation weights of each window length are numerically compared, and the minimum first target evaluation weight value is determined according to the comparison result.
[0061] The window length corresponding to the minimum first target evaluation weight value is determined as the optimal window length.
[0062] The embodiment of the present invention intuitively quantifies the adaptability of different windows to peak and valley detection through a scoring weight mechanism, so as to find the optimal window length with more data points meeting the peak and valley conditions and better adaptability, thereby realizing automatic optimization of window length, avoiding the subjectivity of manual parameter adjustment, and further improving the automation level and result reliability of the peak and valley detection algorithm.
[0063] In some embodiments, based on step 104, the traversal and comparison of the amplitude of each target data point with the data points within the optimal window length on its left and right sides to determine the second target evaluation weight value of each target data point includes: Traverse and compare the amplitude of each target data point with the data points within the optimal window length on its left and right sides; In the process of traversing all target data points, if the amplitude of the current target data point is greater than the amplitude of the data points within the optimal window length on its left and right sides, the second initial evaluation weight value of the current target data point is increased until the traversal is completed and the second target evaluation weight value of each target data point is obtained.
[0064] Specifically, based on the optimal window length L, a range of target data points is selected, and these target data points are traversed and compared in amplitude.
[0065] During the second cycle, the second initial evaluation weight value w2 of the target data point is initialized first.
[0066] Traverse and compare the amplitude of each target data point with the data points within the optimal window length L on its left and right sides.
[0067] During the traversal and loop comparison process, if the amplitude of the target data point currently traversed is greater than the amplitudes of the L data points on its left and greater than the amplitudes of the L data points on its right, the second initial evaluation weight value w2 of the current target data point is increased; if the amplitude of the target data point currently traversed is less than or equal to the amplitude of any of the L data points on its left and right sides, the second initial evaluation weight value w2 of the current target data point is not adjusted.
[0068] Optionally, the second initial evaluation weight value of the target data point is increased, that is, the second initial evaluation weight value is increased by a preset adjustment value. Assuming that the preset adjustment value is 1, then, when the comparison result meets the peak condition, ,in, is the second initial evaluation weight value adjusted according to the comparison result, is the second initial evaluation weight value initialized.
[0069] By traversing and comparing the amplitudes and adjusting the second initial evaluation weight value in the above manner until all target data points are traversed, the second target evaluation weight value W2 of each target data point can be obtained.
[0070] As can be deduced from the above, the traversal and comparison of the amplitude of each target data point with the data points within the optimal window length on its left and right sides to determine the second target evaluation weight value of each target data point includes the following when detecting valley values: Traverse and compare the amplitude of each target data point with the data points within the optimal window length on its left and right sides; In the process of traversing all target data points, if the amplitude of the current target data point is smaller than the amplitude of the data points within the optimal window length on its left and right sides, the second initial evaluation weight value of the current target data point is increased until the traversal is completed and the second target evaluation weight value of each target data point is obtained.
[0071] During the second cycle, the traversal comparison process for valley values is the same as that for peak values, except that the amplitude of the candidate data point traversed during amplitude comparison must be smaller than the amplitudes of all data points within the comparison range. The detailed process is the same as the above-mentioned traversal comparison process for peak values and will not be repeated here.
[0072] Under the condition of optimal window length, the embodiment of the present invention dynamically adjusts the evaluation weight value by comparing the amplitude of the target data point with the data points in its left and right windows, thereby achieving a quantitative evaluation of the peak and valley value characteristics of each target data point, providing a reliable basis for the subsequent precise detection of peak and valley values in the real-time measured signal, thereby improving the accuracy of peak and valley value detection.
[0073] In some embodiments, based on step 104, the second target evaluation weight value of each target data point is used to determine the peak value or valley value of the real-time measured signal from each target data point, and when determining the peak value, the method includes: determining a plurality of peaks from each target data point based on a second target evaluation weight value of each target data point; If the difference between the index values of two adjacent peaks is smaller than a preset value, the two adjacent peaks are merged into one peak to obtain multiple peaks in the real-time measured signal.
[0074] Specifically, the second target evaluation weight values of the target data points are numerically compared, and a plurality of maximum second target evaluation weight values are determined according to the comparison results.
[0075] The target data points corresponding to the largest second target evaluation weight values are determined as peaks, and these peaks are sorted from small to large according to their index values.
[0076] If the index value difference between two adjacent peaks is less than a preset value, it means that the two adjacent peaks are very close. For example, the index value difference between two adjacent peaks is 1. Then the two adjacent peaks are merged into one peak, and finally multiple peaks in the real-time measured signal are obtained.
[0077] Similarly, if the index value difference between multiple consecutive adjacent peaks is less than a preset value, which means that these consecutive adjacent peaks are very close to each other, these consecutive adjacent peaks are merged into one peak, and finally multiple peaks in the real-time measured signal are obtained.
[0078] Optionally, peak merging can adopt an amplitude-based merging method, that is, retaining peaks with larger amplitudes and eliminating smaller peaks. Peak merging can also adopt a weighted average-based merging method, that is, merging the positions and amplitudes of peaks according to amplitude weights. Peak merging can also adopt an index interval-based merging method, that is, directly merging all points between two peaks or multiple peaks into a new interval, and taking the data point corresponding to the maximum amplitude in the interval as the merged peak.
[0079] As can be deduced from the above, the second target evaluation weight value based on each target data point determines the peak value or valley value in the real-time measured signal from each target data point, and when targeting the valley value, includes: determining a plurality of valley values from each target data point based on a second target evaluation weight value of each target data point; If the difference between the index values of two adjacent valley values is smaller than a preset value, the two adjacent valley values are merged into one valley value to obtain multiple valley values in the real-time measured signal.
[0080] The process of valley detection is the same as that of peak detection, as described above, and will not be described in detail here.
[0081] The embodiment of the present invention screens out potential peak and valley values by evaluating weight values, and merges adjacent peak or valley values whose index difference is less than a preset value, which can effectively solve the problem of dense redundant extreme points easily generated in the flat-top area of the square wave, avoid misjudging the same flat-top segment as multiple peaks or valleys, and realize accurate extraction and aggregation of true peak and valley values. The number of detected peak and valley value points is greatly reduced, and the reliability of the peak and valley value detection results is also guaranteed.
[0082] Based on the above peak-to-valley detection process, we will use a practical example to illustrate peak detection. Assume that the array consisting of the amplitude values of each data point in the real-time measured signal is data = [2, 5, 3, 8, 7, 10, 9, 12, 6, 4], and the array length is 10.
[0083] Enter the first round of loop to determine the optimal window length.
[0084] First, initialize the window length to k=1, and the first initial evaluation weight value w1 of the window length k=1 to 0. At the same time, determine the candidate data point range from the 2nd data point to the 9th data point. Traverse and compare the amplitude of each candidate data point with the amplitude of the data point to its left and the amplitude of the data point to its right. When the comparison result meets the peak condition, the first initial evaluation weight value w1 of the window length k=1 is reduced by 1. The traversal results are accumulated to obtain the first target evaluation weight value W1 of the window length k=1.
[0085] Gradually increase the window length and iterate the above loop traversal process until the window length reaches k=4, and then the first target evaluation weight value of each window length can be obtained.
[0086] When the window length k=1, the amplitude comparison is performed from the second data point to the ninth data point. The points that meet the peak condition are the data points with indexes 3, 5, 7, and 9, a total of 4 data points. Then the first target evaluation weight value W1 of the window length k=1 is -4; When the window length k=2, the amplitude comparison is performed from the second data point to the ninth data point. If there is no point that meets the peak condition, the first target evaluation weight value W1 of the window length k=2 is 0; When the window length k=3, the amplitude comparison is performed from the second data point to the ninth data point. If there is no point that meets the peak condition, the first target evaluation weight value W1 of the window length k=3 is 0; When the window length k=4, the amplitude comparison is performed from the second data point to the ninth data point. If there is no point that meets the peak condition, the first target evaluation weight value W1 of the window length k=4 is 0; Select the window length k with the smallest first target evaluation weight value, and the optimal window length is 1.
[0087] Enter the second cycle to detect the peak value in the real-time measured signal.
[0088] First, the target data point range is determined to be from the 2nd data point to the 9th data point, and the second initial evaluation weight value w2 of the target data point is initialized to 0.
[0089] The amplitude of each target data point is compared with the amplitude of the data point to its left and the amplitude of the data point to its right. When the comparison result meets the peak condition, the second initial evaluation weight value w2 of the target data point is increased by 1 to obtain the second target evaluation weight value W2 of the target data point.
[0090] The target data point with index value 2: data(2)=5, compare its amplitude with data(1)=2 and data(3)=3, the comparison results are 5>2 and 5>3, which meets the peak condition, then the second target evaluation weight value W2=1 for the target data point with index value 2; The target data point with index value 3: data(3)=3 is compared with data(2)=5 and data(4)=8 in terms of amplitude. The comparison results are 3<5 and 3<8, which do not meet the peak condition. Therefore, the second target evaluation weight value W2=0 for the target data point with index value 3; The target data point with index value 4: data(4)=8, compare its amplitude with data(3)=3 and data(5)=7, the comparison results are 8>3 and 8>7, which meets the peak condition, then the second target evaluation weight value W2=1 of the target data point with index value 4; The target data point with index value 5: data(5)=7, compare its amplitude with data(4)=8 and data(6)=10, the comparison result is 7<8 and 7<10, which does not meet the peak condition, then the second target evaluation weight value W2=0 of the target data point with index value 5; The target data point with index value 6: data(6)=10, compare its amplitude with data(5)=7 and data(7)=9, the comparison results are 10>7 and 10>9, which meets the peak condition, then the second target evaluation weight value W2=1 of the target data point with index value 6; The target data point with index value 7: data(7)=9, compare its amplitude with data(6)=10 and data(8)=12, the comparison result is 9<10 and 9<12, which does not meet the peak condition, then the second target evaluation weight value W2=0 of the target data point with index value 7; The target data point with index value 8: data(8)=12, compare its amplitude with data(7)=9 and data(9)=6, the comparison results are 12>9 and 12>6, which meets the peak condition, then the second target evaluation weight value W2=1 of the target data point with index value 8; The target data point with index value 9: data(9)=6, compare its amplitude with data(8)=12 and data(10)=4, the comparison result is 6<12 and 6>4, which does not meet the peak condition, then the second target evaluation weight value W2=0 of the target data point with index value 9; The final peak indices extracted are: 2, 4, 6, 8; the corresponding peaks are: 5, 8, 10, 12. The difference between the indices of adjacent peaks is not less than 2, so there is no need to merge them. The multiple peaks in the real-time measured signal are finally: 5, 8, 10, 12.
[0091] Furthermore, after completing the peak-valley detection, the peak-valley feature information can be marked using a peak-valley jump algorithm. That is, each time a peak or valley value is jumped to, the corresponding peak feature information or valley feature information is marked. The peak feature information may include the amplitude, frequency, and position information corresponding to the peak value, and the valley feature information may include the amplitude, frequency, and position information corresponding to the valley value.
[0092] This embodiment introduces three functions to implement the jump algorithm, namely the Next Peak function, the Next Left Peak function, and the Next Right Peak function. The Next Peak function stipulates that when jumping for the first time, it will default to jumping to the highest peak or lowest valley, and then jump in the order of the peak / valley amplitude and its index value; the Next Left Peak function stipulates that it will jump from the peak / valley value at the right boundary to the peak / valley value on the left, and stop jumping when it jumps to the peak / valley value on the left boundary; the Next Right Peak function stipulates that it will start from the peak / valley value at the left boundary to the peak / valley value on the left boundary, and stop jumping when it jumps to the peak / valley value on the right boundary.
[0093] Combine Figure 3-Figure 4 , Figure 3 This is a logical diagram of the peak jump provided by the present invention. Figure 4 This is a logical diagram of the valley jump provided by the present invention.
[0094] In some embodiments, after determining the peak value in the real-time measured signal, the method further includes: Jump to the highest peak and mark its corresponding peak feature information; According to the target sorting result, jump from the highest peak to each peak detected in real time in sequence, and mark the corresponding peak feature information each time jumping to a peak; the target sorting result is updated based on multiple peaks detected in real time at each jump; the target sorting result is obtained by sorting the peaks with equal amplitudes in ascending order according to the index values corresponding to the peaks with equal amplitudes under the condition that there are at least two peaks with equal amplitudes in the initial sorting result; the initial sorting result is obtained by sorting the peaks in descending order based on the amplitudes corresponding to the peaks.
[0095] Specifically, first determine whether the current peak is the highest. If not, jump to the highest peak by default and mark the corresponding peak feature information. Then, execute the Next Peak function.
[0096] Before jumping, the Next Peak function relies on the order of the peak amplitudes and their index values to jump, so sorting is required first. After determining multiple peaks in the real-time measured signal, each peak is first sorted in descending order based on its corresponding amplitude to obtain an initial sorting result. Furthermore, if there are at least two peaks with equal amplitudes in the initial sorting result, each peak with equal amplitude is sorted in ascending order according to its corresponding index value, ultimately obtaining the target sorting result for all peaks.
[0097] According to the target sorting results, jump from the highest peak to each peak detected in real time, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the last peak (i.e., the lowest peak) in the target sorting results and stops after marking.
[0098] It should be noted that in actual measurements, the measured signal will contain random noise and will change in real time. Since the algorithm for detecting the peak and valley values of the real-time measured signal is also real-time, the detected peak value will be updated at each jump and used as the real-time detected peak value. The target sorting result is updated at each jump based on the multiple peak values detected in real time. If the target sorting result is updated in real time and jumps to the second-order peak and marks it at the current moment, then the target sorting result will be updated in real time and jump to the third-order peak and mark it at the next moment. And so on, jumping to the last peak (i.e., the lowest peak) in the target sorting result and stopping.
[0099] Generally speaking, even if the measured signal changes in real time, the fluctuation of its amplitude is not large, so the target sorting result updated based on multiple peaks detected in real time at each jump usually does not change.
[0100] It can be inferred from the above that after determining the valley value in the real-time measured signal, the method further includes: Jump to the lowest valley value and mark the corresponding valley feature information; According to the target sorting result, jump from the lowest valley value to each valley value detected in real time in sequence, and mark the corresponding valley value feature information each time jumping to the valley value; the target sorting result is updated based on multiple valley values detected in real time at each jump; the target sorting result is obtained by sorting the valley values with equal amplitude in ascending order according to the index value corresponding to each valley value with equal amplitude under the condition that there are at least two valley values with equal amplitude in the initial sorting result; the initial sorting result is obtained by sorting the valley values in descending order based on the amplitude corresponding to each valley value.
[0101] The process of valley value jump and marking is the same as that of peak value jump and marking, except that the valley values are sorted in descending order and the jump process is also in descending order. The specific process is as described above and will not be repeated here.
[0102] The embodiment of the present invention uses the Next Peak function to jump and mark according to the sorting results. If the physical positions adjacent to the left or right are directly used for jumping (such as searching for the next peak or valley to the left / right from the current peak or valley), noise may cause the amplitude or position of the adjacent peaks or valleys to change frequently during real-time updates (for example, a new peak appears on the left during a jump, and a higher peak appears on the right due to noise during the next jump), resulting in the randomness of "jumping right when it should jump left". After the fixed jump sequence is determined by amplitude sorting combined with index assistance, the target of each jump is the peak or valley arranged by "energy priority" (amplitude from high to low) or "frequency order" (index ascending order). Even if individual points fluctuate slightly due to noise, the overall jump logic still follows the preset rules (such as always jumping from the highest peak to the second highest, third highest...), avoiding directional confusion caused by local position changes and ensuring the stability and predictability of the jump path.
[0103] In some embodiments, after determining the peak value in the real-time measured signal, the method further includes: Jump from the highest peak to the rightmost peak among the multiple peaks detected in real time, and mark the corresponding peak feature information; According to the order of the index values of each peak, jump from the rightmost peak to each peak detected in real time, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the leftmost peak among the multiple peaks detected in real time and stops.
[0104] Specifically, first determine whether the current peak is the highest. If not, jump to the highest peak by default and mark its corresponding peak feature information. Then, execute the Next Left Peak function.
[0105] Jump from the highest peak to the rightmost peak among multiple peaks detected in real time, and mark its corresponding peak feature information.
[0106] Furthermore, according to the order of the index values of each peak from large to small, jump from the rightmost peak to the peaks detected in real time, and mark the corresponding peak feature information each time it jumps to the peak, until it jumps to the leftmost peak among the multiple peaks detected in real time and stops after marking.
[0107] It can be inferred from the above that after determining the valley value in the real-time measured signal, the method further includes: Jump from the lowest valley value to the rightmost valley value among multiple valley values detected in real time, and mark the corresponding valley value feature information; According to the order of the index values of each valley value, jump from the rightmost valley value to each valley value detected in real time, and mark the corresponding valley value feature information each time jumping to the valley value until jumping to the leftmost valley value among the multiple valley values detected in real time.
[0108] The process of valley value jump and marking is the same as the process of peak value jump and marking. The specific process is as described above and will not be repeated here.
[0109] It should be noted that the Next Left Peak function forces a jump to the left. When using the Next Left Peak function, the signal is checked to see if the next peak / valley to jump to is on the left. If it is on the right due to noise, the jump is aborted. In practice, the signal-to-noise ratio of the measured signal is generally high, and noise-induced jump direction confusion is not guaranteed. The Next Left Peak function effectively addresses this situation.
[0110] This embodiment of the present invention uses the Next Left Peak function to jump and mark the peaks and valleys in order of index values, from the rightmost to the leftmost. This reverse-order traversal of the index values achieves complete coverage and orderly marking of peaks and valleys, avoiding noise-induced jump direction confusion while ensuring the complete collection of extreme value features. This significantly improves the stability of real-time peak and valley value tracking of the measured signal.
[0111] In some embodiments, after determining the peak value in the real-time measured signal, the method further includes: Jump from the highest peak to the leftmost peak among the multiple peaks detected in real time, and mark the corresponding peak feature information; According to the order of the index values of each peak, jump from the leftmost peak to the peaks detected in real time in sequence, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the rightmost peak among the multiple peaks detected in real time and stops.
[0112] Specifically, first determine whether the current peak is the highest. If not, jump to the highest peak by default and mark the corresponding peak feature information. Then, execute the Next Right Peak function.
[0113] Jump from the highest peak to the leftmost peak among multiple peaks detected in real time, and mark its corresponding peak feature information.
[0114] Furthermore, according to the index value of each peak from small to large, jump from the leftmost peak to each peak detected in real time, and mark its corresponding peak feature information each time it jumps to a peak, until it jumps to the rightmost peak among the multiple peaks detected in real time and stops after marking.
[0115] It can be inferred from the above that after determining the valley value in the real-time measured signal, the method further includes: Jump from the lowest valley value to the leftmost valley value among multiple valley values detected in real time, and mark the corresponding valley value feature information; According to the order of the index values of each valley value, jump from the leftmost valley value to each valley value detected in real time, and mark the corresponding valley value feature information each time it jumps to a valley value until it jumps to the rightmost valley value among the multiple valley values detected in real time.
[0116] The process of valley value jump and marking is the same as the process of peak value jump and marking. The specific process is as described above and will not be repeated here.
[0117] It's important to note that the Next Right Peak function forces a jump to the right. When using the Next Right Peak function, the system checks whether the next peak / valley to jump to is on the right. If it's on the left due to noise, the jump is aborted. In practice, the signal-to-noise ratio of the measured signal is generally high, and noise-induced jump direction confusion is not guaranteed. The Next Right Peak function effectively addresses this situation.
[0118] This embodiment of the present invention uses the Next Right Peak function to jump and mark the peaks and valleys in order of index values, from the rightmost to the leftmost. This sequential traversal of index values achieves complete coverage and orderly marking of peak and valley values, avoiding noise-induced jump direction confusion while ensuring the complete collection of extreme value features. This significantly improves the stability of real-time peak and valley value tracking of the measured signal.
[0119] The following is an experimental result diagram for the above peak and valley detection algorithm.
[0120] Figure 5 This figure shows the peak detection effect of a common signal provided by the present invention. Under the influence of 20dB additive Gaussian noise, the theoretical number of peaks should be 19. However, 18 true peaks were detected, 2 false peaks were detected, and 1 true peak was missed. The peak detection accuracy was 94.74%, the missed peak rate was 5.26%, and the false peak rate was 11.1%. This result meets the requirements of most practical measurement scenarios.
[0121] Figure 6This figure shows the valley detection effect of a common signal provided by the present invention. Under the influence of 20dB additive Gaussian noise, the theoretical number of valleys should be 21. However, 19 true valleys were detected, 2 false valleys were detected, and 2 true valleys were missed. The accuracy of valley detection was 90.48%, the missed valley rate was 9.52%, and the false valley rate was 10.53%. This result meets the requirements of most practical measurement scenarios.
[0122] Figure 7 The figure below is a schematic diagram of the peak detection effect of a square wave signal provided by the present invention. Under the influence of 35dB additive Gaussian noise, only one peak is detected on each square wave platform, meeting the needs of actual scenarios. At the same time, 15 of the 16 true peaks were detected and one was missed. The accuracy rate of peak detection was 93.57%, the missed peak rate was 6.25%, and the false peak rate was 0. This result meets the vast majority of requirements in actual measurement scenarios. The valley detection effect is also consistent and will not be repeated here.
[0123] The structure of the peak-valley value detection system provided by the present invention is described below. The peak-valley value detection system described below and the peak-valley value detection method described above can be referred to each other.
[0124] Reference Figure 8 , Figure 8 It is a structural schematic diagram of the peak-valley value detection system provided by the present invention.
[0125] like Figure 8 As shown, the peak-valley value detection system includes: A first determination module 810 is configured to traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides to determine a first target evaluation weight value for the window length; the candidate data point is determined based on the window length and the array length, and the array is composed of the amplitudes corresponding to multiple data points contained in the real-time measured signal; the first target evaluation weight value is used to reflect the effectiveness of detecting peaks or valleys under the condition of the window length; A window selection module 820 is configured to gradually increase the window length, iteratively perform the steps of comparing the amplitude of each candidate data point with the data points within the window lengths to its left and right, and determining a first target evaluation weight value for the window length until the window length reaches a preset length, and select an optimal window length from each window length based on the first target evaluation weight value for each window length; A second determination module 830 is configured to traverse and compare the amplitude of each target data point with the data points within the optimal window length on its left and right sides to determine a second target evaluation weight value for each target data point; the target data point is determined based on the optimal window length and the array length; the second target evaluation weight value is used to reflect the local significance of the target data point as a peak or valley value; The peak-valley value detection module 840 is configured to determine a peak value or a valley value in the real-time measured signal from each target data point based on a second target evaluation weight value of each target data point.
[0126] The peak-valley detection system provided by the present invention dynamically evaluates the effectiveness of peak-valley detection with different window lengths in the first cycle by traversing the increasing window length and calculating the first target evaluation weight value, and automatically selects the optimal window length adapted to the current signal characteristics without relying on manual parameter setting, thereby significantly improving the universality in different signal scenarios; the second cycle compares the left and right neighborhood amplitudes of the target data point based on the optimal window length, and quantifies its local significance as a peak-valley value through the second target evaluation weight value, which can not only accurately capture weak peaks, but also effectively suppress pseudo-peak interference; the synergy of the two cycle scoring makes the window adaptability performance of peak-valley detection extremely high, while maintaining low computational complexity to meet real-time processing requirements, thereby improving the accuracy and efficiency of peak-valley detection as a whole.
[0127] Furthermore, the first determining module 810 is further configured to: Traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides; In the process of traversing all candidate data points, if the amplitude of the current candidate data point is greater than the amplitude of the data points within the window length on its left and right sides, the first initial evaluation weight value of the window length is reduced until the traversal is completed and the first target evaluation weight value of the window length is obtained.
[0128] Furthermore, the window selection module 820 is further configured to: The window length corresponding to the minimum first target evaluation weight value among the first target evaluation weight values of each window length is determined as the optimal window length.
[0129] Furthermore, the peak-valley value detection module 840 is further configured to: determining a plurality of peaks from each target data point based on a second target evaluation weight value of each target data point; If the difference between the index values of two adjacent peaks is smaller than a preset value, the two adjacent peaks are merged into one peak to obtain multiple peaks in the real-time measured signal.
[0130] Furthermore, the peak-valley value detection system is also used for: Jump to the highest peak and mark its corresponding peak feature information; According to the target sorting result, jump from the highest peak to each peak detected in real time in sequence, and mark the corresponding peak feature information each time jumping to a peak; the target sorting result is updated based on multiple peaks detected in real time at each jump; the target sorting result is obtained by sorting the peaks with equal amplitudes in ascending order according to the index values corresponding to the peaks with equal amplitudes under the condition that there are at least two peaks with equal amplitudes in the initial sorting result; the initial sorting result is obtained by sorting the peaks in descending order based on the amplitudes corresponding to the peaks.
[0131] Furthermore, the peak-valley value detection system is also used for: Jump from the highest peak to the rightmost peak among the multiple peaks detected in real time, and mark the corresponding peak feature information; According to the order of the index values of each peak, jump from the rightmost peak to each peak detected in real time, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the leftmost peak among the multiple peaks detected in real time and stops.
[0132] Furthermore, the peak-valley value detection system is also used for: Jump from the highest peak to the leftmost peak among the multiple peaks detected in real time, and mark the corresponding peak feature information; According to the order of the index values of each peak, jump from the leftmost peak to the peaks detected in real time in sequence, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the rightmost peak among the multiple peaks detected in real time and stops.
[0133] It should be noted that the peak-valley value detection system provided by the present invention can execute the peak-valley value detection method described in any of the above embodiments during specific operation, which will not be described in detail in this embodiment.
[0134] Figure 9 Schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 9As shown, the electronic device can include a processor 910, a communications interface 920, a memory 930, and a communications bus 940, wherein the processor 910, the communications interface 920, and the memory 930 complete mutual communication through the communications bus 940. The processor 910 can invoke a logic instruction in the memory 930 to execute a peak-valley value detection method, which includes: traversing and comparing the amplitude of each candidate data point with the data points within the window length on the left and right sides thereof to determine a first target evaluation weight value of the window length; the candidate data point is determined based on the window length and the array length, and the array is formed based on the amplitudes corresponding to the plurality of data points included in the real-time measured signal; the first target evaluation weight value is used to reflect the effectiveness of detecting the peak value or the valley value under the condition of the window length; gradually increasing the window length, iteratively executing the step of traversing and comparing the amplitude of each candidate data point with the data points within the window length on the left and right sides thereof to determine the first target evaluation weight value of the window length, until the window length reaches a preset length, and selecting a best window length from each window length based on the first target evaluation weight value of each window length; traversing and comparing the amplitude of each target data point with the data points within the best window length on the left and right sides thereof to determine a second target evaluation weight value of each target data point; the target data point is determined based on the best window length and the array length; the second target evaluation weight value is used to reflect the local significance of the target data point as a peak value or a valley value; and determining the peak value or the valley value in the real-time measured signal from each target data point based on the second target evaluation weight value of each target data point.
[0135] In addition, the logic instruction in the memory 930 described above can be implemented in the form of a software function unit and sold or used as an independent product, which can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0136] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the peak and valley value detection method provided by the above embodiments, the method comprising: traversing and comparing the amplitude of each candidate data point with the data points within the window length on its left and right sides to determine a first target evaluation weight value of the window length; the candidate data point is determined based on the window length and the array length, and the array is composed of the amplitudes corresponding to multiple data points contained in the real-time measured signal; the first target evaluation weight value is used to reflect the effectiveness of detecting peaks or valleys under the condition of the window length; gradually increasing the window length, Iteratively perform the steps of traversing and comparing the amplitude of each candidate data point with the data points within the window length on its left and right sides, and determining the first target evaluation weight value of the window length, until the window length reaches a preset length, and selecting the optimal window length from each window length based on the first target evaluation weight value of each window length; traversing and comparing the amplitude of each target data point with the data points within the optimal window length on its left and right sides, and determining the second target evaluation weight value of each target data point; the target data point is determined based on the optimal window length and the array length; the second target evaluation weight value is used to reflect the local significance of the target data point as a peak or valley value; based on the second target evaluation weight value of each target data point, determine the peak or valley value in the real-time measured signal from each target data point.
[0137] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the peak-valley detection method provided in the above-mentioned embodiments, the method comprising: traversing and comparing the amplitude of each candidate data point with the data points within the window length on its left and right sides, and determining a first target evaluation weight value of the window length; the candidate data point is determined based on the window length and the array length, and the array is composed of the amplitudes corresponding to a plurality of data points contained in the real-time measured signal; the first target evaluation weight value is used to reflect the effectiveness of detecting peaks or valleys under the condition of the window length; gradually increasing the window length, iteratively executing the comparison of each candidate data point with the data points on its left and right sides. The amplitude of the data points within the window length on the right and left sides is used to determine the first target evaluation weight value of the window length, until the window length reaches a preset length, and based on the first target evaluation weight value of each window length, the optimal window length is selected from each window length; the amplitude of each target data point is compared with the data points within the optimal window length on its left and right sides to determine the second target evaluation weight value of each target data point; the target data point is determined based on the optimal window length and the array length; the second target evaluation weight value is used to reflect the local significance of the target data point as a peak or valley value; based on the second target evaluation weight value of each target data point, the peak or valley value in the real-time measured signal is determined from each target data point.
[0138] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Those skilled in the art will be able to understand and implement the present invention without inventive effort.
[0139] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0140] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A peak-valley value detection method, characterized in that: The peak-valley value detection method comprises: Traversing and comparing the amplitudes of each candidate data point with the data points within the window length on its left and right sides to determine a first target evaluation weight value of the window length; the candidate data point is determined based on the window length and the array length, and the array is composed of amplitudes corresponding to multiple data points contained in the real-time measured signal; the first target evaluation weight value is used to reflect the effectiveness of detecting peaks or valleys under the condition of the window length; gradually increasing the window length, iteratively performing the steps of traversing and comparing the amplitude of each candidate data point with the data points within the window lengths on its left and right sides, and determining a first target evaluation weight value of the window length until the window length reaches a preset length, and selecting an optimal window length from each window length based on the first target evaluation weight value of each window length; Traversing and comparing the amplitudes of each target data point with the data points within the optimal window length on its left and right sides to determine a second target evaluation weight value for each target data point; the target data point is determined based on the optimal window length and the array length; the second target evaluation weight value is used to reflect the local significance of the target data point as a peak or valley value; Based on the second target evaluation weight value of each target data point, a peak value or a valley value in the real-time measured signal is determined from each target data point.
2. The peak-valley value detection method according to claim 1, characterized in that: The traversal compares the amplitude of each candidate data point with the data points within the window length on its left and right sides, and determines the first target evaluation weight value of the window length, which includes: Traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides; In the process of traversing all candidate data points, if the amplitude of the current candidate data point is greater than the amplitude of the data points within the window length on its left and right sides, the first initial evaluation weight value of the window length is reduced until the traversal is completed and the first target evaluation weight value of the window length is obtained.
3. The peak-valley value detection method according to claim 2, characterized in that: The selecting the optimal window length from each window length based on the first target evaluation weight value of each window length includes: The window length corresponding to the minimum first target evaluation weight value among the first target evaluation weight values of each window length is determined as the optimal window length.
4. The peak-valley value detection method according to claim 1, characterized in that: The step of determining a peak value or a valley value in the real-time measured signal from each target data point based on the second target evaluation weight value of each target data point includes: determining a plurality of peaks from each target data point based on a second target evaluation weight value of each target data point; If the difference between the index values of two adjacent peaks is smaller than a preset value, the two adjacent peaks are merged into one peak to obtain multiple peaks in the real-time measured signal.
5. The peak-valley value detection method according to claim 1, characterized in that: After determining the peak value of the real-time measured signal, the method further includes: Jump to the highest peak and mark its corresponding peak feature information; According to the target sorting result, jump from the highest peak to each peak detected in real time in sequence, and mark the corresponding peak feature information each time jumping to a peak; the target sorting result is updated based on multiple peaks detected in real time at each jump; the target sorting result is obtained by sorting the peaks with equal amplitudes in ascending order according to the index values corresponding to the peaks with equal amplitudes under the condition that there are at least two peaks with equal amplitudes in the initial sorting result; the initial sorting result is obtained by sorting the peaks in descending order based on the amplitudes corresponding to the peaks.
6. The peak-valley value detection method according to claim 1, characterized in that: After determining the peak value of the real-time measured signal, the method further includes: Jump from the highest peak to the rightmost peak among the multiple peaks detected in real time, and mark the corresponding peak feature information; According to the order of the index values of each peak, jump from the rightmost peak to each peak detected in real time, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the leftmost peak among the multiple peaks detected in real time and stops.
7. The peak-valley value detection method according to claim 1, characterized in that: After determining the peak value of the real-time measured signal, the method further includes: Jump from the highest peak to the leftmost peak among the multiple peaks detected in real time, and mark the corresponding peak feature information; According to the order of the index values of each peak, jump from the leftmost peak to the peaks detected in real time in sequence, and mark the corresponding peak feature information each time it jumps to a peak, until it jumps to the rightmost peak among the multiple peaks detected in real time and stops.
8. A peak-valley value detection system, characterized in that: include: A first determination module is used to traverse and compare the amplitude of each candidate data point with the data points within the window length on its left and right sides to determine a first target evaluation weight value of the window length; The candidate data points are determined based on the window length and the array length, and the array is composed of amplitudes corresponding to a plurality of data points contained in the real-time measured signal; the first target evaluation weight value is used to reflect the effectiveness of detecting peaks or valleys under the condition of the window length; a window selection module configured to gradually increase the window length, iteratively perform the steps of comparing the amplitude of each candidate data point with the data points within the window lengths on its left and right sides, and determining a first target evaluation weight value for the window length until the window length reaches a preset length, and select an optimal window length from each window length based on the first target evaluation weight value for each window length; A second determination module is used to traverse and compare the amplitude of each target data point with the data points within the optimal window length on its left and right sides to determine the second target evaluation weight value of each target data point; The target data point is determined based on the optimal window length and array length; the second target evaluation weight value is used to reflect the local significance of the target data point as a peak or valley value; The peak-valley value detection module is used to determine the peak value or valley value in the real-time measured signal from each target data point based on the second target evaluation weight value of each target data point.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the peak-valley value detection method according to any one of claims 1 to 7 are implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the peak-valley value detection method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Data processing method and device, storage medium and electronic equipment
CN111797880A
Target detection method and device, electronic equipment and storage medium
CN112966683A
Multi-window spectrum peak identification method and device based on signal-to-noise ratio, medium and product
CN115078616A
Exoskeleton motion signal peak valley detection method and system based on sliding window variance
CN115758203A
Multi-scale filtering weighted peak value extraction method
CN115795349A