title: Remove small lines detected by OpenCV HoughLines
body: <p>I am trying to detect lines from noisy image and as a result I get too many lines. I need to iterate through lines multiple times and this is just too slow with so many lines, I am only interested in lines that are long enough. </p>
  
  <p>My code to detect lines is as follows:</p>
  
  <pre><code>// Edge detection
  int lowThreshold = 35;
  Canny(greyMat, dst, lowThreshold, lowThreshold * 3, 3);
  cv::blur(dst, dst, cv::Size(2,2));
  // Standard Hough Line Transform
  std::vector&lt;cv::Vec2f&gt; lines; // will hold the results of the detection
  HoughLines(dst, lines, 1, rho_resolution, 150, 0, 0 ); // runs the actual detection
  </code></pre>
  
  <p>My source image is <a href="https://i.stack.imgur.com/eYNAv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eYNAv.png" alt="source image"></a></p>
  
  <p>And the resulting image from Canny is <a href="https://i.stack.imgur.com/5Ne2Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Ne2Q.png" alt="result image from Canny"></a></p>
  
  <p>HoughLines will detect 100 lines, I am only interested in the long ones in the middle that form a rectangle. How can I remove the short lines? If I increase Canny threshold some lines I need are not detected.</p>