improve performance to detect lines in image