Document image correction method and device, storage medium and computer equipment

By using standard document images for feature matching and mapping calculations, the problem of difficult and poor training of document correction models is solved, the accuracy and generalization ability of document correction are improved, and the application scope of the model is enhanced.

CN118898845APending Publication Date: 2024-11-05BEIJING XUEDIRUANJIAN DEVELOPMENT CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411079065.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2024-11-05

AI Technical Summary

Technical Problem

The existing document correction model is difficult to train and has poor results, especially in extreme cases, which is difficult to achieve ideal correction results, which affects the reliability and user experience of document correction.

Method used

Standard document images are used as reference for document images to be corrected, feature matching and mapping calculations are performed through the pre-trained document correction model, image mapping parameters are obtained for deformation processing, and the corrected target document image is obtained.

Benefits of technology

It improves the accuracy and generalization ability of document correction, reduces the cost and time of model training, ensures the complete retention of detailed information such as text and graphics, and enhances the application scope and applicability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118898845A_ABST
    Figure CN118898845A_ABST
Patent Text Reader

Abstract

The invention discloses a document image correction method and device, a storage medium and computer equipment, and relates to the technical field of image processing. The method comprises the steps of obtaining a to-be-corrected document image, and performing frame cutting on the to-be-corrected document image to obtain an initial document image; based on the initial document image, a standard document image corresponding to the initial document image is searched in a preset standard document library; correcting the image features of the initial document image based on the image features of the standard document image through a pre-trained document correction model to obtain image mapping parameters of the initial document image; and based on the image mapping parameter, performing deformation processing on the initial document image to obtain a corrected target document image. According to the method, the training difficulty of the document correction model and the collection difficulty of the sample data can be effectively reduced, and the correction effect of the document image can be greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a document image correction method, device, storage medium and computer equipment. Background Art

[0002] Document correction technology plays a vital role in AI (Artificial Intelligence) technology-related products, especially in applications focusing on document processing. Document correction can restore deformed document images caused by shooting angles, uneven lighting or other factors to their original shapes. The corrected document images not only improve the visual effect, but also improve the accuracy of subsequent processing steps, such as improving the accuracy of optical character recognition (OCR).

[0003] At present, the mainstream document correction methods are mainly based on deep learning algorithms. This type of method can achieve image correction through complex neural network models, and its optimization strategy mainly focuses on two aspects: one is to refine the model structure to enhance the correction ability; the other is to improve the quality of training data to promote model learning.

[0004] However, as the model structure becomes more complex, the computational burden of the model is greatly increased, resulting in longer model inference time. Moreover, in order to train a high-performance document correction model, a large amount of high-quality and diverse annotated data is usually required. However, the collection and preparation of this data is often time-consuming, labor-intensive, and costly, which limits the development speed and application scope of the model. In addition, even for optimized models, for document images in some extreme cases, such as severe distortion or shadow occlusion, the existing document correction methods still cannot achieve the ideal correction effect, thus affecting the reliability of document correction and user experience. Summary of the invention

[0005] In view of this, the embodiments of the present application provide a document image correction method, apparatus, storage medium and computer equipment, the main purpose of which is to solve the technical problems of difficult training of document correction models and poor document correction effects.

[0006] According to one aspect of the present application, a document image correction method is provided, the method comprising:

[0007] Acquire a document image to be corrected, and perform border cropping on the document image to be corrected to obtain an initial document image;

[0008] Based on the initial document image, searching a preset standard document library for a standard document image corresponding to the initial document image;

[0009] Correcting the image features of the initial document image based on the image features of the standard document image using a pre-trained document correction model to obtain image mapping parameters of the initial document image;

[0010] Based on the image mapping parameters, the initial document image is deformed to obtain a corrected target document image.

[0011] According to another aspect of the present application, a document image correction device is provided, the device comprising:

[0012] An image cropping module is used to obtain a document image to be corrected, and perform border cropping on the document image to be corrected to obtain an initial document image;

[0013] An image search module, configured to search a preset standard document library for a standard document image corresponding to the initial document image based on the initial document image;

[0014] An image recognition module, configured to correct the image features of the initial document image based on the image features of the standard document image through a pre-trained document correction model, so as to obtain image mapping parameters of the initial document image;

[0015] The image correction module is used to perform deformation processing on the initial document image based on the image mapping parameters to obtain a corrected target document image.

[0016] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned document image correction method is implemented.

[0017] According to another aspect of the present application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned document image correction method when executing the program.

[0018] By means of the above technical solution, a document image correction method and device, storage medium and computer equipment provided in the embodiment of the present application can more accurately identify and correct the complex deformation and distortion in the initial document image by using a standard document image as a reference image of the document image to be corrected, and using a document correction model for feature matching and mapping calculation, so as to ensure that the text, graphics and other detailed information in the original image can be completely preserved, thereby avoiding the blurring, distortion and other problems that may be introduced by traditional methods, and improving the correction accuracy of the document. In addition, the document correction model used in the above method can be trained through conventional model structures and training data, without the need for complex network architecture or a large amount of specific annotation data, thereby reducing the cost and time of model training. Moreover, since the document correction model learns the image mapping relationship between the deformed image and the standard image, the above document correction model can learn richer and more accurate correction strategies, thereby enhancing the generalization ability of the model and the prediction ability of the image mapping relationship.

[0019] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0021] Figure 1 A schematic diagram of a process of a document image correction method provided in an embodiment of the present application is shown;

