Image document rectification method, device, equipment and readable storage medium

By combining image enhancement algorithms and neural network models, the problem of poor Fourier transform correction effect is solved, achieving efficient correction of complex image documents and improving the accuracy of OCR recognition.

CN117854081BActive Publication Date: 2026-07-14GLODON CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GLODON CO LTD
Filing Date
2024-01-08
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing image document correction methods based on Fourier transform cannot effectively correct images with a rotation angle exceeding 45°, and are sensitive to image noise, making it difficult to process document images with complex background textures and blurred handwriting, resulting in low OCR recognition accuracy.

Method used

Image enhancement algorithms are used to preprocess image documents, including adding tables, rotation, color inversion, cropping, pasting, scaling, and channel transformation. Combined with neural network model training, an image document correction model is generated. The trained model can identify and correct the rotation angle of the image document.

Benefits of technology

It improves the accuracy of correcting image documents with rotation angles, enhances the accuracy of OCR recognition, is applicable to complex backgrounds and diverse image documents, and improves the generalization ability of recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117854081B_ABST
    Figure CN117854081B_ABST
Patent Text Reader

Abstract

The application discloses a kind of image document rectification method, device, equipment and readable storage medium, the method comprises: obtaining multiple image documents;Based on the first preset algorithm, the image document is rectified, and the first image document is generated;Based on the second preset algorithm, the first image document is carried out image enhancement processing, and the second image document is generated;Second image document is input into initial neural network model and is trained, and image document rectification model is generated;Obtain the image document to be identified, and the image document to be identified is identified by image document rectification model, and the rotation angle of the image document to be identified is obtained;The image document to be identified is rectified by rotation angle, and target direction image document is generated.The application improves the content of image document through image enhancement, and trains neural network model based on the enhanced image document, uses the model trained to the input image and rotates rectification, improves the accuracy of image document correction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer-aided design, and more specifically to a method, apparatus, device, and readable storage medium for correcting image documents. Background Technology

[0002] With the rapid development of OCR (Optical Character Recognition) technology, people are increasingly demanding higher image quality. Since most OCR software assumes the input image is upright, excessive rotation of the input image may prevent the software from recognizing the text. Therefore, image document correction, as a crucial preprocessing step, significantly impacts the effectiveness of subsequent processing steps.

[0003] Current image document correction technologies typically rely on Fourier transform to obtain the image's frequency domain information, predicting the image's rotation angle, and then using this rotation angle to correct the document, thus ensuring the accuracy of OCR software recognition. However, this method can only correct rotation errors within 45° and is quite sensitive to image noise, primarily suitable for scanned documents with slight rotation and low image noise. Furthermore, for document images captured by a camera, the background texture is complex, the text is blurry, and the rotation angle is not fixed. Such complex image documents are difficult to correct effectively using the above methods, thus reducing the accuracy of OCR software recognition.

[0004] There is currently no effective solution to the technical problem that the correction effect of image documents based on Fourier transform in the existing technology is not good. Summary of the Invention

[0005] The purpose of this invention is to provide a method, apparatus, device, and readable storage medium for correcting image documents, which can solve the technical problem that the correction effect is not good when correcting image documents based on Fourier transform in the prior art.

[0006] One aspect of the present invention provides an image document correction method, the method comprising: acquiring a plurality of image documents, wherein the image documents have corresponding rotation angles; correcting the image documents based on a first preset algorithm to generate a first image document, wherein the rotation angle corresponding to the first image document is a positive standard position angle; performing image enhancement processing on the first image document based on a second preset algorithm to generate a second image document, wherein the rotation angle corresponding to the second image document is a positive standard position angle or a non-standard positive position angle; inputting the second image document into an initial neural network model for training to generate an image document correction model; acquiring an image document to be identified, identifying the image document to be identified through the image document correction model to obtain the rotation angle of the image document to be identified; and correcting the image document to be identified through the rotation angle to generate a target orientation image document.

[0007] Optionally, performing image enhancement processing on the first image document based on a second preset algorithm to generate a second image document includes: determining a first target image from multiple first image documents using a preset random probability algorithm; performing a table addition operation on the first target image to generate a first enhanced image; determining the first enhanced image and the first image document without the table addition operation as a first intermediate image; performing a rotation operation on the first intermediate image using a preset random probability algorithm to generate a second intermediate image; determining a third target image from the second intermediate image using a preset random probability algorithm; performing a color inversion operation on the third target image to generate a third enhanced image; and determining the third enhanced image. The second intermediate image, along with the second intermediate image without color inversion, is used as the third intermediate image. A fourth target image is determined from the third intermediate image using a preset random probability algorithm. The fourth target image is then cropped to generate a fourth enhanced image. The fourth enhanced image and the third intermediate image without cropping are then used as the fourth intermediate image. A fifth target image is determined from the fourth intermediate image using a preset random probability algorithm. The fifth target image is then textured to generate a fifth enhanced image. The fifth enhanced image is then used as the fifth intermediate image. The fifth intermediate image is scaled to generate a sixth enhanced image. The sixth enhanced image undergoes a channel transformation to generate the second image document.

