Ask Your Question
0

How to eliminate Text underline?

asked 2020-11-19 06:32:19 -0600

kst gravatar image

updated 2020-11-30 07:08:44 -0600

berak gravatar image

I have a scanned document which I will like to remove the underlined text before I run OCR through it. The reason why I need to remove the underline is because I noticed the accuracy of the OCR to recognize is bothered by the underlined.

C:\fakepath\Unline.PNG

For example, in the attached image, if I removed the underlines, the 2 dates can be recognized accurately else, one of the dates is not recognizable.

Any python sample code is much appreciated.

C:\fakepath\MC.PNG

Thanks

edit retag flag offensive close merge delete

Comments

What did you try? Did you bother to search for a solution?

Hint: the HoughLinesP function is what you are looking for. Here's a tutorial, just change the line color to white: python tutorial

kbarni gravatar imagekbarni ( 2020-11-19 11:32:05 -0600 )edit

I did some searches on possible solutions. I also tried the HougLinesP function as you shared. Also tried "contours" way of looking for lines in the image. But the result wasn't satisfactorily. For example, I got extra line created.

kst gravatar imagekst ( 2020-11-19 17:49:01 -0600 )edit

@kst. I deleted my answers. Because, u didn't providing second image(invalid date stamp). The first image will work w/out underline. How will I know if one of the dates is not recognizable. Even if it is both underlined or just one underline.

supra56 gravatar imagesupra56 ( 2020-11-20 07:02:05 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-11-24 02:58:40 -0600

berak gravatar image

have a look at the morphology tutorial

a long horizontal kernel should do the trick.

edit flag offensive delete link more

Comments

I tried the code and the text in the image got wiped out. I am new in opencv. Not sure how to fix the problem.

I just downloaded a sample "Medical Certificate" (MC.png) which I googled and attached. There is underline and I am trying to remove it.

kst gravatar imagekst ( 2020-11-30 06:57:16 -0600 )edit

one of the problems is that your example images are badly scanned, not perfectly horizontal, even with a "fold" in it. you can't make gold from shite, you know ?

berak gravatar imageberak ( 2020-11-30 07:09:28 -0600 )edit

I know what you meant. However, this is not something I can control. Sometime the line is not a perfect straight line. It might be slanted slightly. That's the real world dude ! if it is a perfectly straight line, isn't it easy to solve.

kst gravatar imagekst ( 2020-12-02 07:59:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-11-19 06:32:19 -0600

Seen: 1,423 times

Last updated: Nov 30 '20