I think you can solve your problem by using HoughTransfor
- Use the function called HoughTransform.
- The function will find 2 lines Line1 and Line2.
- Get the muse click position on the image say it Pointxx.
- Find the prependicular distances from Pointxx to Line1 and Line2.
- The line which has minimum prependicular distance is the line you need.
- Draw the line on the image.