I have a pair of similar scanners from different manufacturers. The task relates to 2D (so far away from 3D).

When data is requested, a packet (one-dimensional array) of ~ 1000 dimension comes, for each point, two values ​​are the first X and the second Y.

EXAMPLE OF MASSIF (the view on the chart will be, a line with a small slope)

[25,354; 40,250; 25,599; 40,942; .......... 50,304; 42,231]

In the first case, you need to find the following point (in the picture marked with blue): enter image description here
But it should not be just a maximum of an array. In fact, these are 4 lines (from an array of points), the algorithm must unite the points in a line and, based on the number of lines found, look for something defined on them or in them (middle, gap between the first and second)

The parameters that can be changed in the algorithm are the half-width of the line (distance from noise to the calculated line), before the algorithm combines them in a line, it also looks at the maximum distance from a point to a point and decides whether to include it in a line or not.

I use the method of least squares, but it works only with straight lines. and that is not entirely correct. How to merge points into lines and then operate with lines? Because my algorithm works once out of a hundred.

example of the scanner on the link (tyk in me) !

  • Just give an array of data, preferably with the most difficult situations. - Yuri Negometyanov
  • @Yuri Negometyanov did not quite understand you comes a regular one-dimensional array of ~ 1000 elements of which 500 values ​​for X and 500 for Y [X1, Y1, X2, Y2, X3, Y3 ........ X500, Y500] in second comes about 500 packets with such coordinates - Aleksander Tozik
  • Just correct the question - put there an array corresponding to the picture. This is usually done, since third-party links are not always stable. - Yuri Negometyanov February
  • @Yuri Negometyanov corrected himself - Aleksander Tozik February
  • Did it all work out? - Yuri Negometyanov February

1 answer 1

In general, the processing algorithm should be as follows:

  1. Evaluate data trend using a sliding median filter . Processing is carried out only on the Y coordinate.
  2. Calculate the divided differences by the median trend.
    Maximum modulo values ​​of a divided first-order difference
    (y i + 1 -y i ) / (x i + 1 -x i ) , calculated according to the trend, indicate the points of discontinuity of the function.
  3. Calculate the variable component (the difference between the original data and the obtained trend). The maxima of the sum of modules of this magnitude at 3-5 points signal the breaking of the function.
  4. The data fragments selected in PP.2-3 can be approximated by smooth dependencies (including the least squares method). Without the separation of fragments, the use of the sum of squares instead of the sum of the modules according to claim 3 gives less stable statistics.
  • If the step on X is almost constant, then simple differences can be calculated, but not separated. - Yuri Negometyanov February