[0022] Figure 2 A schematic diagram showing a flow chart of another document image correction method provided in an embodiment of the present application is shown;

[0023] Figure 3 A schematic diagram of a page of a document image to be corrected provided in an embodiment of the present application is shown;

[0024] Figure 4 A schematic diagram of a page of a standard document image provided by an embodiment of the present application is shown;

[0025] Figure 5 A page schematic diagram of a target document image provided by an embodiment of the present application is shown;

[0026] Figure 6 A schematic diagram of the structure of a document image correction device provided in an embodiment of the present application is shown;

[0027] Figure 7 A schematic structural diagram of another document image correction device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0028] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.

[0029] At present, document correction technology generally relies on deep learning algorithms, and the core optimization strategies of the algorithms mainly focus on improving the model architecture and the quality of training data. However, complex model structures may slow down the reasoning speed of the model, thereby limiting the application of document correction functions on mobile platforms; high-quality training data is expensive and difficult to fully cover all application scenarios, especially in the case of extreme deformation, it is often difficult to achieve a relatively ideal correction effect.

[0030] In response to the above problems, this application proposes a document image correction solution for specific scenarios. Among them, specific scenarios refer to document correction scenarios that are suitable for "standard template" characteristics, such as educational aids (examination papers, textbooks, exercise books, etc.), medical records (medical records, examination reports, etc.), legal documents (contracts, judgments, etc.), financial documents (invoices, receipts, etc.), etc. In these scenarios, the document types are relatively fixed. Therefore, the document images provided by the user can be compared and corrected through a predefined standard library. This can not only improve the efficiency and accuracy of the correction, and enhance the correction ability in extreme deformation situations, but also effectively simplify the model training process, reduce the model's dependence on high-quality sample data, and enable the correction model to achieve excellent correction performance through conventional structures and sample data sets.

[0031] In one embodiment, the core idea of ​​the above document correction method is as follows: Figure 1 As shown, a document image correction method is provided, which is described by taking the method applied to a computer device such as a server or a client as an example, and includes the following steps:

[0032] Step 101 , obtaining a document image to be corrected, and performing border cropping on the document image to be corrected to obtain an initial document image.

[0033] The document image refers to a digital image obtained by scanning or photographing a paper document containing text, graphics and other information. The document image may be deformed or distorted due to factors such as shooting angle and lighting conditions. Border cropping refers to removing unnecessary edge parts from the original document image, such as removing unnecessary background and borders when scanning or photographing, to obtain an initial document image that focuses more on the document content.

[0034] Specifically, the computer device can collect the document image to be corrected through terminal devices such as scanners, digital cameras, and smart mobile devices, and can also obtain the document image to be corrected through the Internet or electronic documents (such as PDF files). Among them, the extracted document image may be distorted, tilted, or irregular due to reasons such as incorrect shooting angles, page wrinkles, and uneven light. Furthermore, the computer device can identify the boundaries in the document image through image processing techniques, such as edge detection algorithms, contour recognition algorithms, page content extraction models, and other algorithms or models, and then cut off all areas outside the identified boundaries, retaining only the part containing the document content, and obtaining the initial document image. Among them, the boundaries of the document image may be the white edges of the document, shadow areas, or areas with obvious color changes. This step can reduce background noise and unnecessary processing areas in the document image, making the document image easier to search.

[0035] Step 102: Based on the initial document image, a standard document image corresponding to the initial document image is searched in a preset standard document library.

[0036] Among them, the standard document library refers to a database containing standard document images of various types and formats. The standard document images in the standard document library are usually high-quality, non-deformed and standardized images. Among them, the standard document images can be stored in various forms. For example, for each standard document in the standard document library, the document image itself and the image features, text content and identifiers (such as coded images such as QR codes and bar codes or specific identifiers such as document titles and logos) corresponding to the document image can be stored. By storing various information of standard document images in the standard document library, the search efficiency and search accuracy of standard document images can be improved. In this embodiment, the standard document library can continuously receive new documents and automatically update the new documents to the standard library, thereby improving the search capability for new documents.

[0037] Specifically, the computer device can compare the initial document image with the images in the standard document library through a feature matching algorithm (such as SIFT, SURF, etc.) or a deep learning model (such as a convolutional neural network CNN), and calculate the similarity or distance between the initial document image and the standard document images in the standard document library through the feature matching algorithm or the deep learning model, thereby searching for the standard image that best matches the initial image based on the comparison result of the similarity or distance as the standard document image corresponding to the initial document image. Figure 3 A document image to be corrected is provided. The initial document image obtained after border cropping can be used as a basic file. A standard document image corresponding to the initial document image is searched in a standard document library. The standard document image is as follows: Figure 4 As shown. Figure 3 and Figure 4 It can be seen that Figure 3 The original document image uploaded by the user contains not only the document information, but also the background information and the user's handwriting trace information. The standard document image only contains Figure 3 The same document information as in the document information, at the same time, Figure 3 It is also a high-quality, undistorted, and normalized image.

[0038] Step 103, using a pre-trained document correction model, the image features of the initial document image are corrected based on the image features of the standard document image to obtain image mapping parameters of the initial document image.

