Complement lines feature detector with a better adaptive thresholded. Clean up the code.

Signed-off-by: Ievgen Varavva <yvaravva@google.com>