title: Extract lined table from scanned document opencv python
body: <p>I want to extract the information from a scanned table and store it a csv. Right now my table extraction algorithm does the following steps.</p>
  
  <ol>
  <li>Apply skew correction</li>
  <li>Apply a gaussian filter for denoising.</li>
  <li>Do a binarization using Otsu thresholding</li>
  <li>Do a morphological opening.</li>
  <li>Canny egde detection</li>
  <li>Do a hough transform to obtain lines of table.</li>
  <li>Remove duplicate lines( same lines in the range of 10 pixels)</li>
  <li>filter the horizontal and vertical lines using slope of line(slope should be less than +/-5 degree for horizontal and normal of verticals).</li>
  </ol>
  
  <p>This algorithm is working fine for digital born pdfs and most of the scanned documents. But, Some of the documents have a noisy table and thus its not identifying the lines correctly.</p>
  
  <p>Here is a sample image in which my algorithm fails.</p>
  
  <p><a href="https://i.stack.imgur.com/f8GOA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f8GOA.jpg" alt="raw image"></a></p>
  
  <p>These are the operations I am doing on this table.
  1.Gaussian blur</p>
  
  <p><a href="https://i.stack.imgur.com/OJzYY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OJzYY.jpg" alt="Gaussian blur"></a></p>
  
  <p>2.Otsu thresholding</p>
  
  <p><a href="https://i.stack.imgur.com/hBUnZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hBUnZ.jpg" alt="Otsu thresholding"></a></p>
  
  <p>3.Morphological opening </p>
  
  <p><a href="https://i.stack.imgur.com/q8UBQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q8UBQ.jpg" alt="Morphological opening"></a></p>
  
  <p>4.Canny edge detection </p>
  
  <p><a href="https://i.stack.imgur.com/eyewa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eyewa.jpg" alt="Canny edge detection"></a></p>
  
  <p>5.filtered lines,as you can see the lines are clearly not identified 
  correctly. </p>
  
  <p><a href="https://i.stack.imgur.com/8UI60.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8UI60.jpg" alt="filtered lines,as you can see the lines are clearly not identified correctly."></a></p>
  
  <p>Can anyone please suggest better method for extracting horizontal and vertical lines from this kind of less quality scans.</p>
  
  <p>Thanks in advance!!</p>