One-component peak mounting

I have a one-dimensional array of floating point values ​​(C # doubles FYI), and I need to find the "peak" of the values ​​... as if graph.

I cannot just take the highest value, since the peak is actually a plateau with slight fluctuations. This plateau is in the midst of noise. I am looking for a solution that will give me the center of this plateau.

An example array might look like this:

1,2,1,1,2,1,3,2,4,4,4,4,5,6, 8,8,8,8,7,8,7,9,7 , 5,4,4, 3,3,2,2,1,1,1,1,1,2,1,1,1,1,1

where the peak is somewhere in the bold section.

Any ideas?

+6
math c # algorithm
source share
4 answers

You need to first determine what you mean by "small." Say a "small" wobble around a maximum is defined as any value that is inside the ± plus ε maximum. Then, a direct definition of the plateau.

Go through the data to identify the maximum, and then do a second pass to identify all the values ​​that are inside the ± plus ε maximum.

+3
source share

You can apply a low-pass filter to your input array to smooth out small fluctuations, then find the peak in the filtered data. The simplest example is probably a “boxer,” a filter where the output value is the sum of the input values ​​at a certain distance from the current position of the array. In pseudocode, it will look something like this:

for i = 0, samplecount-1 if (i < boxcar_radius) or (i >= (samplecount - boxcar_radius)) then filtered_data[i] = 0 // boxcar runs off edge of input array, don't use else filtered_data[i] = 0 for j = i-boxcar_radius, i+boxcar_radius filtered_data[i] = filtered_data[i] + input_data[j] endfor endif endfor 

If you have an idea of ​​how wide the “plateau” will be, you can choose the radius of the frame (about half the expected width of the plateau) to detect objects at an appropriate scale.

+6
source share

Peak detection is one of the steps in Phase Correlation and other motion estimation algorithms used in places like video compression. One approach is this: consider a candidate for the top and window of a certain number of neighbors. Now apply the quadratic function using standard regression. The peak with subpixel accuracy is at the maximum set quadratic.

+2
source share

Obviously, the exact solution depends on the details. If your distribution is always nice, as in your example, you can:

 def GetPeak(l): large = max(l) * 0.8 above_large = [i for i in xrange(len(l)) if l[i] > large] left_peak = min(above_large) right_peak = max(above_large) return (left_peak, right_peak) 
+1
source share

All Articles