[0039] The document correction model refers to a deep learning model obtained by training a large number of standard document images and corresponding deformed images. The document correction model can learn the mapping relationship from the deformed image to the standard image, and can adopt a convolutional neural network (CNN), a generative adversarial network (GAN) or other types of deep learning architectures. Image features refer to features in an image that can be used to distinguish and identify different objects or contents, such as edges, textures, shapes, etc. Image mapping parameters refer to the deformation parameters required to convert the initial document image into an image in a standard state, such as echo point coordinates, pixel mapping relationships, etc.

[0040] Specifically, the computer device can pass the initial document image and the standard document image as input to the document correction model, and the document correction model can analyze the image features of the two images, such as edges, corners, textures, etc., and calculate the image mapping parameters required to convert the initial document image into a document in a standard state. The image mapping parameters may include echo point coordinates, pixel mapping relationships, etc., wherein the image mapping parameters can deform the initial document image into a layout and shape that can match the standard document image.

[0041] Step 104 , based on the image mapping parameters, the initial document image is deformed to obtain a corrected target document image.

[0042] Specifically, the computer device can use image deformation technology, such as affine transformation algorithm, perspective transformation algorithm and other algorithms, to deform the initial document image according to the calculated image mapping parameters. During the deformation process, each pixel or point in the initial document image can be adjusted according to the mapping parameters to eliminate the distortion and tilt in the image, thereby obtaining a corrected target document image. The target document image can visually present the correct direction and shape, and the content remains clear and intact.

[0043] It should be noted that the image mapping parameters of the initial document image predicted by the computer device refer to the mapping relationship between all feature points in the initial document image and the feature points on the corrected document, which includes the original content in the document page and the trace features left by the user on the document page, such as the content written by the user, etc. The document correction model can obtain the appearance of the image in an ideal state (i.e., the standard document image) by inputting the initial document image and the corresponding standard document image, which helps the model learn how to align the feature points in the initial document image with the feature points in the standard document image, thereby improving the accuracy and robustness of the correction. At the same time, the model only uses the standard document image as a reference for restoring the initial document image in text form and image form, and its correction target is still the initial document image itself. Therefore, the model will only correct the points or pixels in the initial document image so that the initial document image can be restored to a more ideal state. For example, if Figures 3 to 5 As shown, Figure 3 is a document image to be corrected. By performing border cropping operation on it, the initial document image can be obtained. Figure 4 is the standard document image corresponding to it, Figure 5 It is the target document image obtained by correcting the initial document image through the standard document image. Figures 3 to 5 It can be seen that the document correction model can not only Figure 3 The document content in the document can be restored, and the trace information in the document can also be restored, thereby ensuring the lossless display of the document content and improving the quality of the document image and the user experience.

[0044] The technical solution provided in this embodiment, by using a standard document image as a reference image of the document image to be corrected, and using a document model for feature matching and mapping calculation, can more accurately identify and correct the complex deformation and distortion in the initial document image, so as to ensure that the text, graphics and other detailed information in the original image can be completely preserved, thereby avoiding the blurring, distortion and other problems that may be introduced by traditional methods, and improving the correction accuracy of the document. In addition, the document correction model used in the above method can be trained through conventional model structures and training data, without the need for complex network architecture or a large amount of specific annotation data, thereby reducing the cost and time of model training. Moreover, since the document correction model learns the image mapping relationship between the deformed image and the standard image, the above document correction model can learn a richer and more accurate correction strategy, thereby enhancing the generalization ability of the model and the prediction ability of the image mapping relationship.

[0045] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, another document image correction method is provided, such as Figure 2As shown, the method includes:

[0046] Step 201, obtain a sample document image and a standard document image corresponding to the sample document image, train a neural network model based on the sample document image and the standard document image, and obtain a document correction model.

[0047] Specifically, before model training, the computer device can first collect a large number of sample document images and their corresponding standard document images as a training data set. Among them, the sample document images can come from various scanning devices or camera devices, so the sample document images may have various deformations and noises, such as distortion, tilt, perspective transformation, etc. In contrast, the standard document images are the accurately corrected versions corresponding to these sample document images, usually rectangular document images with correct content layout. In addition, in the training data set, a part of samples lacking standard document images can also be set. In this embodiment, an image of the same size as the sample document image can be generated for the sample lacking the standard document image, and its background color can be a uniform color, for example, all set to white. This sample processing method can ensure that in the absence of a standard image reference, the model can also learn to correct the document content as much as possible, and place the corrected content on a white background, thereby simulating a standardized output.

[0048] Furthermore, the computer device can use the processed sample document image and its corresponding standard document image or corresponding white background image to train the selected neural network model. During the model training process, the model can learn to extract features from the input sample document image and predict the corresponding corrected image, that is, the model can try to minimize the difference between the predicted image and the standard image. This process can involve iterative steps such as forward propagation to calculate the loss and back propagation to update the model parameters until the model performance reaches the preset standard, and a trained document correction model can be obtained.

[0049] By setting sample document images containing various deformations and noises, this embodiment enables the document correction model to learn how to extract key information from these complex scenes and effectively correct the document images, so that when processing document images in practical applications, the original appearance of the document can be restored more accurately, and the accuracy and efficiency of information extraction can be improved. In addition, for samples that lack standard document images, this embodiment introduces white background images as alternative standards, so that the model can learn how to deal with such special cases during the training process. This processing method not only reduces the difficulty and cost of data collection, but also significantly improves the model's correction ability for such samples. In practical applications, when encountering similar document images without standard references, the model can correct them to a relatively standardized state based on the learned knowledge, thereby expanding the scope of application and practicality of the model.

