title: Removing slant horizontal lines in image
body: <p><a href="https://i.stack.imgur.com/KRWLL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KRWLL.jpg" alt="original image"></a></p>
  
  <p>I have an image where I have a horizontal line underlying the text ; after applying through various techniques in order  a. HoughLineP and HoughLine and this code</p>
  
  <pre><code> image = cv2.imread('D:\\detect_words.jpg')
   gray = 255 - cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
   for row in range(gray.shape[0]):
      avg = np.average(gray[row, :] &gt; 16)
      if avg &gt; 0.25:
          cv2.line(image, (0, row), (gray.shape[1]-1, row), (0, 0, 255))
          cv2.line(gray, (0, row), (gray.shape[1]-1, row), (0, 0, 0), 1)
    cv2.imwrite('D:\\words\\final_removed.jpg',image)
  </code></pre>
  
  <p>I am able to get to this 
  <a href="https://i.stack.imgur.com/p5ji2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p5ji2.jpg" alt="after processing"></a></p>
  
  <p>after this phase; I am applying erosion and dilation </p>
  
  <pre><code>kernel = np.ones((3,3), np.uint8) 
  img_erosion = cv2.erode(255-gray, kernel, iterations=1) 
  img_dilation = cv2.dilate(img_erosion, kernel, iterations=1) 
  cv2.imwrite('D:\\words\\final_removed4.jpg',255-img_dilation)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ScYho.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ScYho.jpg" alt="final image after dilation and erosion"></a></p>
  
  <p>My question is; removing the horizontal lines although removes but there is pixel loss for words; and not all the horizontal lines are removed. Is there a novel approch where this loss can be minimized and all horizontal lines are removed (here the horizontal lines above AGE is still present).</p>