Ask Your Question
1

completing characters to get their contour

asked 2017-10-10 04:20:55 -0600

Finch gravatar image

Hi guys, at the moment I am working on OCR using opencv in c++. After processing my image I get something like this:

image description

The problem is that the pixels of the display have a big distance between each other so filtering results in not fully connected characters. I tried to play with dilate but it makes the characters way too big. Do you have an idea how to solve my problem?

I thought about writing my own little algorythm which connects contours (or their moments) if the distance between them is at a certain length but I am pretty sure there is an easier way which I just didn't think of yet.

Finch

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2017-10-11 21:15:59 -0600

Ziri gravatar image

If using Opencv OCR is not necessary try training your images so you don't need to preprocess.

edit flag offensive delete link more

Comments

Test answer

mshabunin gravatar imagemshabunin ( 2017-10-12 08:22:28 -0600 )edit

test comment

Finch_the_second gravatar imageFinch_the_second ( 2017-10-12 08:47:57 -0600 )edit
0

answered 2017-10-11 06:53:06 -0600

updated 2017-10-11 06:56:06 -0600

Wait wait wait. if you first dilate until connection and then apply equal iterations of erosion again, you will have a perfect fixed result right? Try the inbrowser javascript sample and be amazed about the possibilities.

And even if the erosion part destroys the connection again, after dilation you can always apply the thinning operators.

edit flag offensive delete link more

Comments

Alright, for some reason my other acc doesn't work so I created this one. The erosion/dilation works pretty good for "unique" character but characters like "1" "I" "i" "l" are really hard to distinguish because dilate/erode are smoothing the endges too much.

I will try the thinning and also will try to adjust some parameters, maybe I get a satisfying result.

Finch_the_second gravatar imageFinch_the_second ( 2017-10-13 04:29:27 -0600 )edit
1

Well covering i, l and 1 is the worst case for any OCR application and also the most challenging ones...

StevenPuttemans gravatar imageStevenPuttemans ( 2017-10-13 07:00:48 -0600 )edit

I tried thinning today with all possible algorithms. Either they open up the connection or they randomly add lines where there should not be lines. It seems like I have to live with dialte/erode and need to handle potential incorrect readings afterwards.

Finch_the_second gravatar imageFinch_the_second ( 2017-10-19 08:33:58 -0600 )edit
0

answered 2017-10-10 07:23:50 -0600

LBerger gravatar image

Yes using closing or openning does not solve your problem.

You can try connectedComponentsWithStat and use gravity center to look for nearest neighbours. Then you can can fixed a distance threshold to connect components.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-10-10 04:20:55 -0600

Seen: 110 times

Last updated: Oct 12