[0008] Optionally, a table-adding operation is performed on the first target image to generate a first enhanced image, including: determining the contour information of the first target image; in response to the table-adding operation on the first target image, obtaining table attribute parameters, wherein the table attribute parameters include total length, total width, row and column width, number of rows and columns, and table rotation angle; calculating the table attribute parameters to obtain table contour information, and matching the table contour information with the contour information of the first target image; if the table contour information is a subset of the contour information of the first target image, corresponding drawing is performed in the first target image according to the table contour information to generate the first enhanced image; if the table contour information is not a subset of the contour information of the first target image, the table attribute parameters are adjusted, and corresponding drawing is performed in the first target image based on the adjusted table attribute parameters to generate the first enhanced image.

[0009] Optionally, a texture mapping operation is performed on the fifth target image to generate a fifth enhanced image, including: retrieving a background image set from a database, wherein the background image set includes a color background set and a natural background set; traversing all fifth target images to determine whether there are fifth target images with consistent edge colors; if there are fifth target images with consistent edge colors, extracting a preset number of fifth target images with consistent edge colors as first texture objects, determining the remaining fifth target images as second texture objects, selecting a background image of the corresponding color from the color background set to set the background of the first texture object, selecting a corresponding background image from the natural background set to set the background of the second texture object, and generating a fifth enhanced object. If there are no fifth target images with consistent edge colors, selecting a corresponding background image from the natural background set to set the background of the fifth target image, and generating a fifth enhanced object.

[0010] Optionally, scaling the fifth intermediate image to generate the sixth enhanced image includes: scaling the fifth intermediate image proportionally to generate an intermediate scaled image, wherein the long side of the intermediate algorithm image is a preset length; determining the short side of the intermediate scaled image and calculating the difference between the preset length and the short side; determining the filling area on one side of the short side of the intermediate scaled image based on the difference, and performing a filling operation based on the filling area to generate the sixth enhanced image.

[0011] Optionally, a channel transformation operation is performed on the sixth enhanced image to generate a second image document, including: determining the long side, short side, and original channel of the sixth enhanced image; creating a new channel from the long side and short side of the sixth enhanced image, and determining how to combine the new channel with the original channel of the sixth enhanced image to obtain the second image document.

[0012] Optionally, the second image document is input into an initial neural network model for training to generate an image document correction model, including: using the second image document and the sixth enhanced image as input data to a first training model, and using the first preset dimension information as output data to train the first training model; performing a reverse rotation operation on the sixth enhanced image to generate a third image document; using the third image document as input data to a second training model, and using the second preset dimension information as output data to train the second training model; and sequentially concatenating the trained first training model and the second training model to generate an image document correction model.

[0013] Another aspect of the present invention provides an image document correction device, the device comprising: an acquisition module for acquiring a plurality of image documents, wherein the image documents have corresponding rotation angles; a first correction module for correcting the image documents based on a first preset algorithm to generate a first image document, wherein the rotation angle corresponding to the first image document is a positive standard position angle; an image enhancement module for performing image enhancement processing on the first image document based on a second preset algorithm to generate a second image document, wherein the rotation angle corresponding to the second image document is a positive standard position angle or a non-standard positive position angle; a training module for inputting the second image document into an initial neural network model for training to generate an image document correction model; a recognition module for acquiring an image document to be recognized, recognizing the image document to be recognized through the image document correction model, and obtaining the rotation angle of the image document to be recognized; and a second correction module for correcting the image document to be recognized based on the rotation angle to generate a target orientation image document.

[0014] Another aspect of the present invention provides a computer device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the image document correction method of any of the above embodiments.

[0015] Another aspect of the present invention provides a computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the image document correction method of any of the above embodiments. Further, the computer-readable storage medium may primarily include a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application program required for a function, etc.; and the data storage area may store data created based on the use of blockchain nodes, etc.

[0016] This invention mainly comprises three parts: image enhancement, neural network training, and model inference. Image enhancement generates a training set based on the original dataset. The neural network training process uses this training set to train the neural network model. Model inference uses the trained model to perform rotation correction on the input image, thereby improving the accuracy of image document correction. It can also be used as a preprocessing step for optical character recognition, efficiently and accurately correcting documents with rotation angles and increasing the accuracy of optical character recognition. Attached Figure Description

[0017] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0018] Figure 1 A flowchart illustrating an optional image document correction method provided in Embodiment 1 of the present invention is shown.

