Line detection PR #2 follow-up.

This PR includes #2 rebased on top of current HEAD + a commit that cleans up the code and adds an improved adaptive thresholding routine.
I think that we should try kind of adaptive filtration to filter out false positives.

For example (very stupid one, just out of the top of my head), we might use only lines that longer than 50% of a longest line found.

Another fruitful idea here is to build histogram for angles (say, with bucket of 3-5 degrees), find the biggest peak and filter out everything except lines of this angle it and their neighbors + the same angle + 90 degrees