1

I am trying to extract coordinates for each cell from a tabular image in grayscale using cv2.findContours

But I'm not able to get exact tables due to gaps in between lines. I tried with cv2.dilate followed by cv2.erode with both horizontal and vertical kernels of size (1, 5) and (5, 1) but before filling the gaps lines become thick enough to fill the cell.

Please look at the image to get the idea. Updated image

Community
  • 1
  • 1
No_Name
  • 85
  • 6
  • I couldnt understand the exact problem. Why ```erode``` and ```dilate``` and what for? – Yunus Temurlenk Aug 06 '20 at 17:46
  • 1
    @YunusTemurlenk I have updated the image have a look, please. – No_Name Aug 06 '20 at 20:01
  • Please check if [this](https://stackoverflow.com/questions/43859750/how-to-connect-broken-lines-in-a-binary-image-using-python-opencv) solves your problem. – Aravind Aug 06 '20 at 20:15
  • You can detct the joints first by using a similar approach like [here](https://stackoverflow.com/questions/60633334/how-to-detect-corner-joints-that-connect-elements-on-images). Then you can complete those uncompleted lines by adding pixels to their end until joints – Yunus Temurlenk Aug 07 '20 at 06:15
  • Btw this seems a goog problem, you can make this question also be better by editing – Yunus Temurlenk Aug 07 '20 at 06:15
  • To connect broken lines/edges based on contour extremities have a look at this https://stackoverflow.com/questions/71811385/connecting-disjointed-lines-or-edges-in-binary-images/71816288#71816288 – Jeru Luke Apr 23 '22 at 16:18

0 Answers0