[0019] Figure 2 A structural block diagram of the image document correction device provided in Embodiment 2 of the present invention is shown; and

[0020] Figure 3 A block diagram of a computer device suitable for implementing an image document correction method, as provided in Embodiment 3 of the present invention, is shown. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention.

[0022] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0023] Example 1

[0024] In practical applications, due to differences in shooting methods, download channels, and layout, image documents are not always displayed at a standard angle, but rather with a certain angular offset during display. Existing OCR technology is typically used to recognize characters in image documents, and offset image documents often affect the layout of characters. When such images are input into OCR software for recognition, the final result has a low accuracy rate. To improve the standardization of input data for OCR software, this embodiment provides an image document correction method, which improves both the standardization of input data and the accuracy of OCR technology recognition. Figure 1 A flowchart illustrating the correction method for this image document is shown, as follows: Figure 1 As shown, the image document correction method may include steps S101 to S106, wherein:

[0025] Step S101: Obtain multiple image documents, wherein each image document has a corresponding rotation angle;

[0026] Specifically, the image document can be a document image or other images containing characters; there are no restrictions. The rotation angle of the image document is between -45° and 45°.

[0027] The sources for obtaining image documents are not limited to direct import from digital cameras (including photocopying of photos taken with film), searching on photography websites, slideshows, obtaining image material CDs or cloud storage, obtaining via email forums, obtaining via blogs, taking screenshots using a browser or Sogou Pinyin input with screenshot function, or drawing images yourself using drawing software such as Photoshop.

[0028] Step S102: Correct the image document based on the first preset algorithm to generate a first image document, wherein the rotation angle corresponding to the first image document is the positive standard position angle;

[0029] Specifically, the first preset algorithm can be a Fourier transform algorithm or a conventional angle prediction algorithm; no restriction is imposed here.

[0030] The positive standard position angle can be the offset angle of the long side (or short side) of the image document from the horizontal line, which is 0 degrees.

[0031] The frequency domain information of the image is obtained through Fourier transform, thereby predicting the rotation angle of the first image document. Based on the rotation angle, the image document is rotated in the opposite direction to generate the first image document. This step allows for a uniform setting of the rotation angle of the image document, which is beneficial for rapid processing of the image document and thus improves the correction efficiency.

[0032] Step S103: Perform image enhancement processing on the first image document based on the second preset algorithm to generate a second image document, wherein the rotation angle corresponding to the second image document is a positive standard position angle or a non-standard positive position angle.

[0033] Specifically, the second preset algorithm may include adding a table, rotating, inverting colors, cropping, pasting, color transformation, scaling, FFT, and inverse rotation.

[0034] By performing image enhancement processing on the first image document using the second preset algorithm, the content of the image document can be enriched, covering different types of image documents that may appear in actual application scenarios, thereby improving the accuracy and range of subsequent recognition of actual images.

[0035] Preferably, step S103 can be steps S1031 to S1037, wherein:

[0036] Step S1031: Determine the first target image from multiple first image documents using a preset random probability algorithm, perform a table addition operation on the first target image to generate a first enhanced image, and determine the first enhanced image and the first image document without the table addition operation as the first intermediate image;

[0037] Specifically, the preset random probability algorithm can be a numerical probability algorithm, Monte Carlo algorithm, Las Vegas algorithm, Sherwood algorithm, or other random algorithms, without any restrictions.

[0038] The first target image can be 20% of the image documents selected from multiple first image documents, or it can be any other number; there is no restriction here.

[0039] For document documents, since the table sizes are not all the same, conventional document correction methods will adjust the image document to a fixed style table. This method will cause the table content and table borders to not correspond perfectly during the subsequent recognition process, resulting in low image document recognition accuracy.

[0040] By adding different types of table styles to the first document image, corresponding to various types of tables that may appear in actual application scenarios, the applicability of image document correction is made more extensive, preventing the neural network model from overfitting to the table shape and improving the accuracy of image document correction.

[0041] Preferably, step S1031 may include steps A1 to A5, wherein:

[0042] Step A1: Determine the contour information of the first target image;

[0043] The contour information of the first target image can be the length and shape of the contour segments.

[0044] Step A2: In response to the table addition operation on the first target image, obtain table attribute parameters, wherein the table attribute parameters include total length, total width, row and column width, number of rows and columns, and table rotation angle;

[0045] The table attribute parameters can be set randomly according to actual needs, and there are no restrictions here.

[0046] Step A3: Calculate the table attribute parameters to obtain table outline information, and match the table outline information with the outline information of the first target image;

[0047] There are two ways to calculate table outline information: one way is to first calculate the table size information by the total length and total width, and then adjust the table according to the table rotation angle. After adjustment, the table border information is determined as the table outline information.

