Add optional logging.
Add logging and rename variable to avoid namespace collision.
Change lines API to move thresholding and thinning to caller.