[0050] Step 202: Acquire the document image to be corrected, perform border cropping on the document image to be corrected, and obtain an initial document image.

[0051] Specifically, the implementation process of step 202 may refer to step 101 and will not be described in detail here.

[0052] In an optional implementation, the document image to be corrected may be frame cropped by at least one of the following methods. Furthermore, the two methods may be used in combination with each other, which is not specifically limited herein.

[0053] Step 202-1, extracting document page features from the document image through a pre-trained contour recognition model, and based on the document page features, identifying the position of the document page in the document image, and cropping the document image according to the position of the document page to obtain an initial document image.

[0054] In this embodiment, the computer device can use a pre-trained contour recognition model to perform border cropping. First, the contour recognition model can be trained on a large number of images with document page features annotated through deep learning technology, so as to learn to recognize the unique features of the document image, such as page edges and corners. Then, when processing the document image to be corrected, the contour recognition model can extract these features and determine the precise position of the document page based on them. Subsequently, the computer device can crop the document image according to the identified document page position, thereby removing the background or irrelevant content outside the page to obtain the initial document image.

[0055] Step 202-2, image enhancement processing is performed on the document image to be corrected, and contour information in the document image after image enhancement processing is identified through edge detection algorithm and contour search algorithm, and the document image is frame cropped based on the contour information to obtain an initial document image.

[0056] In this embodiment, the computer device can also combine algorithms such as image enhancement, edge detection and contour finding to perform border cropping. First, the computer device can perform image enhancement processing on the document image, such as contrast enhancement, noise suppression, etc., to improve the image quality and make the edge information clearer. Then, an edge detection algorithm (such as Canny edge detector) can be applied to identify edge points in the image, which usually correspond to the boundaries of the document page. Then, a contour finding algorithm (such as Hough transform) can be used to extract complete contour lines from the edge points, and these contour lines are the boundaries of the document page. Finally, the document image can be cropped according to the identified contour information to obtain an initial document image.

[0057] It should be noted that step 202-1 and step 202-2 can be used alone or in combination to improve the accuracy and robustness of border cropping. For example, step 202-1 can be used to perform preliminary cropping first, and then step 202-2 can be used to fine-tune the result, etc. This embodiment does not make specific limitations here.

[0058] This embodiment can remove unnecessary edge parts of the document image by performing border cropping on the document image to be corrected, so that the object of subsequent correction processing is more concentrated, thereby reducing the amount of image processing calculations and improving image processing efficiency. In addition, border cropping helps to more accurately locate the position of the document page, thereby providing more accurate input for subsequent correction processing. In particular, when the document image has a complex background or deformation, border cropping can remove irrelevant external interference factors, so that the correction model can focus more on the document content itself, thereby improving the accuracy of correction.

[0059] Step 203: Based on the initial document image, a standard document image corresponding to the initial document image is searched in a preset standard document library.

[0060] Specifically, the implementation process of step 203 may refer to step 102, which will not be described in detail here.

[0061] In an optional implementation, the standard document image corresponding to the initial document image may be searched for by at least one of the following methods. The three methods may also be used in combination with each other, which are not specifically limited herein.

[0062] Step 203-1, extract image features from the initial document image, and perform similarity comparison between the extracted image features and the image features of each standard document image in the standard document library, and determine the standard document image corresponding to the initial document image based on the similarity comparison result of the image features.

[0063] In this embodiment, the computer device can use a global image feature comparison method to search for standard document images. Specifically, the computer device can first use image feature extraction technology to extract features from the initial document image to generate a feature descriptor that represents the global characteristics of the image. Subsequently, the image features of each standard document image in the standard document library can be traversed (the image features of the standard document images in the standard document library can be extracted during the search, or when the standard images are stored in the library, and mapped and stored with the standard document images). Afterwards, the computer device can use a feature matching algorithm to calculate the similarity between the feature descriptors of the initial document image and each image in the standard document library, and finally, based on the similarity comparison results, select the standard document image with the highest similarity as the standard document image corresponding to the initial document image.

[0064] Step 203-2, extracting key areas from the initial document image, and performing similarity comparison between image features of the key areas and image features of key areas of each standard document image in the standard document library, and determining a standard document image corresponding to the initial document image based on the similarity comparison result of the image features of the key areas, wherein the key areas include coded graphics and / or specific logos.

[0065] In this embodiment, the computer device can use the key area feature comparison method to search the standard document image. Specifically, based on the fact that document images often contain some specific key areas, such as QR codes, bar codes, company logos, specific text boxes and other areas, these areas usually play an important role in the unique identification of documents. Therefore, the image features of these key areas can be accurately located and extracted in the initial document image. Subsequently, only the image features of these key areas and the key areas of the standard document images in the standard document library are compared for similarity, so as to determine the standard document image corresponding to the initial document image. This method can focus more on the core features of the document and improve the accuracy and efficiency of the search.

[0066] Step 203-3, extract text information from the initial document image, and perform similarity comparison between the text information and the text information of each standard document image in the standard document library, and determine the standard document image corresponding to the initial document image based on the similarity comparison result of the text information.

