I have a large set of random points, $(x_i,y_i)$, which, for unknown reasons, seem to align along certain lines:
I want to calculate the slope of those lines (also their other parameters, but I'm asking about the slope here)
Separating the lines algorithmically, seems to be too complex. I guess that I would need a classification algorithm, and those never give stable results.
That's why I am only talking about the slope.
What I did:
I made a synthetic sample generating random lines:
The average point $\color{blue}{(c_x,c_y)}$ is drawn in blue, and on this chart, the lines have $-45$° angle.
I have the intuition that the sum of all points distances to a line passing by the blue point, should be maximal/minimal when the line matches the slope I'm looking for (or the perpendicular slope).
I calculated the distance summed of all points to a line passing for the center, with angle $\alpha$, for different angles (from $0$ to $360$), and I got this chart:
I drawn the point lines at $-45$°, and the distance seems to be maximal just around the normal angle $+45$, so it suggest that I could use a maximization solver to find the slope normal to the lines, by maximizing the distance of all points to a line passing by the center (blue point).
It seems to work for different angles I tried, but I'm not sure if that's a correct procedure.
Also, the distance is not minimal when the slope $\tan(\alpha)$ is parallel to the lines.
EDIT: I just noticed that if the points are clustered in two distant groups, independent of the orientation of the lines, the maximum distance would be the one separating the groups. Maybe Fourier transforms would be able to detect the orientation of the lines?







The method employed by us:
- Convert the picture issued by the OP to Windows Bitmap format
- Load the BMP file into a computer program, developed for the purpose
- Map the color content onto real (double precision) numbers
- Define a zero level of this mapping; in our case white = - 0.2
- Define empirically limitations for the area that looks interesting
- Use a contouring module for making isolines at level zero
- Use all sort of limitations for distinguishing relevant data from the rest
- Calculate second order moments (variances) for the relevant isolines
- Take a look at the theory in the webpage Two-dimensional Moments
- Especially take notice of the formula $\;\tan(2 \theta) = 2 \sigma_{xy}/(\sigma_{xx} - \sigma_{yy})$
- Calculate mean value $\pm$ spread of relevant angles $\alpha=-\theta$ and Output
The numerical end result obtained is: Picture produced:Note.
A more robust method may be to consider instead the angles of the minor axes of the ellipses of inertia $\;\sigma_{yy}(x-\mu_x)^2-2\sigma_{xy}(x-\mu_x)(y-\mu_y)+\sigma_{xx}(y-\mu_y)^2=\sigma_{xx}\sigma_{yy}-\sigma_{xy}^2\;$ with the x-axis.
Free accompanying source-only software (Delphi Pascal) has been made available at the site: MSE publications / references 2021
Disclaimer. Anything free comes without guarantee :-(and without referee)