Document scanning OCR (Optical Character Recognition) method based on background bleaching correction and storage medium
By using a combination of background bleaching correction method and deep learning network in optical character recognition technology, the problems of uneven lighting and shadow interference are solved, the recognition accuracy of document scanning images is improved, and high-precision electronic document entry is achieved.
Patent Information
- Application Number
- CN202310572615.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-19
- Publication Date
- 2024-11-22
AI Technical Summary
In the existing optical character recognition technology, uneven lighting and shadow problems of document scanned images lead to a reduced accuracy of text recognition, and the black pixel value of non-document areas is close to 0, causing interference during the bleaching process.
The document scanning OCR recognition method based on background bleach correction is adopted, including image data processing steps such as retained contrast decolorization, image binarization, morphological filling, Gaussian filtering, color division and background correction, and text detection is carried out in combination with DBNet++ and CRNN network models. and identify.
By reducing the influence of uneven light and shadows, improving the contrast of text information, reducing interference in non-document areas, significantly improving the accuracy of text recognition, and achieving high-precision electronic entry of document scanning images.
Smart Images

Figure CN119007233A_ABST
Abstract
Description
Technical Field
[0001] The present invention mainly relates to the technical field of optical character recognition, and in particular to a document scanning OCR recognition method and storage medium based on background bleaching correction. Background Art
[0002] Optical Character Recognition (OCR) refers to the process in which an electronic device (such as a scanner or digital camera) examines characters printed on paper, determines their shapes by detecting dark and light patterns, and then uses character recognition methods to translate the shapes into computer text; that is, for printed characters, an optical method is used to convert the text in a paper document into a black and white dot matrix image file, and recognition software is used to convert the text in the image into text format for further editing and processing by word processing software.
[0003] The document scanned image obtained from the scanning table is an RGB image. The document area of the image records the text information that needs to be recognized, but there are often problems such as uneven lighting and shadows, which will reduce the accuracy of text recognition. At the same time, the non-document area of the image has no text information and is often black, with a pixel value close to 0. Color changes are likely to occur during the document bleaching process, causing interference to subsequent text recognition. Summary of the invention
[0004] The technical problem to be solved by the present invention is: in view of the technical problems existing in the prior art, the present invention provides a document scanning OCR recognition method and storage medium based on background bleaching correction, which has a simple principle, a wide range of applications and high recognition accuracy.
[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0006] A document scanning OCR recognition method based on background bleaching correction, comprising:
[0007] Step S1: Obtain image data; obtain a document scanned RGB image;
[0008] Step S2: image data processing, processing and correcting the image data;
[0009] Step S3: Image text area detection: inputting image data into a text detection network for text detection;
[0010] Step S4: Image OCR recognition: recognize the detected text area to identify the text information of the document scan image.
[0011] As a further improvement of the method of the present invention: the step S2 includes image contrast-preserving decolorization, using a contrast-preserving decolorization method to convert the RGB image into a grayscale image.
[0012] As a further improvement of the method of the present invention: when performing image contrast-preserving decolorization, the acquired RGB image is decolorized using a contrast-preserving decolorization method to obtain a grayscale image g(x,y), where (x,y) represents pixel position information.
[0013] As a further improvement of the method of the present invention: the step S2 includes image binarization, binarizing the acquired grayscale image to obtain a binarized image; the formula for the image binarization is as follows:
[0014]
[0015] In the above formula, g(x,y) is the grayscale image pixel value, ranging from 0 to 1. e(x,y) is the image obtained after binarization.
[0016] As a further improvement of the method of the present invention: the step S2 includes image morphological filling, using a morphological filling method to fill the binary image to obtain a filled image.
[0017] As a further improvement of the method of the present invention: the step S2 includes image Gaussian filtering, performing Gaussian filtering on the acquired RGB image to obtain a filtered image.
[0018] As a further improvement of the method of the present invention: the formula of the Gaussian filtering method is as follows:
[0019]
[0020]
[0021] In the above formula, represents the convolution operation, G(x,y) represents the Gaussian template function, l(x,y) represents any channel value of R(x,y), G(x,y) and B(x,y) in the three channel values of the RGB image, t(x,y) is the filtered output image of the corresponding channel value, and σ is the standard deviation of the Gaussian template function.
[0022] As a further improvement of the method of the present invention: the step S2 includes image color division and image background correction. The image color division is performed using a color division formula, with the RGB original image as the base color and the filtered image as the mixed color to obtain a divided image; the image background correction is performed based on the filled image to correct the pixels in the area outside the divided image document.
[0023] As a further improvement of the method of the present invention: when performing image background restoration, the formula is as follows:
[0024]
[0025] In the above formula, f(x, y) represents the filled image, c(x, y) is one of the three-channel values of the output RGB image after color division, and q(x, y) is one of the three-channel values of the corresponding background repaired image.
[0026] As a further improvement of the method of the present invention: in the step S3, when performing image text area detection, text detection is performed on the RGB format image after background restoration using a DBNet++ neural network with Resnet50 as the backbone network or an EAST network model with ResNet50 as the backbone network.
[0027] As a further improvement of the method of the present invention: in the step S4, the image OCR recognition is to perform text recognition on the detected text area, using a CRNN network model with Resnet34_vd as the backbone network or an ABINet network model with ResNet45 as the backbone network.
[0028] The present invention further provides a storage medium storing a computer program for implementing any one of the above methods.
[0029] Compared with the prior art, the advantages of the present invention are:
[0030] 1. The document scanning OCR recognition method and storage medium based on background bleaching correction of the present invention have simple principle, wide application range and high recognition accuracy. By using a color division-based method to bleach the background of the document area of the image, the influence of uneven illumination and shadow problems in the document area on text recognition is reduced, the contrast of text information is improved, and the subsequent recognition accuracy is improved.
[0031] 2. The document scanning OCR recognition method and storage medium based on background bleaching correction of the present invention further use a morphological filling-based method to distinguish the non-document area from the document area of the image, reducing the interference of the non-document area without text information on the recognition process. The present invention further connects the bleached corrected image to the DBNet++ text detection network and the CRNN text recognition network, which can effectively detect and recognize the text information in the document scan image, thereby completing the electronic entry of the document scan image information. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a schematic flow diagram of the method of the present invention.
[0033] Figure 2 It is a schematic diagram of RGB of a document scan image obtained from a scanning platform in a specific application example of the present invention.
[0034] Figure 3 It is a schematic diagram of a grayscale image obtained after performing a contrast-preserving decolorization operation on an RGB original image in a specific application example of the present invention.
[0035] Figure 4 It is a schematic diagram of a binarized image obtained after binarizing a grayscale image in a specific application example of the present invention.
[0036] Figure 5 It is a schematic diagram obtained after morphological filling is performed on a binary image in a specific application example of the present invention.
[0037] Figure 6 It is a schematic diagram of a blurred image obtained after Gaussian filtering of an RGB original image in a specific application example of the present invention.
[0038] Figure 7 It is a schematic diagram of an output image obtained after color division in a specific application example of the present invention.
[0039] Figure 8 It is a schematic diagram of an image obtained by performing background correction on a color-divided image in a specific application example of the present invention. DETAILED DESCRIPTION
[0040] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0041] like Figure 1 and Figure 2 As shown, the document scanning OCR recognition method based on background bleaching correction of the present invention comprises:
[0042] Step S1: Obtain image data; obtain a document scanned RGB image taken from a scanning platform; wherein, an RGB image is a method of representing a color image, which represents a variety of colors by changing the values of the three channels of red (R), green (G), and blue (B) and their superposition.
[0043] Step S2: image data processing;
[0044] Step S3: Image text area detection; input the corrected image into the text detection network for text detection; wherein text detection refers to finding the area where the text is located in the image through a specific method, which is a sub-problem in the field of target detection.
[0045] Step S4: Image OCR recognition: Recognize the detected text area to identify the text information of the document scanned image. Among them, text recognition refers to using computer vision related technology to allow the computer to recognize the text information in the image.
[0046] In a specific application example, step S2 of the present invention includes but is not limited to the following process:
[0047] Image contrast-preserving desaturation: Use the contrast-preserving desaturation method to convert the RGB image into a grayscale image; image contrast refers to the measurement of different brightness levels between the brightest white and the darkest black in the dark area, that is, the size of the grayscale contrast of an image.
[0048] Image binarization: binarize the acquired grayscale image to obtain a binary image;
[0049] Image morphological filling: Use the morphological filling method to fill the binary image and obtain the filled image;
[0050] Image Gaussian filtering: Gaussian filtering is performed on the acquired RGB image to obtain the filtered image;
[0051] Image color division: Use the color division formula, take the RGB original image as the base color, and the filtered image as the mixed color to perform color division to obtain the divided image;
[0052] Image background correction: Correct the pixels outside the divided image document based on the filled image.
[0053] In a specific application example, when performing image contrast-preserving decolorization, a contrast-preserving decolorization method is used to decolorize the RGB image obtained from the scanning station to obtain a grayscale image g(x,y), where (x,y) represents pixel position information. The contrast-preserving decolorization method can adopt traditional methods in the prior art according to actual needs, so as to meet actual needs.
[0054] In a specific application example, the formula for image binarization is as follows:
[0055]
[0056] In the above formula, g(x,y) is the grayscale image pixel value, ranging from 0 to 1. e(x,y) is the image obtained after binarization.
[0057] In a specific application example, when performing image morphological filling, the obtained binary image e(x, y) is filled using a morphological method to obtain a filled image f(x, y). The morphological filling method can adopt traditional methods in the prior art according to actual needs, so as to meet actual needs.
[0058] In a specific application example, the formula of the Gaussian filtering method is as follows:
[0059]
[0060]
[0061] In the above formula, represents the convolution operation, G(x,y) represents the Gaussian template function, l(x,y) represents any channel value of R(x,y), G(x,y) and B(x,y) in the three channel values of the RGB image, t(x,y) is the filtered output image of the corresponding channel value, and σ is the standard deviation of the Gaussian template function.
[0062] In a specific application example, when dividing image colors, the formula is as follows:
[0063]
[0064]
[0065] In the above formula, l(x,y) represents any channel value of R(x,y), G(x,y) and B(x,y) in the three-channel values of the RGB image, t(x,y) is the Gaussian filter output image of the corresponding channel value, eps is a minimum value to prevent the divisor from being 0, and c(x,y) is one of the three-channel values of the output RGB image after the corresponding color division.
[0066] In a specific application example, when performing image background repair, the formula is as follows:
[0067]
[0068] In the above formula, f(x, y) represents the filled image, c(x, y) is one of the three-channel values of the output RGB image after color division, and q(x, y) is one of the three-channel values of the corresponding background repaired image.
[0069] In a specific application example, in step S3, when performing image text area detection, the RGB format image after background repair is subjected to text detection using a DBNet++ neural network with Resnet50 as the backbone network. The traditional method in the prior art can be adopted according to actual needs, based on the ability to meet actual needs. After detection, the text positioning of the image is obtained.
[0070] In a specific application example, in step S4, the image OCR recognition is to perform text recognition on the detected text area, using a CRNN network model with Resnet34_vd as the backbone network. The method can adopt traditional methods in the prior art according to actual needs, based on the ability to meet actual needs. After model processing, the computer can recognize text information on the image.
[0071] In the above method of the present invention, the text area detection uses the DBNet++ network model, and other text detection methods may also be used, such as the EAST network model using ResNet50 as the backbone network.
[0072] In the above method of the present invention, the text recognition method uses a CRNN network model with Resnet34_vd as the backbone network, and other text recognition methods may also be used, such as an ABINet network model with ResNet45 as the backbone network.
[0073] The present invention further provides a storage medium storing a computer program for implementing any one of the above methods.
[0074] As can be seen from the above, the present invention performs Gaussian filtering on the acquired RGB image, takes the RGB image as the base color, takes the image after Gaussian filtering as the mixed color, performs color division according to the division formula, and obtains the divided image. The part of the image containing text information has the information retained and has a certain degree of brightness improvement, and the shadow part of other areas of the document is bleached, so the contrast of the text information is enhanced overall, which is convenient for subsequent text recognition and improves the recognition accuracy; secondly, the present invention converts the color image into a grayscale image using a contrast-retaining decolorization method, then binarizes the grayscale image, and then uses a morphological filling method to fill the document area. After filling, the document area becomes white, and most of the background area around the document becomes black. The document is distinguished from the background according to the pixel value information, which is convenient for distinguishing and processing different areas of the image, and reducing the background interference from the document surrounding the text recognition; finally, the bleached corrected image is connected to the DBNet++ text detection network and the CRNN text recognition network, so that the text information in the document scan image can be effectively detected and recognized, thereby completing the electronic entry of the text information of the document scan image.
[0075] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.
Claims
1. A document scanning OCR recognition method based on background bleaching correction, characterized in that: include: Step S1: Obtain image data; obtain a document scanned RGB image; Step S2: image data processing, processing and correcting the image data; Step S3: Image text area detection: inputting image data into a text detection network for text detection; Step S4: Image OCR recognition: recognize the detected text area to identify the text information of the document scan image.
2. The document scanning OCR recognition method based on background bleaching correction according to claim 1, characterized in that: The step S2 includes image contrast preserving decolorization, using a contrast preserving decolorization method to convert the RGB image into a grayscale image.
3. The document scanning OCR recognition method based on background bleaching correction according to claim 2, characterized in that: When performing image contrast preserving decolorization, the acquired RGB image is decolorized using the contrast preserving decolorization method to obtain a grayscale image. g ( x,y ) , (x,y) represents the pixel position information.
4. The document scanning OCR recognition method based on background bleaching correction according to claim 2, characterized in that: The step S2 includes image binarization, which is to binarize the acquired grayscale image to obtain a binarized image. The formula for the image binarization is as follows: In the above formula, g ( x,y ) is the grayscale image pixel value, ranging from 0 to 1, e ( x,y ) is the image obtained after binarization.
5. The document scanning OCR recognition method based on background bleaching correction according to claim 4, characterized in that: The step S2 includes image morphological filling, which uses a morphological filling method to fill the binary image to obtain a filled image.
6. The document scanning OCR recognition method based on background bleaching correction according to any one of claims 1 to 5, characterized in that: The step S2 includes performing Gaussian filtering on the image, and performing Gaussian filtering on the acquired RGB image to obtain a filtered image.
7. The document scanning OCR recognition method based on background bleaching correction according to claim 6, characterized in that: The formula of the Gaussian filtering method is as follows: In the above formula, represents the convolution operation, G( x,y ) represents the Gaussian template function, l( x,y ) Represents the three-channel value of the RGB image R( x,y ) , G( x,y ) and B( x,y ) Any channel value of t ( x,y ) is the filtered output image corresponding to the channel value, and σ is the standard deviation of the Gaussian template function.
8. The document scanning OCR recognition method based on background bleaching correction according to any one of claims 1 to 5, characterized in that: The step S2 includes image color division and image background correction. The image color division is performed using a color division formula, with the RGB original image as the base color and the filtered image as the mixed color to obtain a divided image; the image background correction is performed based on the filled image to correct the pixels in the area outside the divided image document.
9. The document scanning OCR recognition method based on background bleaching correction according to claim 8, characterized in that: When performing image background repair, the formula is as follows: In the above formula, f(x, y) represents the filled image, c(x, y) is one of the three-channel values of the output RGB image after color division, and q(x, y) is one of the three-channel values of the corresponding background repaired image.
10. The document scanning OCR recognition method based on background bleaching correction according to any one of claims 1 to 5, characterized in that: In step S3, when performing image text area detection, text detection is performed on the RGB format image after background restoration using a DBNet++ neural network with Resnet50 as the backbone network or an EAST network model with ResNet50 as the backbone network.
11. The document scanning OCR recognition method based on background bleaching correction according to any one of claims 1 to 5, characterized in that: In step S4, the image OCR recognition is to perform text recognition on the detected text area, using a CRNN network model with Resnet34_vd as the backbone network or an ABINet network model with ResNet45 as the backbone network.
12. A storage medium, characterized in that: The storage medium stores a computer program for implementing any one of the methods in claims 1-11.
