lsd optimization: segment detection part