title: Hough Lines detecting too many lines
body: <p>I am trying to extract the vertical lines from the fabric image using hough lines in opencv. I applied contrast enhancement to enhance the lines and bilateral filtering to try and remove the other fabric textures. However, on applying the houghlines, the code detects lines all over the image. I tried playing around with the parameters for hough but the results were the same.</p>
  
  <p>Input image after applying histogram equalization and bilateral filter:</p>
  
  <p><a href="https://i.stack.imgur.com/nQneb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nQneb.png" alt="enter image description here"></a></p>
  
  <p>Here is the image after applying the hough line, red representing the detected lines.
  Output showing hough detections:</p>
  
  <p><a href="https://i.stack.imgur.com/kJUKl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kJUKl.png" alt="enter image description here"></a></p>
  
  <p>What is another approach I can try so that the hough does not start detecting the minute fabric patterns as lines as well?</p>
  
  <p>Here is the code I have:</p>
  
  <p>`</p>
  
  <pre><code>    img1= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
      img2 = cv2.equalizeHist(img1)
      img3 = cv2.equalizeHist(img2)
      img4 = cv2.equalizeHist(img3)
      img5 = cv2.bilateralFilter(img4, 9, 75,75)
      cv2.imshow("threshold",img5)
      edges = cv2.Canny(img4,50,127,apertureSize = 3)
      lines= cv2.HoughLines(edges, 1, math.pi/180.0, 200, np.array([]), 0, 0)
      a,b,c = lines.shape
      for i in range(a):
          rho = lines[i][0][0]
          theta = lines[i][0][1]
          a = math.cos(theta)
          b = math.sin(theta)
          x0, y0 = a*rho, b*rho
          pt1 = ( int(x0+1000*(-b)), int(y0+1000*(a)) )
          pt2 = ( int(x0-1000*(-b)), int(y0-1000*(a)) )
          cv2.line(img, pt1, pt2, (0, 0, 255), 2, cv2.LINE_AA)
  
  cv2.imshow('image1',img)
  cv2.waitKey(0)
  cv2.destroyAllWindows()`
  </code></pre>