[0067] In this embodiment, the computer device can also use a text information comparison method to search for standard document images. Specifically, for document images containing a large amount of text information, the text content in the initial document image can also be extracted by optical character recognition technology. Then, the extracted text information is compared with the text information of each standard document image in the standard document library. This comparison of text content can be based on a simple string matching algorithm, or a more complex natural language processing technology can be used to evaluate the semantic similarity between texts. Finally, based on the similarity comparison results of the text information, the standard document image that best matches the initial document image is determined.

[0068] It should be noted that, in actual applications, one or more of the above search methods can be selected and combined with each other according to the specific characteristics and requirements of the document image to achieve a better search effect. Corresponding to the above multiple image search methods, the standard document library can store at least one information of the standard document image, including the standard document image itself and the image features corresponding to the standard document image, the image features of the key area and text information, etc., so as to improve the search efficiency and search accuracy of the standard document image.

[0069] This embodiment adopts a variety of search strategies, including global image feature comparison strategy, key area feature comparison strategy and text information comparison strategy, and can flexibly select one or more image search strategies in combination with specific application scenarios, thereby significantly improving the search efficiency and accuracy of standard document images. In addition, when facing complex and changeable document images, such as scenes with severe deformation, occlusion and noise, by combining multiple search methods, the feature information in the document image can be more comprehensively captured, thereby improving the adaptability and robustness of the system to various types of document images. Even when some feature information is missing or blurred, effective matching can be achieved through other feature information.

[0070] Step 204 , when no standard document image corresponding to the initial document image is found, a reference image having the same size as the initial document image and a background color of a preset color is generated, and the reference image is used as the standard document image corresponding to the initial document image.

