In the past few monthsR & D department of the companyAs an intern in pattern recognition, I have learned a lot about OCR and technology. Thank you for your guidance from teacher Lu, sun, and other teachers. I like it very much. You have gained a lot from me.
OCR (Optical Character Recognition) optical character recognition is a processing technique used to obtain character information in an image, it is a technology that converts image data with text information into text data. There are many places in our lives, such as electronic eye (License Plate Recognition) and youdao Dictionary (Image Word Recognition) on the highway.
OCR can be identified in the following steps: character detection, noise reduction, tilt correction, layout analysis, text cutting, character recognition, correction, post-processing, etc. The stroke filter is a filter used for OCR pre-processing to remove noise. It can filter out the less distinctive parts of the image, while retaining the more obvious parts of the text. It is a common method for character detection and background denoising.
TheDefinitionSimple:
First, define the stroke response. For a given angle Alpha and distance parameter D (), the response of a pixel (expressed in small R) is:
U1, U2, and U3 represent the pixel sum in the rectangle No. 1, 2, and 3. the denominator is a parameter proportional to the pixel variance distribution in the rectangle No. 1, and B Indicates bright, this is the case of white and black characters. Intuitively, if the current pixel (X, Y) is a stroke pixel pointPixel andThe pixel difference between the two and the third rectangle is relatively large, and the difference between the two and the third rectangle is small, so the response will reach the maximum value at the position of the stroke pixel. However, because the direction of the current stroke is different from the font size, you need to adjust Alpha and D to find the maximum value.
The following task is to find the maximum value, as shown in the first line (the last two rows are not required for subsequent SVM classification. For details, refer to this paper ), the response of a pixel (represented by a large R) is the maximum R value in the response set corresponding to all possible values of alpha and D, that is, the R of the pixel. It can be imagined that this filter is very consistent with the texture characteristics of the text, the text is composed of bar strokes, if an image contains text, the response at the text strokes will be relatively large, response in other places will be relatively small, and this feature can be used to filter out the text.
Some experiment results are as follows:
First, enter the image:
Response:
Binarization:
NotesArticleThe parameters in are relatively rigid and the effect is not very good. In my experiment, a set of reasonable parameters are shown in
D = 1, 2, 3, 4, Alpha interval = 45 degrees, where the length of the stroke should not exceed two times of D, otherwise the response of the text boundary will have a ringing effect
In terms of speed, the length and width of the above test diagram are 722*535 pixels. Run on my I5 blacklist for about 1300 Ms. The environment is windows, x64, opencv, and C ++. The most important parameter that affects the speed is the selection of Alpha. Calculating a response at every 45 degrees and calculating a response at every 10 degrees won't have much difference in accuracy. Similarly, if Alpha interval is set to 90, there is no loss of precision, but the speed can be reduced to 600 Ms.If you want to perform real-time video processing, you 'd better extract the rectangle where the subtitle is located and then process it. In this way, the speed can be within 50 ms.