title: Removing long horizontal/vertical lines from edge image using OpenCV
body: <p>How can I use standard image processing filters (from OpenCV) to remove long horizontal and vertical lines from an image?</p>
  
  <p>The images are B&amp;W so removing means simply painting black.</p>
  
  <p>Illustration:</p>
  
  <p><img src="https://i.stack.imgur.com/dStpj.png" alt="illustration of required filter"></p>
  
  <p>I'm currently doing it in Python, iterating over pixel rows and cols and detecting ranges of consecutive pixels, removing those that are longer than N pixels. However, it's really slow in comparison to the OpenCV library, and if there's a way of accomplishing the same with OpenCV functions, that'll likely be orders of magnitude faster.</p>
  
  <p>I imagine this can be done by convolution using a kernel that's a row of pixels (for horizontal lines), but I'm having a hard time figuring the exact operation that would do the trick.</p>