[0048] Another approach is to first calculate the table's dimensions using the row and column widths and the number of rows and columns, then adjust the table according to its rotation angle, and finally determine the table's border information as its outline.

[0049] The table outline information is matched with the outline information of the first target image to determine whether the table outline is enveloped by the outline of the first target image. Based on the result, a table with the corresponding style is added to the first target image.

[0050] Step A4: If the table outline information is a subset of the outline information of the first target image, draw the corresponding image in the first target image according to the table outline information to generate the first enhanced image;

[0051] Step A5: If the table outline information is a non-subset of the outline information of the first target image, adjust the table attribute parameters and draw the corresponding image in the first target image based on the adjusted table attribute parameters to generate the first enhanced image.

[0052] The recognition area of ​​the image document is limited to the border lines and the internal area; areas outside the border lines cannot be recognized. When the table outline information is a non-subset of the outline information of the first target image, it indicates that the table size exceeds the image document size. In this case, the set table attribute parameters need to be adaptively adjusted so that the table area is enveloped by the image document area. This adjustment can be achieved by modifying one or a combination of parameters such as total length, total width, row and column width, number of rows and columns, and table rotation angle.

[0053] Step S1032: Rotate the first intermediate image using a preset random probability algorithm to generate a second intermediate image;

[0054] Since all image documents have been corrected in step S102, the image documents are now rotated to the positive standard position. However, in real-world applications, image documents are not always displayed at the positive standard position. To better reflect the actual scenario, the first intermediate image is rotated to ensure the accuracy of the image document correction.

[0055] Based on a preset random probability algorithm, 90% of the image documents in the first intermediate image are randomly rotated by angle values ​​in the range of [-180°, 180°], and 10% of the image documents in the first intermediate image are rotated by angle values ​​in the range of [-2°, 2°]. The rotation angle values ​​are then used as labels for each image document to obtain the second intermediate image.

[0056] Step S1033: Determine the third target image from the second intermediate image using a preset random probability algorithm, perform a color inversion operation on the third target image to generate a third enhanced image, and determine the third enhanced image and the second intermediate image without color inversion operation as the third intermediate image;

[0057] The third target image can be 3% of the image document in the second intermediate image;

[0058] The color inversion method can be as follows: obtain the RGB values ​​of the third target image, then convert the third target image based on the difference obtained according to the preset rule (255-RGB) to generate the third enhanced image.

[0059] This step can improve the generalization of image documents, thereby improving the accuracy of image document correction.

[0060] Step S1034: Determine the fourth target image from the third intermediate image using a preset random probability algorithm, perform a cropping operation on the fourth target image to generate a fourth enhanced image, and determine the fourth enhanced image and the third intermediate image without cropping as the fourth intermediate image;

[0061] The fourth target image can be 50% of the image document in the third intermediate image.

[0062] The rule for cropping the fourth target image is that the cropping position is not limited, and the ratio of the long side to the short side after cropping is between [1 / 2, 1]. Since image and document sizes are not exactly the same in real-world scenarios, this step increases the diversity of image and document aspect ratios, which is beneficial for conforming to real-world scenarios. In addition, cropping can avoid situations where the rotation angle is determined by the document edges in some scenarios, prompting the subsequent recognition model to determine the document rotation angle by the text direction, thereby improving the accuracy of image and document correction.

[0063] Step S1035: Determine the fifth target image from the fourth intermediate image using a preset random probability algorithm, perform a texture mapping operation on the fifth target image to generate a fifth enhanced image, and determine the fifth enhanced image as the fifth intermediate image;

[0064] Background texture is also a crucial factor affecting the determination of image document rotation angle. In real-world applications, image documents contain various background textures. Due to differences in background texture attribute settings, the rotation angle of the background texture may be mistakenly used as the rotation angle of the image document during some image document correction processes, leading to reduced accuracy. By setting texture mapping operations for image documents, it's possible to address different real-world scenarios, thereby improving the accuracy of image document correction and its robustness to background textures.

[0065] The fifth target image is all the image documents in the fourth intermediate image.

[0066] Preferably, step S1035 may include steps B1 to B4, wherein:

[0067] Step B1: Obtain a background image set from the database, wherein the background image set includes a color background set and a natural background set;

[0068] The color background set contains background images of different colors, which can be solid colors or gradient colors; there are no restrictions. The nature background set can contain background images of landscapes, people, animals, etc., obtained from different download channels, and can also be other non-solid color images; there are no restrictions.

[0069] Step B2: Traverse all fifth target images and determine whether there is a fifth target image with the same edge color;

[0070] Step B3: If there are fifth target images with consistent edge colors, extract a preset number of fifth target images with consistent edge colors as first texture objects, determine the remaining fifth target images as second texture objects, select a background image of the corresponding color from the color background set to set the background of the first texture object, select a background image of the corresponding color from the natural background set to set the background of the second texture object, and generate a fifth enhanced object.

