I would like to extract straight lines from a 2D binary matrix.
I would to find 1s grouped by neighbor coordinates.
In the attached image, there is a 256x128 binary matrix.
4 straight lines can be extracted from the given example.
After finding all grouped 1s, I would like to have a vector [x1,y1,x2,y2] which contains 2 edge coordinates.
In the given example, there should be 4 vectors of course.
There is no chance that they can cross themselves.
Matrix always contains shapes similar to straight lines.
Language does not matter, preferably Python code.
I tried to use numpy and scipy.spatial.distance libraries to create a solution but failed.
Which techniques I should use, or which libs/functions I should look into?
Thanks in advance.