I have a binary image, I want to detect discontinuous lines and linking them. 
I don't know anything (coordinates, angle etc). 
Can any one guide me how should I start? Suppose I have this image:

![enter image description here](https://i.stack.imgur.com/9UFWc.png)

I want to join discontinuous lines. And I want to store information of lines joining (in an array) to use afterward.