Principal Component Analysis (PCA) can be used to determine average edge direction due to the inherently linear structure of the image. Five small regions are randomly selected in the image. Each of them is centered on a data point, so we are guaranteed to have some "edge" points inside the region.
PCA is performed for each region and resulting directions (e.vectors of respective covarience matrix) are compared to determine the direction for majority of regions.
After the edge direction has been determined all data is projected on axis perpendicular to the edges. These perpendicular components are nicely separated for different edges allowing us to use K-Means clusterization for individual edge assignment.