title: Define distance between lines
body: <p>i'm very new to Python and i'm trying to define hand drawn lines in illustrations, as the code i've written shows, after i blur, erode and do a threshold to an image with cv2.Canny those that appears as lines to our eyes are parallel in the code </p>
  
  <p>(this line <a href="https://i.stack.imgur.com/A2AYO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A2AYO.png" alt="line"></a> appears like this <a href="https://i.stack.imgur.com/lTnZH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lTnZH.png" alt="this"></a>)</p>
  
  <p>I then display only the parallel ones but i don't know how to define a min and max distance value (in pixel)</p>
  
  <p>Any help please?</p>
  
  <p>This is what i've written so far:</p>
  
  <pre><code>import numpy as np
  import cv2
  import time
  import math
  start_time = time.time()
  
  base = cv2.imread('prova/eq.jpg')
  gray = cv2.cvtColor(base, cv2.COLOR_BGR2GRAY)
  img = cv2.bilateralFilter(gray, 9, 90, 1)
  
  kernel = np.ones((2,2), np.uint8)
  img_dilation = cv2.dilate(img, kernel, iterations=2)
  img_erosion = cv2.erode(img, kernel, iterations=4)
  
  edges = cv2.Canny(img_erosion,cv2.THRESH_BINARY+cv2.THRESH_OTSU,550,apertureSize = 3)
  #edges = cv2.Canny(gray,1,250,apertureSize = 3)
  
  
  cv2.imwrite('edges.jpg',edges)
  
  
  minLineLength=50
  maxLineGap=10
  threshold=20
  
  image=edges
  
  lines = cv2.HoughLinesP(image=image,rho=1,theta=np.pi/180, threshold=threshold,lines=np.array([]), minLineLength=minLineLength,maxLineGap=maxLineGap)
  
  angles = []
  for x1,y1,x2,y2 in lines[0]:
      theta = math.atan(float(y2 - y1) / (x2 - x1))
      angles.append({'theta': theta, 'p1': (x1, y1), 'p2': (x2, y2)})
  
  for i in range(len(angles)):
      for j in range(i + 1, len(angles)):
          delta = abs(angles[i]['theta'] - angles[j]['theta'])
          if delta &lt; 0.01:
              print(delta)#, angles[i], angles[j])
              cv2.line(base, angles[i]['p1'], angles[i]['p2'], (0, 0, 255), 2, cv2.CV_AA)
              cv2.line(base, angles[j]['p1'], angles[j]['p2'], (255, 0, 0), 2, cv2.CV_AA)
  
  
  
  
  
  
  a,b,c = lines.shape
  #for i in range(a):
  #    cv2.line(base, (lines[i][0][0], lines[i][0][1]), (lines[i][0][2], lines[i][0][3]), (0, 0, 255), 13, cv2.CV_AA)
  
  cv2.imwrite('prova/prova.jpg',base)
  
  
  print("--- %s seconds ---" % (time.time() - start_time))
  </code></pre>