[0071] Specifically, the preset quantity can be 50%, or other values, depending on actual needs.

[0072] The texture operation for the first texture object is to select a background image from the color background set that matches the edge color of the first texture object and set the background; the texture operation for the second texture object is to randomly select a background image from the natural background set and set the background.

[0073] Step B4: If there is no fifth target image with consistent edge color, select a corresponding background image from the set of natural backgrounds to set the background of the fifth target image and generate the fifth enhanced object.

[0074] For the fifth target image where there is no consistent edge color, the texture mapping operation on the fifth target image involves randomly selecting a background image from the set of natural backgrounds for background setting.

[0075] Specifically, after step S1035, the method further includes: performing a color transformation operation on the fifth intermediate image, that is, randomly adjusting the brightness, contrast, saturation, and hue of the image document. Preferably, the torchvision.transforms.ColorJitter library is used, with specific parameters of brightness 0.5, contrast 0.5, saturation 0.5, and hue 0.3, at which point the text in the document can still be recognized.

[0076] Step S1036: Scale the fifth intermediate image to generate the sixth enhanced image;

[0077] This step ensures that the canvas area of ​​the image document is of uniform size, which facilitates the subsequent recognition of the model.

[0078] Preferably, step S1036 may include steps C1 to C3, wherein:

[0079] Step C1: Scale the fifth intermediate image proportionally to generate an intermediate scaled image, wherein the long side of the intermediate algorithm image is a preset length;

[0080] The preset length can be 1024.

[0081] Step C2: Determine the shorter side of the intermediate scaled image and calculate the difference between the preset length and the shorter side;

[0082] Step C3: Determine the filling region on the short side of the intermediate scaled image using the difference, and perform a filling operation based on the filling region to generate the sixth enhanced image.

[0083] The filled area is a rectangle whose adjacent side length is the difference between the shorter side length and the shorter side length.

[0084] Filling operations based on the fill region can be performed by randomly dividing the fill region along the short side, and then setting the fill regions outside the two short sides of the image in the middle of the scaled image.

[0085] Step S1037: Perform a channel transformation operation on the sixth enhanced image to generate a second image document.

[0086] Adding channels aims to provide richer frequency domain information to the neural network model in order to improve the accuracy of predicting rotation angles.

[0087] Preferably, step S1037 may include steps D1 to D2, wherein:

[0088] Step D1: Determine the long side, short side, and original channel of the sixth enhanced image;

[0089] The original channel is an RGB channel.

[0090] Step D2: Create a new channel from the long and short sides of the sixth enhanced image, and combine the new channel with the original channel of the sixth enhanced image to obtain the second image document.

[0091] In addition, steps S1031, S1033 and S1035 must be executed in a strict order, while other image enhancement steps can be executed in any order.

[0092] Step S104: Input the second image document into the initial neural network model for training to generate an image document correction model;

[0093] The initial neural network model is divided into a first training model and a second training model;

[0094] The first and second training models can be ResNet18 network models or other network models; there are no restrictions here.

[0095] Preferably, step S104 may include steps S1041 to S1044, wherein:

[0096] Step S1041: Use the second image document and the sixth enhanced image as input data for the first training model, and use the first preset dimension information as output data for the first training model to train the first training model.

[0097] The first preset dimension information can be 90 categories: 0°, 1°, 2°...89°.

[0098] Step S1042: Perform a reverse rotation operation on the sixth enhanced image to generate a third image document;

[0099] The sixth enhanced image is rotated in the opposite direction (0°, 90°) to the rotation in step S1032. During the rotation, a correction error is randomly generated that is uniformly distributed between -5° and 5° to simulate possible error situations.

[0100] Step S1043: Use the third image document as input data for the second training model and the second preset dimension information as output data for the second training model to train the second training model;

[0101] The second preset dimension information can be categorized into four types: 0°, 90°, 180°, or 270°.

[0102] Step S1044: Sequentially concatenate the first and second trained models to generate an image document correction model.

[0103] Step S105: Obtain the image document to be recognized, and use the image document correction model to recognize the image document to obtain the rotation angle of the image document to be recognized;

[0104] Step S106: Correct the image document to be identified by the rotation angle to generate a target orientation image document.

[0105] This embodiment mainly includes three parts: image enhancement, neural network training, and model inference. Image enhancement generates a training set based on the original dataset. The neural network training process uses the training set to train the neural network model. Model inference uses the trained model to perform rotation correction on the input image, improving the accuracy of image document correction. At the same time, it can also be used as a preprocessing step for optical character recognition, efficiently and accurately correcting documents with rotation angles and increasing the accuracy of optical character recognition.

[0106] Example 2

