1

I am new to do image precessing. I am trying to remove the dash lines and dotted lines from the images using cv2 in python, but have some difficulties.

What I have tried:

(1) I got some idea from How to remove horizontal and vertical lines from an image , to remove the lines in the image. So I want to plot the dash lines into lines, and then, remove them. I used the Hough Tranform (Python How to detect vertical and horizontal lines in an image with HoughLines with OpenCV?) and (opencv detect dotted lines), but it introduces a lot of unnecessary lines that mess up all the numbers and words. I tuned the 'minLineLength' and 'maxLineGap' but do not help. The reason for these is there are some points in the words and numbers have the same 'maxLineGap' as the dash lines, so there are all plotted into lines. So if I remove the lines, I would remove the part of characters and numbers that have lines, such as 'Liabilities' and '28,056,622'.

(2) I tried to use:

horizontalStructure = cv2.getStructuringElement(cv2.MORPH_RECT, (horizontalsize,1))

But I am not sure how to represent dash lines pattern, and CV_SHAPE_CUSTOM is not available in the cv2.

Please provide me with some suggestions. Thanks!

The original file enter image description here

The image after I plot line accross the dash lines

enter image description here

tairen
  • 379
  • 3
  • 9

1 Answers1

1

This is quite old post however if in case useful to someone. Use cv2.dilate to get dotted line into a straight line followed by cv2.getStructuringElement to remove the lines. Experiment with the dilate iterations in cv2.dilate and horizontal line size within cv2.getStructuringElement for better results. If dilation affects the characters/digits, create a mask using cv2.bitwise methods (and, or, xor) and apply only the mask over lines. hth!

Arun
  • 421
  • 3
  • 6