title: How to plot the shortest distance between two lines passing through an arbitrary point using OpenCV in Python?
body: <p>I have a picture with lines drawn on it.</p>
  <p>And, I want to draw a straight line with the shortest distance between two lines passing through an arbitrary point.
  with <strong>Python OpenCV</strong></p>
  <p>This is a code that can extract green from the original image and draw dots with mouse from the thinned image.</p>
  <pre><code>import numpy as np
  import cv2
  def on_mouse(event, x,y,flags,param):
     if event == cv2.EVENT_LBUTTONDOWN:
        cv2.line(img,(x,y),(x,y),(255,0,0),2)
        cv2.imshow('thinned',thinned)
  
  def colorPickandThinning(img):
     height, width = img.shape[:2] 
  
     img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) 
   
     lower_green = (40,60,0) 
     upper_green = (80, 255, 255) 
     img_mask = cv2.inRange(img_hsv, lower_green, upper_green)
  
     img[:, :, 0] = 0
     img[:, :, 2] = 0
     img[:, :, 1] = img_mask
     img_temp = img
  
     # filtering image nosiecancel
     noisecancel = cv2.fastNlMeansDenoisingColored(img_temp,None,49,57,7,21)
     cv2.imshow('noise',noisecancel)
  
     #thinning
     thinned = cv2.ximgproc.thinning(cv2.cvtColor(noisecancel,cv2.COLOR_RGB2GRAY))
  
     return thinned
  
  img = cv2.imread('test_img.jpg')
  thinned = colorPickandThinning(img)
  cv2.imshow('thinned',thinned)
  cv2.setMouseCallback('thinned',on_mouse,thinned)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>
  <p>This is a result picture and I drew a dot with the mouse.</p>
  <p><a href="https://i.stack.imgur.com/mdG9P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mdG9P.png" alt="enter image description here" /></a></p>
  <p>I want to draw like this picture.</p>
  <p><a href="https://i.stack.imgur.com/bR0VH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bR0VH.jpg" alt="enter image description here" /></a></p>