[0071] Specifically, when the computer device fails to search for a standard document image corresponding to the initial document image, it can obtain the width and height information of the initial document image to determine the size of the reference image. Then, the computer device can determine a preset background color for the reference image, wherein the preset color is usually a universal, non-interfering color, such as white (#FFFFFF), light gray (#F5F5F5), etc., to facilitate subsequent processing. Subsequently, the computer device can use image processing software to create a new image file based on the size of the initial document image and the preset background color. This new image file has the same size as the initial document image, and all its pixels are set to the preset background color. After the reference image is generated, it can be used as the standard document image corresponding to the initial document image. In the subsequent processing flow, the reference image can be used to replace the missing standard document image to perform document correction and other operations.

[0072] This embodiment can ensure the continuity of the document processing flow by generating a reference image as a substitute standard document image when the standard document image corresponding to the initial document image cannot be searched. This processing method avoids processing interruption or failure caused by the lack of a standard document image, and improves the stability and reliability of the system. In addition, by using the reference image as the standard document image corresponding to the initial document image, the document correction model can be used to correct the initial document image through the reference image compatibility, thereby providing a flexible and effective solution for the situation where the corresponding standard document image cannot be found.

[0073] Step 205 , using a pre-trained document correction model, the image features of the initial document image are corrected based on the image features of the standard document image to obtain image mapping parameters of the initial document image.

[0074] Specifically, the implementation process of step 205 may refer to step 103, which will not be described in detail here.

[0075] In an optional embodiment, the document correction model can obtain the image mapping parameters of the initial document image in the following manner: input the image features of the initial document image and the image features of the standard document image into a pre-trained document correction model, and perform feature fusion on the image features of the initial document image and the image features of the standard document image through the document correction model, and then predict the mapping relationship between the initial document image and the standard document image based on the fused image features through the document correction model to obtain the image mapping parameters of the initial document image.

[0076] Specifically, the computer device can input the image features of the initial document image and the standard document image into the pre-trained document correction model. These image features may include edge information, texture features, shape features, etc. Among them, the document correction model has been trained on a large number of document image pairs with correct mapping relationships annotated, and has learned how to predict the mapping relationship between images based on image features. Therefore, within the model, the model will perform feature fusion processing on the input image features, that is, fuse the two sets of features into a unified feature representation for subsequent processing. Then, based on this fused feature representation, the model can predict the mapping relationship between the initial document image and the document in the standard state. This mapping relationship can be pixel-level, that is, the correspondence between each pixel point between the two images, or it can be a coarse-grained mapping based on key points or pixel blocks. Finally, the image mapping parameters of the initial document image can be calculated based on the predicted mapping relationship. These parameters can be echo point coordinates, that is, the coordinate position where a specific key point in the initial document image should be located after correction, or they can be pixel mapping relationships, that is, the position where each pixel point or pixel block in the initial document image should be mapped to the document image after correction.

[0077] This embodiment corrects the initial document image through a pre-trained document correction model, and can accurately predict the mapping relationship between the initial document image and the document in the standard state, so as to achieve accurate correction of the initial document image. In addition, this embodiment can select a more appropriate correction method according to actual needs by correcting based on key points or based on pixel mapping, so that the document correction method can be applied to different types of document images and different correction demand scenarios.

[0078] In an optional implementation, the image mapping parameters include echo point coordinates or pixel mapping relationships, and the image mapping parameters of the initial document image can be specifically acquired in any of the following ways.

[0079] Step 205-1, through the document correction model, based on the fused image features, predict the coordinate positions of the key points in the initial document image to the key points on the standard document image, obtain the key point coordinates of the initial document image, and perform interpolation transformation processing based on the key point coordinates to obtain the echo point coordinates of the initial document image.

[0080] In this embodiment, the document correction model can obtain the image mapping parameters of the initial document image by using a prediction method based on key point coordinates. Specifically, the document correction model can extract key information from the fused image features, and analyze and predict the corresponding coordinate positions of a series of key points in the initial document image on the document under the standard state, wherein the key points may include document corners, edge intersections, positioning points of various parts of the text content in the document, and the like. Then, the model can perform interpolation transformation processing on the predicted key points. Among them, interpolation transformation is a mathematical method that can be used to estimate the coordinates of other positions in the image based on known key point coordinates. In this embodiment, the key point coordinates can be used as control points, and through interpolation algorithms such as bilinear interpolation, bicubic interpolation, etc., the positions of multiple points in the initial document image after correction are calculated, thereby obtaining the coordinates of the echo points.

[0081] This embodiment can calculate the mapping relationship between the initial document image and the document in the standard state through the prediction of key point coordinates and the interpolation transformation algorithm. The above method has a small amount of calculation and strong robustness, and is more suitable for document images where key points are easy to extract and stable. In addition, the application of interpolation transformation also ensures the smoothness and continuity of the mapping result, thereby improving the quality of the corrected image.

[0082] Step 205-2, through the document correction model, based on the fused image features, predict the mapping relationship between the pixel blocks in the initial document image and the pixel blocks in the standard document image, or predict the mapping relationship between the pixel points in the initial document image and the pixel points in the standard document image, to obtain the pixel mapping relationship of the initial document image.

[0083] In this embodiment, the document correction model can also use a method of predicting the mapping relationship between pixels or pixel blocks to obtain the image mapping parameters of the initial document image. Specifically, the document correction model can learn and predict the mapping relationship between each pixel or pixel block in the initial document image and the corresponding pixel or pixel block in the document under the standard state based on the fused image features. This mapping relationship can be a precise point-to-point mapping or a coarse-grained mapping based on pixel blocks. Point-to-point mapping requires the model to predict each pixel point, which has high accuracy but high computational complexity; pixel block-based mapping simplifies the problem by considering the overall relationship between pixel blocks, which can improve computational efficiency.

[0084] This implementation can achieve a more refined and accurate correction of the initial document image by predicting the mapping relationship between pixel points or pixel blocks. Compared with the key point-based method, this method has higher accuracy and flexibility, and is particularly suitable for application scenarios that require high correction results. At the same time, its computational complexity is relatively high, requiring more powerful computing resources and longer processing time. Therefore, in practical applications, a specific document correction model can be selected according to actual needs and resource conditions.

[0085] Step 206 , based on the image mapping parameters, the initial document image is deformed to obtain a corrected target document image.

[0086] Specifically, the computer device can select a corresponding deformation algorithm according to the type of image mapping parameters, such as echo point coordinates or pixel mapping relationships. Specifically, if the image mapping parameters are echo point coordinates, algorithms such as image affine transformation or perspective transformation can be used to calculate the transformation matrix from the key points in the initial document image to the target position (i.e., echo point coordinates), so as to achieve deformation processing of the entire image. This image deformation method is relatively simple and can be applied to most document correction scenarios. Furthermore, if the image mapping parameters are pixel mapping relationships, grid-based deformation algorithms such as Thin Plate Spline (TPS) or Radial Basis Function (RBF) interpolation can be used. According to the mapping relationship between given pixels or pixel blocks, the new positions of all pixels on the entire image are obtained by interpolation calculation, thereby achieving accurate deformation of the image.

[0087] In this embodiment, by deforming the initial document image, it is ensured that the processed target document image can accurately reflect the mapping relationship between the initial document image and the document in the standard state, while maintaining the clarity and readability of the image. In this embodiment, the target document image can also be post-processed, such as smoothing filtering, sharpening enhancement, etc., to further improve the quality of the image.

[0088] This embodiment can accurately correct the initial document image by deforming it based on the image mapping parameters, thereby eliminating its original deformation, tilt and other problems. Moreover, the automated correction process can be completed without manual intervention, greatly improving the efficiency of document processing. At the same time, since the correction process is based on the pre-trained model and image mapping parameters, it has high stability and reliability. The corrected target document image also has better visual effects and readability, making the text, graphics and other information in the document clearer and easier to read.

[0089] Step 207 , performing text completion processing and format correction processing on the corrected target document image to obtain a corrected target document image, and outputting the corrected target document image.

[0090] Specifically, the computer device can detect the text content in the corrected target document image, and when it is detected that the text content in the target document image is missing, the missing text content in the target document image is supplemented based on the text content in the standard document image, and then the target document image with the supplemented text content is subjected to document format correction processing through the pre-trained format correction model to obtain the target document image after format correction. In this embodiment, when the text content in the target document image is not missing, the target document image can also be directly subjected to document format correction processing through the format correction model, so that the format of the target document image can be more unified and standardized, thereby improving the visual effect of the document.

[0091] In this embodiment, the computer device can detect the text content of the corrected target document image through optical character recognition (OCR) technology or a text detection algorithm based on deep learning. This process can identify the text area in the image and its specific content, thereby providing a basis for subsequent text completion processing. When it is detected that the text content in the target document image is missing, such as part of the text is blocked, blurred or missing, the missing text can be completed based on the text content in the standard document image. In the process of completion, the text at the corresponding position in the standard document image can be extracted, and the text can be integrated into the missing area of ​​the target document image through image processing technology, such as font matching, color adjustment, etc., to restore the complete text content. After completing the text completion, the pre-trained format correction model can be used to perform format correction processing on the target document image. The format correction model can identify format errors in the document, such as inconsistent line spacing, inconsistent font size, incorrect alignment, etc., by pre-learning the specifications and standards of multiple document formats, and automatically adjust and correct the format errors therein to ensure that the document is visually more neat and standardized, which is convenient for subsequent reading and processing. Finally, the target document image after text completion and format correction can be output for further use or storage by the user.

[0092] This embodiment can effectively restore the missing text content in the target document image through text completion processing, ensuring the integrity and accuracy of the document information. Moreover, through format correction processing, it can automatically identify and correct format errors in the document, making the document visually neater and more standardized, reducing misunderstandings or errors caused by format problems. In addition, the text completion and format correction processes can be completed based on automated algorithms and models without any human intervention, greatly improving the efficiency and accuracy of document processing, and reducing labor costs and time costs.

[0093] The technical solution provided in this embodiment, by using a standard document image as a reference image of the document image to be corrected, and using a document model for feature matching and mapping calculation, can more accurately identify and correct the complex deformation and distortion in the initial document image, so as to ensure that the text, graphics and other detailed information in the original image can be completely retained, thereby improving the correction accuracy of the document. Moreover, the above method can further improve the standardization and readability of the document image through text completion and format correction operations, thereby improving the visual effect of the document image. In addition, the document correction model used in the above method can be trained through conventional model structures and training data, without the need for complex network architecture or a large amount of specific annotation data, thereby reducing the cost and time of model training. Moreover, the trained document correction model can also correct the initial document image for which the standard document image has not been searched, thereby increasing the scope of application of the model.

[0094] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. In addition, the numbers corresponding to the various steps in the above embodiments only serve as identification and are not used as a limitation on the order in which the steps are executed. The order in which the steps are executed in each embodiment can be set according to actual conditions.

[0095] Further, as Figures 1 to 5 The specific implementation of the method shown in the embodiment of the present application provides a document image correction device, such as Figure 6 As shown, the device comprises:

[0096] The image cropping module 31 can be used to obtain a document image to be corrected, and perform border cropping on the document image to be corrected to obtain an initial document image;

[0097] An image search module 32, which can be used to search for a standard document image corresponding to the initial document image in a preset standard document library based on the initial document image;

[0098] An image correction module 33, which can be used to correct the image features of the initial document image based on the image features of the standard document image through a pre-trained document correction model to obtain image mapping parameters of the initial document image;

[0099] The image processing module 34 may be used to perform deformation processing on the initial document image based on the image mapping parameters to obtain a corrected target document image.

[0100] In a specific application scenario, the image cropping module 31 can be specifically used to extract document page features from the document image through a pre-trained contour recognition model, and based on the document page features, identify the position of the document page in the document image, and perform border cropping on the document image according to the position of the document page to obtain an initial document image; and / or, perform image enhancement processing on the document image to be corrected, and identify the contour information in the document image after image enhancement processing through an edge detection algorithm and a contour search algorithm, and perform border cropping on the document image based on the contour information to obtain an initial document image.

[0101] In a specific application scenario, the image search module 32 can be specifically used to extract image features of the initial document image, and perform a similarity comparison between the extracted image features and the image features of each standard document image in the standard document library, and determine the standard document image corresponding to the initial document image based on the similarity comparison result of the image features; and / or, extract a key area from the initial document image, and perform a similarity comparison between the image features of the key area and the image features of the key areas of each standard document image in the standard document library, and determine the standard document image corresponding to the initial document image based on the similarity comparison result of the image features of the key area, wherein the key area includes a coded graphic and / or a specific logo; and / or, extract text information from the initial document image, and perform a similarity comparison between the text information and the text information of each standard document image in the standard document library, and determine the standard document image corresponding to the initial document image based on the similarity comparison result of the text information.

[0102] In specific application scenarios, such as Figure 7 As shown, the above-mentioned device also includes an image generation model 35, which can be used to generate a reference image with the same size as the initial document image and a preset background color when a standard document image corresponding to the initial document image is not searched out, and use the reference image as the standard document image corresponding to the initial document image.

[0103] In a specific application scenario, the image correction module 33 can be specifically used to input the image features of the initial document image and the image features of the standard document image into the pre-trained document correction model; through the document correction model, the image features of the initial document image and the image features of the standard document image are feature fused; through the document correction model, based on the fused image features, the mapping relationship between the initial document image and the standard document image is predicted to obtain the image mapping parameters of the initial document image.

[0104] In a specific application scenario, the image correction module 33 can be specifically used for the image mapping parameters including echo point coordinates or pixel mapping relationships; then, the document correction model is used to predict the mapping relationship between the initial document image and the standard document image based on the fused image features to obtain the image mapping parameters of the initial document image, including: the document correction model is used to predict the coordinate positions of the key points in the initial document image to the key points on the standard document image based on the fused image features to obtain the key point coordinates of the initial document image, and interpolation transformation processing is performed based on the key point coordinates to obtain the echo point coordinates of the initial document image; or, the document correction model is used to predict the mapping relationship between the pixel block in the initial document image and the pixel block in the standard document image based on the fused image features, or, the mapping relationship between the pixel points in the initial document image and the pixel points in the standard document image is predicted to obtain the pixel mapping relationship of the initial document image.

[0105] In specific application scenarios, such as Figure 7 As shown, the device also includes an image post-processing model 36, and the image post-processing model 36 can be used to detect the text content in the corrected target document image; when it is detected that the text content in the target document image is missing, the missing text content in the target document image is completed based on the text content in the standard document image; through the pre-trained format correction model, the target document image with the completed text content is subjected to document format correction processing to obtain a target document image after format correction.

[0106] It should be noted that for other corresponding descriptions of the functional units involved in the document image correction device provided in the embodiment of the present application, reference can be made to Figures 1 to 5 The corresponding description in the method will not be repeated here.

[0107] The embodiment of the present application also provides a computer device, which can be a personal computer, a server, a network device, etc. The computer device includes a bus, a processor, a memory and a communication interface, and can also include an input and output interface and a display device. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store location information. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in each method embodiment are implemented.

[0108] Those skilled in the art will appreciate that the structure of the above-mentioned computer device is only a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components, or combine certain components, or have a different arrangement of components.

[0109] In one embodiment, a computer-readable storage medium is provided. The computer-readable storage medium may be non-volatile or volatile, and stores a computer program thereon. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0110] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0111] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0112] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0113] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A document image correction method, characterized in that: The method comprises: Acquire a document image to be corrected, and perform border cropping on the document image to be corrected to obtain an initial document image; Based on the initial document image, searching a preset standard document library for a standard document image corresponding to the initial document image; Correcting the image features of the initial document image based on the image features of the standard document image using a pre-trained document correction model to obtain image mapping parameters of the initial document image; Based on the image mapping parameters, the initial document image is deformed to obtain a corrected target document image.