[0107] Embodiment 2 of the present invention also provides an image document correction device, which corresponds to the image document correction method provided in Embodiment 1 above. The corresponding technical features and effects are not detailed in this embodiment; relevant aspects can be referred to in Embodiment 1 above. Specifically, Figure 2 A structural block diagram of the correction device for this image document is shown. Figure 2 As shown, the image document correction device 200 includes an acquisition module 201, a first correction module 202, an image enhancement module 203, a training module 204, a recognition module 205, and a second correction module 206, wherein:

[0108] The acquisition module 201 is used to acquire multiple image documents, wherein the image documents have corresponding rotation angles;

[0109] The first correction module 202 is connected to the acquisition module 201 and is used to correct the image document based on the first preset algorithm to generate a first image document, wherein the rotation angle corresponding to the first image document is a positive standard position angle.

[0110] The image enhancement module 203 is connected to the first correction module 202 and is used to perform image enhancement processing on the first image document based on the second preset algorithm to generate a second image document, wherein the rotation angle corresponding to the second image document is a positive standard position angle or a non-standard positive position angle.

[0111] The training module 204, connected to the image enhancement module 203, is used to input the second image document into the initial neural network model for training, and generate an image document correction model.

[0112] The recognition module 205, connected to the training module 204, is used to acquire the image document to be recognized, recognize the image document to be recognized through the image document correction model, and obtain the rotation angle of the image document to be recognized.

[0113] The second correction module 206 is connected to the recognition module 205 and is used to correct the image document to be recognized by the rotation angle to generate a target orientation image document.

[0114] Optionally, the image enhancement module includes: a table-adding unit, configured to determine a first target image from multiple first image documents using a preset random probability algorithm, perform a table-adding operation on the first target image to generate a first enhanced image, and determine the first enhanced image and the first image document without the table-adding operation as a first intermediate image; a rotation unit, configured to perform a rotation operation on the first intermediate image using a preset random probability algorithm to generate a second intermediate image; and a color inversion unit, configured to determine a third target image from the second intermediate image using a preset random probability algorithm, perform a color inversion operation on the third target image to generate a third enhanced image, and determine the third enhanced image and the second intermediate image without the color inversion operation as a first intermediate image. A third intermediate image; a cropping unit, configured to determine a fourth target image from the third intermediate image using a preset random probability algorithm, perform a cropping operation on the fourth target image to generate a fourth enhanced image, and determine the fourth enhanced image and the third intermediate image without cropping as the fourth intermediate image; a pasting unit, configured to determine a fifth target image from the fourth intermediate image using a preset random probability algorithm, perform a pasting operation on the fifth target image to generate a fifth enhanced image, and determine the fifth enhanced image as the fifth intermediate image; a scaling unit, configured to scale the fifth intermediate image to generate a sixth enhanced image; and a channel transformation unit, configured to perform a channel transformation operation on the sixth enhanced image to generate a second image document.

[0115] Optionally, a table unit is added for: determining the contour information of the first target image; in response to the table addition operation on the first target image, obtaining table attribute parameters, wherein the table attribute parameters include total length, total width, row and column width, number of rows and columns, and table rotation angle; calculating the table attribute parameters to obtain table contour information, and matching the table contour information with the contour information of the first target image; if the table contour information is a subset of the contour information of the first target image, corresponding drawing is performed in the first target image according to the table contour information to generate a first enhanced image; if the table contour information is not a subset of the contour information of the first target image, the table attribute parameters are adjusted, and corresponding drawing is performed in the first target image based on the adjusted table attribute parameters to generate a first enhanced image.

[0116] Optionally, the mapping unit is configured to: retrieve a background image set from a database, wherein the background image set includes a color background set and a natural background set; traverse all fifth target images to determine whether there are fifth target images with consistent edge colors; if there are fifth target images with consistent edge colors, extract a preset number of fifth target images with consistent edge colors as first mapping objects, determine the remaining fifth target images as second mapping objects, select a background image of the corresponding color from the color background set to set the background of the first mapping object, select a corresponding background image from the natural background set to set the background of the second mapping object, and generate a fifth enhanced object. If there are no fifth target images with consistent edge colors, select a corresponding background image from the natural background set to set the background of the fifth target image, and generate a fifth enhanced object.

[0117] Optionally, the scaling unit is configured to: scale the fifth intermediate image proportionally to generate an intermediate scaled image, wherein the long side of the intermediate algorithm image is a preset length; determine the short side of the intermediate scaled image and calculate the difference between the preset length and the short side; determine a filling area on one side of the short side of the intermediate scaled image through the difference, and perform a filling operation based on the filling area to generate a sixth enhanced image.

[0118] Optionally, the channel transformation unit is used to: determine the long side, short side, and original channel of the sixth enhanced image; create a new channel from the long side and short side of the sixth enhanced image; and determine the combination of the new channel with the original channel of the sixth enhanced image to obtain a second image document.

