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.
These are leftovers from the initial PR, that have not been implemented. I'm not sure tags like 'parallel', 'perpendicular', would be of much use. Removing them.