Ask Your Question
0

How do I detect thinner/gray lines in a table?

asked 2018-12-24 00:31:40 -0600

opencv-newb gravatar image

Context :http://answers.opencv.org/question/63847/how-to-extract-tables-from-an-image/

I have done the above to extract tables from images.

The problem happens when there are gray row lines with very bold dark column lines. The above approach detects the very bold dark column lines but it misses the less bold, gray-er row lines. I do OTSU thresholding before finding contours. The thresholding removes those gray lines before finding contours.

How do I extract such lines?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-12-24 06:12:52 -0600

kbarni gravatar image

I couldn't test the next ideas, but (at least some of them) they should work. Probably you'll have to experiment a bit to find the right parameters.

First, I suggest to do a gamma adjustment as preprocessing; it should darken the grey lines to make them more visible:

out = in ^ gamma

where in is normalized between 0..1 and gamma>1.

To detect the lines, you can use a Sobel filter and get the regions where abs(Gx) is high and Gy=0 (for vertical lines) and abs(Gy) is high and Gx=0 (for horizontal lines).

Another possibility is to create some convolution kernels that respond to the horizontal and vertical lines. For example:

-1 -1 5 -1 -1
-1 -1 5 -1 -1
-1 -1 5 -1 -1

and

-1 -1 -1
-1 -1 -1
 5  5  5
-1 -1 -1
-1 -1 -1

You can make them 3x3, 5x5 and so on. They should highlight the lines.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-12-24 00:31:40 -0600

Seen: 1,145 times

Last updated: Dec 24 '18