[0119] Optionally, the training module is configured to: train the first training model by using the second image document and the sixth enhanced image as input data of the first training model and the first preset dimension information as output data of the first training model; perform a reverse rotation operation on the sixth enhanced image to generate a third image document; train the second training model by using the third image document as input data of the second training model and the second preset dimension information as output data of the second training model; and sequentially concatenate the trained first training model and the second training model to generate an image document correction model.

[0120] Example 3

[0121] Figure 3A block diagram of a computer device suitable for implementing an image document correction method, as provided in Embodiment 3 of the present invention, is shown. In this embodiment, the computer device 300 may be a smartphone, tablet computer, laptop computer, desktop computer, rack server, blade server, tower server, or cabinet server (including standalone servers or server clusters composed of multiple servers), etc., that executes a program. Figure 3 As shown, the computer device 300 in this embodiment includes, but is not limited to, a memory 301, a processor 302, and a network interface 303 that are communicatively connected to each other via a system bus. It should be noted that... Figure 3 Only a computer device 300 with components 301-303 is shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0122] In this embodiment, the memory 303 includes at least one type of computer-readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 301 may be an internal storage unit of the computer device 300, such as the hard disk or memory of the computer device 300. In other embodiments, the memory 301 may also be an external storage device of the computer device 300, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 300. Of course, the memory 301 may also include both the internal storage unit and the external storage device of the computer device 300. In this embodiment, the memory 301 is typically used to store the operating system and various application software installed on the computer device 300, such as program code for image document correction methods.

[0123] In some embodiments, processor 302 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. This processor 302 is typically used to control the overall operation of computer device 300. For example, it performs control and processing related to data interaction or communication with computer device 300. In this embodiment, processor 302 is used to run program code for the steps of a correction method for an image document stored in memory 301.

[0124] In this embodiment, the image document correction method stored in memory 301 can be further divided into one or more program modules and executed by one or more processors (processor 302 in this embodiment) to complete the present invention.

[0125] Network interface 303 may include a wireless network interface or a wired network interface, which is typically used to establish a communication link between computer device 300 and other computer devices. For example, network interface 303 is used to connect computer device 300 to an external terminal via a network, establishing a data transmission channel and communication link between computer device 300 and the external terminal. The network may be an intranet, the Internet, Global System for Mobile Communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, or other wireless or wired networks.

[0126] Example 4

[0127] This embodiment also provides a computer-readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, App application store, etc., which stores a computer program. When the computer program is executed by a processor, it implements the steps of an image document correction method.

[0128] Obviously, those skilled in the art should understand that the modules or steps of the above-described embodiments of the present invention can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the embodiments of the present invention are not limited to any particular hardware and software combination.

[0129] It should be noted that the sequence numbers of the embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0130] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0131] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for correcting image documents, characterized in that, The method includes: Acquire multiple image documents, wherein each image document has a corresponding rotation angle; The image document is corrected based on the first preset algorithm to generate a first image document, wherein the rotation angle corresponding to the first image document is the positive standard position angle; The first image document is enhanced based on the second preset algorithm to generate a second image document, wherein the rotation angle corresponding to the second image document is a positive standard position angle or a non-standard positive position angle; The second image document is input into the initial neural network model for training to generate an image document correction model; Obtain the image document to be identified, and use the image document correction model to identify the image document to obtain the rotation angle of the image document to be identified; The image document to be identified is corrected by the rotation angle to generate a target orientation image document; The step of performing image enhancement processing on the first image document based on the second preset algorithm to generate the second image document includes: A first target image is determined from multiple first image documents using a preset random probability algorithm. A table is added to the first target image to generate a first enhanced image. The first enhanced image and the first image document without the table addition operation are determined as the first intermediate image. The first intermediate image is rotated using a preset random probability algorithm to generate a second intermediate image. A third target image is determined from the second intermediate image using a preset random probability algorithm. A color inversion operation is performed on the third target image to generate a third enhanced image. The third enhanced image and the second intermediate image without color inversion are determined as the third intermediate image. A fourth target image is determined from the third intermediate image using a preset random probability algorithm. The fourth target image is then cropped to generate a fourth enhanced image. The fourth enhanced image and the third intermediate image without cropping are then identified as the fourth intermediate image. A fifth target image is determined from the fourth intermediate image using a preset random probability algorithm. A texture mapping operation is performed on the fifth target image to generate a fifth enhanced image. The fifth enhanced image is then determined to be the fifth intermediate image. The fifth intermediate image is scaled to generate the sixth enhanced image; The sixth enhanced image is subjected to a channel transformation operation to generate a second image document.