2. The method according to claim 1, characterized in that The step of performing border cropping on the document image to be corrected to obtain an initial document image includes: extracting document page features from the document image through a pre-trained contour recognition model, identifying the position of the document page in the document image based on the document page features, and performing border cropping on the document image according to the position of the document page to obtain an initial document image; and / or, The document image to be corrected is subjected to image enhancement processing, and contour information in the document image after image enhancement processing is identified through an edge detection algorithm and a contour search algorithm. Based on the contour information, the document image is subjected to border cropping to obtain an initial document image.

3. The method according to claim 1, characterized in that: The step of searching a preset standard document library for a standard document image corresponding to the initial document image based on the initial document image includes: Extracting image features from the initial document image, and performing similarity comparison between the extracted image features and the image features of each standard document image in the standard document library, and determining a standard document image corresponding to the initial document image based on the similarity comparison result of the image features; and / or, Extracting a key area from the initial document image, and performing a similarity comparison based on image features of the key area and image features of key areas of each standard document image in the standard document library, and determining a standard document image corresponding to the initial document image based on the similarity comparison result of the image features of the key area, wherein the key area includes a coded graphic and / or a specific mark; and / or, Text information is extracted from the initial document image, and a similarity comparison is performed between the text information and the text information of each standard document image in the standard document library. Based on the similarity comparison result of the text information, a standard document image corresponding to the initial document image is determined.