2. The method according to claim 1, characterized in that, The step of adding a table to the first target image to generate the first enhanced image includes: Determine the contour information of the first target image; In response to the table addition operation on the first target image, table attribute parameters are obtained, wherein the table attribute parameters include total length, total width, row and column width, number of rows and columns, and table rotation angle; The table attribute parameters are calculated to obtain table outline information, and the table outline information is matched with the outline information of the first target image. If the table outline information is a subset of the outline information of the first target image, the corresponding drawing is performed in the first target image according to the table outline information to generate the first enhanced image; If the table outline information is a non-subset of the outline information of the first target image, the table attribute parameters are adjusted, and corresponding drawing is performed in the first target image based on the adjusted table attribute parameters to generate the first enhanced image.

3. The method according to claim 1, characterized in that, The step of performing a texturing operation on the fifth target image to generate a fifth enhanced image includes: Retrieve background image sets from the database, wherein the background image sets include color background sets and natural background sets; Iterate through all fifth target images and determine if there is a fifth target image with the same edge color; If there is a fifth target image with the same edge color, then a preset number of fifth target images with the same edge color are extracted as the first texture object, the remaining fifth target images are determined as the second texture object, a background image of the corresponding color is selected from the color background set to set the background of the first texture object, and a background image of the corresponding color is selected from the natural background set to set the background of the second texture object, thereby generating the fifth enhanced object; If no fifth target image with consistent edge color exists, a corresponding background image is selected from the set of natural backgrounds to set the background of the fifth target image, thereby generating a fifth enhanced object.

4. The method according to claim 1, characterized in that, The scaling operation on the fifth intermediate image to generate the sixth enhanced image includes: The fifth intermediate image is scaled proportionally to generate an intermediate scaled image, wherein the long side of the intermediate scaled image is a preset length; Determine the shorter side of the intermediate scaled image, and calculate the difference between the preset length and the shorter side; The fill region on the short side of the intermediate scaled image is determined by the difference, and a fill operation is performed based on the fill region to generate the sixth enhanced image.

5. The method according to claim 4, characterized in that, The step of performing a channel transformation operation on the sixth enhanced image to generate a second image document includes: Determine the long side, short side, and original channel of the sixth enhanced image; The long and short sides of the sixth enhanced image are used to create a new channel, and the new channel is combined with the original channel of the sixth enhanced image to obtain a second image document.

6. The method according to claim 1, characterized in that, The initial neural network model is divided into a first training model and a second training model. The step of inputting the second image document into the initial neural network model for training to generate an image document correction model includes: The second image document and the sixth enhanced image are used as input data for the first training model, and the first preset dimension information is used as output data for the first training model to train the first training model. Perform a reverse rotation operation on the sixth enhanced image to generate a third image document; The third image document is used as the input data of the second training model, and the second preset dimension information is used as the output data of the second training model to train the second training model. The first and second trained models are sequentially concatenated to generate an image document correction model.

7. An image document correction device, characterized in that, The device includes: An acquisition module is used to acquire multiple image documents, wherein the image documents have corresponding rotation angles; The first correction module is used to correct the image document based on the first preset algorithm to generate a first image document, wherein the rotation angle corresponding to the first image document is a positive standard position angle; The image enhancement module is used to perform image enhancement processing on the first image document based on a second preset algorithm to generate a second image document, wherein the rotation angle corresponding to the second image document is a positive standard position angle or a non-standard positive position angle; The training module is used to input the second image document into the initial neural network model for training, and generate an image document correction model; The recognition module is used to acquire the image document to be recognized, recognize the image document to be recognized through the image document correction model, and obtain the rotation angle of the image document to be recognized. The second correction module is used to correct the image document to be recognized by the rotation angle and generate a target orientation image document; The image enhancement module is further configured to determine a first target image from multiple first image documents using a preset random probability algorithm, perform a table addition operation on the first target image to generate a first enhanced image, and determine the first enhanced image and the first image document without the table addition operation as the first intermediate image; The first intermediate image is rotated using a preset random probability algorithm to generate a second intermediate image. A third target image is determined from the second intermediate image using a preset random probability algorithm. A color inversion operation is performed on the third target image to generate a third enhanced image. The third enhanced image and the second intermediate image without color inversion are determined as the third intermediate image. A fourth target image is determined from the third intermediate image using a preset random probability algorithm. The fourth target image is then cropped to generate a fourth enhanced image. The fourth enhanced image and the third intermediate image without cropping are then identified as the fourth intermediate image. A fifth target image is determined from the fourth intermediate image using a preset random probability algorithm. A texture mapping operation is performed on the fifth target image to generate a fifth enhanced image. The fifth enhanced image is then determined to be the fifth intermediate image. The fifth intermediate image is scaled to generate the sixth enhanced image; The sixth enhanced image is subjected to a channel transformation operation to generate a second image document.

8. A computer device, the computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 6.