4. The method according to claim 1 or 3, characterized in that: The method further comprises: When no standard document image corresponding to the initial document image is searched out, a reference image having the same size as the initial document image and a preset background color is generated, and the reference image is used as the standard document image corresponding to the initial document image.

5. The method according to claim 1, characterized in that The pre-trained document correction model is used to correct the image features of the initial document image based on the image features of the standard document image to obtain the image mapping parameters of the initial document image, including: Inputting the image features of the initial document image and the image features of the standard document image into the pre-trained document correction model; By means of the document correction model, feature fusion is performed on the image features of the initial document image and the image features of the standard document image; The document correction model is used to predict the mapping relationship between the initial document image and the standard document image based on the fused image features, so as to obtain the image mapping parameters of the initial document image.

6. The method according to claim 5, characterized in that The image mapping parameters include echo point coordinates or pixel mapping relationships; the document correction model is used to predict the mapping relationship between the initial document image and the standard document image based on the fused image features to obtain the image mapping parameters of the initial document image, including: The document correction model is used to predict the coordinate positions of the key points in the initial document image to the key points on the standard document image based on the fused image features, to obtain the key point coordinates of the initial document image, and interpolation transformation processing is performed based on the key point coordinates to obtain the echo point coordinates of the initial document image; or The document correction model predicts the mapping relationship between the pixel blocks in the initial document image and the pixel blocks in the standard document image based on the fused image features, or predicts the mapping relationship between the pixel points in the initial document image and the pixel points in the standard document image, so as to obtain the pixel mapping relationship of the initial document image.

7. The method according to claim 1, characterized in that The method further comprises: Detecting text content in the corrected target document image; When it is detected that the text content in the target document image is missing, the missing text content in the target document image is supplemented based on the text content in the standard document image; Through the pre-trained format correction model, the target document image with the text content completed is subjected to document format correction processing to obtain the target document image after format correction.

8. A document image correction device, characterized in that: The device comprises: An image cropping module is used to obtain a document image to be corrected, and perform border cropping on the document image to be corrected to obtain an initial document image; An image search module, configured to search a preset standard document library for a standard document image corresponding to the initial document image based on the initial document image; An image correction module, configured to correct the image features of the initial document image based on the image features of the standard document image through a pre-trained document correction model, so as to obtain image mapping parameters of the initial document image; The image processing module is used to perform deformation processing on the initial document image based on the image mapping parameters to obtain a corrected target document image.

9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Distorted document image correction method and device

    CN111260586A

  • Document correction method and device, electronic equipment and storage medium

    CN114742722A

  • Document image correction model training method and document image correction method

    CN115984856A