An image correction method, device, electronic equipment and computer storage medium

By identifying text information in an image and matching it with preset anchor points, and calculating matrix transformation, the accuracy problem of traditional image correction methods when edge detection fails is solved, achieving higher image correction accuracy and applicability.

CN115631491BActive Publication Date: 2026-07-03CHINA CONSTRUCTION BANK +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA CONSTRUCTION BANK
Filing Date
2022-09-27
Publication Date
2026-07-03

Smart Images

  • Figure CN115631491B_ABST
    Figure CN115631491B_ABST
Patent Text Reader

Abstract

The application discloses an image correction method and device, electronic equipment and computer storage medium. The target text block obtained by identifying the to-be-corrected image is matched with the plurality of preset anchor point information in the target preset anchor point set corresponding to the image type, and the first matrix of the to-be-corrected image is determined according to the target preset anchor point information and the target text block obtained by matching. The second matrix is calculated according to the inverse matrix of the first matrix, and the perspective transformation is performed on the to-be-corrected image according to the second matrix, so that the target image is obtained. In this way, by matching the text block of the to-be-corrected image with the preset anchor point information, the accuracy of the matrix transformation equation can be improved, and the accuracy of the image correction can be improved. In addition, by identifying the text information in the to-be-corrected image instead of identifying the object edge, the limitation of the traditional image correction method can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of image processing technology, and in particular relates to an image correction method, apparatus, electronic device and computer storage medium. Background Technology

[0002] With the development of OCR technology, it is being used in more and more application scenarios to recognize text in user-uploaded images. However, for tilted or non-orthogonal images, the image needs to be corrected first to facilitate subsequent analysis and recognition of the text information in the image.

[0003] Currently, most traditional image correction methods are based on edge detection. They extract the contours of the objects to be identified in user-uploaded images, determine the tilt angle of the objects, and then correct the images. However, traditional image correction methods that rely on edge detection have poor image correction results when the contours of the objects are occluded or the edges cannot be accurately identified, and the algorithms and processing involved are also quite complex. Summary of the Invention

[0004] This application provides an image correction method, apparatus, electronic device, and computer storage medium, which can reduce the limitations of image correction methods that rely on edge detection, thereby improving the accuracy of image correction.

[0005] In a first aspect, embodiments of this application provide an image correction method, which may include:

[0006] Obtain the image to be corrected;

[0007] Based on the image type of the image to be corrected, a target preset anchor point set corresponding to the image type of the image to be corrected is determined from a set of multiple preset anchor points that are pre-configured. The target preset anchor point set includes information on multiple preset anchor points, and the image type of the image to be corrected corresponds one-to-one with the preset anchor point set.

[0008] The text information in the image to be corrected is recognized to obtain at least one text block, which includes text characters and text block coordinates.

[0009] Match the target text block with multiple preset anchor information in the target preset anchor point set to obtain the target preset anchor information that matches the target text block. The target text block is any one of at least one text block, and the target preset anchor information is any one of multiple preset anchor information.

[0010] Based on the target preset anchor point information and the target text block, determine the first matrix of the image to be corrected;

[0011] Calculate the inverse of the first matrix to obtain the second matrix;

[0012] Based on the second matrix, a perspective transformation is performed on the image to be corrected to obtain the target image.

[0013] In one embodiment, the aforementioned preset anchor point information includes preset anchor point coordinates and regular expressions. The step of matching the target text block with multiple preset anchor point information in the target preset anchor point set to obtain target preset anchor point information that matches the target text block may include:

[0014] Based on the text characters in the target text block, match them with the regular expressions in multiple preset anchor information in the target preset anchor set to obtain the target preset anchor information that matches the target text block;

[0015] Accordingly, the step of determining the first matrix of the image to be corrected based on the target preset anchor point information and the target text block mentioned above may include:

[0016] Based on the coordinates of the preset anchor points in the target preset anchor point information and the coordinates of the target text block, a first matrix of the image to be corrected is determined. The first matrix is ​​used to transform the coordinates of the preset anchor points in the preset anchor point set into the coordinates of the text blocks in the image to be corrected.

[0017] In one embodiment, after the step of determining the first matrix of the image to be corrected based on the target preset anchor point information and the target text block, the method may further include:

[0018] Based on multiple first matrices, the third matrix is ​​determined through linear regression.

[0019] Accordingly, the steps described above for calculating the inverse of the first matrix to obtain the second matrix may include:

[0020] Replace the first matrix with the third matrix;

[0021] Calculate the inverse of the third matrix to obtain the second matrix.

[0022] In one embodiment, after the step of performing perspective transformation on the image to be corrected according to the second matrix to obtain the target image, the method may further include:

[0023] In response to the selection operation of the target recognition region in the target image, the text information corresponding to the target region in the target image is recognized to obtain the first text recognition result. The multiple identifiable regions in the target image correspond one-to-one with the coordinates of multiple preset anchor points in the target preset anchor point set. The target recognition region is any one of the multiple identifiable regions.

[0024] In one embodiment, the step of recognizing text information corresponding to the target region in the target image and obtaining a first text recognition result in response to the selection operation of the target recognition region in the target image may include:

[0025] The first text recognition result is compared with the text characters in at least one text block to obtain a comparison result, which is used to indicate whether there is a recognition error in the text characters in at least one text block;

[0026] If the comparison result indicates that a character in at least one text block is misrecognized, the character in at least one text block is corrected based on the first text recognition result.

[0027] In one embodiment, after the step of performing perspective transformation on the image to be corrected according to the second matrix to obtain the target image, the method may further include:

[0028] Display the target image.

[0029] Secondly, this embodiment provides an image correction device, which may include:

[0030] The acquisition module is used to acquire the image to be corrected.

[0031] The first determining module is used to determine a target preset anchor point set corresponding to the image type of the image to be corrected from a pre-configured set of multiple preset anchor points according to the image type of the image to be corrected. The target preset anchor point set includes multiple preset anchor point information, and the preset anchor point information includes preset anchor point coordinates and regular expressions. The image type of the image to be corrected and the preset anchor point set correspond one-to-one.

[0032] The recognition module is used to recognize text information in the image to be corrected and obtain at least one text block, which includes text characters and text block coordinates.

[0033] The matching module is used to match the target text block with multiple preset anchor information in the target preset anchor set to obtain the target preset anchor information that matches the target text block. The target text block is any one of at least one text block, and the target preset anchor information is any one of multiple preset anchor information.

[0034] The second determining module is used to determine the first matrix of the image to be corrected based on the target preset anchor point information and the target text block;

[0035] The calculation module is used to calculate the inverse of the first matrix to obtain the second matrix;

[0036] The transformation module is used to perform perspective transformation on the image to be corrected based on the second matrix to obtain the target image.

[0037] Thirdly, embodiments of this application provide an electronic device, the device comprising:

[0038] processor;

[0039] Memory used to store processor-executable instructions;

[0040] The processor is configured to execute instructions to implement the image correction method as shown in any embodiment of the first aspect.

[0041] Fourthly, embodiments of this application provide a computer storage medium on which a computer program is stored, which, when executed by a processor, implements the image correction method as shown in any embodiment of the first aspect.

[0042] Fifthly, embodiments of this application also provide a computer program product comprising a computer program stored in a readable storage medium, wherein at least one processor of the device reads from the storage medium and executes the computer program, causing the device to perform the image correction method shown in any embodiment of the first aspect.

[0043] This application provides an image correction method, apparatus, electronic device, and computer storage medium. Compared with the prior art, this application has the following advantages:

[0044] This application discloses an image correction method, apparatus, electronic device, and computer storage medium. Based on the image type of the acquired image to be corrected, a target preset anchor point set corresponding to the image type of the image to be corrected is determined from a pre-configured set of multiple preset anchor points. Then, text information in the image to be corrected is recognized to obtain at least one text block. The target text block is matched with the multiple preset anchor point information in the target preset anchor point set. Based on the matched target preset anchor information and the target text block, a first matrix of the image to be corrected is determined. A second matrix is ​​calculated based on the inverse of the first matrix. A perspective transformation is then performed on the image to be corrected based on the second matrix to obtain the target image.

[0045] Thus, by determining the corresponding set of preset anchor points based on the image type of the image to be corrected, the image correction method can be applied to various image types and improve recognition accuracy. By matching text blocks in the image to be corrected with pre-set anchor point information, the accuracy of determining the matrix transformation equation can be improved, thereby improving the accuracy of image correction. Furthermore, since this method identifies text information in the image to be corrected rather than object edges, it does not rely on edge detection technology and can identify images where object edges are occluded, thus reducing the limitations of traditional image correction methods. Attached Figure Description

[0046] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 This is a schematic flowchart of an image correction method provided in an embodiment of this application;

[0048] Figure 2 This is a schematic diagram of an image to be corrected provided in an embodiment of this application;

[0049] Figure 3 This is a schematic diagram of another image to be corrected provided in an embodiment of this application;

[0050] Figure 4 This is a schematic diagram of a target image provided in an embodiment of this application;

[0051] Figure 5 This is a schematic flowchart of another image correction method provided in an embodiment of this application;

[0052] Figure 6 This is a flowchart illustrating another image correction method provided in an embodiment of this application;

[0053] Figure 7 This is a flowchart illustrating another image correction method provided in an embodiment of this application;

[0054] Figure 8 This is a flowchart illustrating another image correction method provided in an embodiment of this application;

[0055] Figure 9 This is a flowchart illustrating another image correction method provided in an embodiment of this application;

[0056] Figure 10 This is a schematic diagram of the structure of an image correction device provided in an embodiment of this application;

[0057] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0058] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.

[0059] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this application all comply with the relevant provisions of national laws and regulations.

[0060] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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 includes elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0061] As can be seen from the background section, since most traditional image correction methods are based on edge detection, the image correction effect is poor when the outline of the object is occluded or the edge cannot be accurately identified.

[0062] To address the problems existing in the prior art, embodiments of this application provide an image correction method, apparatus, electronic device, and computer storage medium. Based on the image type of the acquired image to be corrected, a target preset anchor point set corresponding to the image type of the image to be corrected is determined from a pre-configured set of multiple preset anchor points. Then, text information in the image to be corrected is recognized to obtain at least one text block. The target text block is matched with multiple preset anchor point information in the target preset anchor point set. Based on the matched target preset anchor point information and the target text block, a first matrix of the image to be corrected is determined. A second matrix is ​​calculated based on the inverse of the first matrix. A perspective transformation is then performed on the image to be corrected based on the second matrix to obtain the target image.

[0063] Thus, by determining the corresponding set of preset anchor points based on the image type of the image to be corrected, the image correction method can be applied to various image types and improve recognition accuracy. By matching text blocks in the image to be corrected with pre-set anchor point information, the accuracy of determining the matrix transformation equation can be improved, thereby improving the accuracy of image correction. Furthermore, since this method identifies text information in the image to be corrected rather than object edges, it does not rely on edge detection technology and can identify images where object edges are occluded, thus reducing the limitations of traditional image correction methods.

[0064] The image correction method provided in the embodiments of this application will be described below. For example... Figure 1 As shown, the image correction method provided in this application includes the following steps:

[0065] S101: Obtain the image to be corrected;

[0066] S102: Based on the image type of the image to be corrected, determine the target preset anchor point set corresponding to the image type of the image to be corrected from a set of multiple preset anchor points that are pre-configured. The target preset anchor point set includes multiple preset anchor point information, and the image type of the image to be corrected corresponds one-to-one with the preset anchor point set.

[0067] S103: Recognize the text information in the image to be corrected to obtain at least one text block, the text block including text characters and text block coordinates;

[0068] S104: Match the target text block with multiple preset anchor information in the target preset anchor set to obtain target preset anchor information that matches the target text block. The target text block is any one of at least one text block, and the target preset anchor information is any one of multiple preset anchor information.

[0069] S105: Determine the first matrix of the image to be corrected based on the target preset anchor point information and the target text block;

[0070] S106: Calculate the inverse of the first matrix to obtain the second matrix;

[0071] S107: Based on the second matrix, perform perspective transformation on the image to be corrected to obtain the target image.

[0072] The above describes an image correction method provided in this application. This method, based on the image type of the acquired image to be corrected, determines a target preset anchor point set corresponding to the image type from a pre-configured set of multiple preset anchor points. Then, it identifies text information in the image to be corrected to obtain at least one text block. The target text block is matched with multiple preset anchor point information in the target preset anchor point set. Based on the matched target preset anchor information and the target text block, a first matrix of the image to be corrected is determined. A second matrix is ​​calculated based on the inverse of the first matrix. A perspective transformation is then performed on the image to be corrected based on the second matrix to obtain the target image.

[0073] Thus, by determining the corresponding set of preset anchor points based on the image type of the image to be corrected, the image correction method can be applied to various image types and improve recognition accuracy. By matching text blocks in the image to be corrected with pre-set anchor point information, the accuracy of determining the matrix transformation equation can be improved, thereby improving the accuracy of image correction. Furthermore, since this method identifies text information in the image to be corrected rather than object edges, it does not rely on edge detection technology and can identify images where object edges are occluded, thus reducing the limitations of traditional image correction methods.

[0074] In S101, the image to be corrected is obtained. In one example, the image to be corrected may be as follows: Figure 2 As shown, this includes information such as name, number, and address. It is understood that the image to be corrected includes, but is not limited to, [other information]. Figure 2 The types shown are examples of images to be corrected, such as certificates and licenses.

[0075] In step S102, based on the image type of the image to be corrected, a target preset anchor point set corresponding to the image type of the image to be corrected is determined from a pre-configured set of multiple preset anchor points. The target preset anchor point set includes multiple preset anchor point information sets, and there is a one-to-one correspondence between the image type of the image to be corrected and the preset anchor point set. In one example, based on the image type of the image to be corrected, the corresponding target preset anchor point set is selected from the multiple preset anchor point sets, thereby obtaining all preset anchor point information included in the target preset anchor point set. The preset anchor point information includes preset anchor point coordinates and regular expressions. For example, when the image type of the image to be corrected is an identity verification certificate, the target preset anchor point set corresponding to the identity verification certificate is selected.

[0076] In one example, the anchor points include:

[0077] Anchor name: for easy memorization by the operator, it does not have a program function;

[0078] Anchor regular expressions (regexes): Used to match results recognized by OCR, such as "^Name$". Multiple regular expressions can be configured for each anchor.

[0079] Anchor point position (text_region): The position of the anchor point on the template image. It should be noted that the anchor point position here is the coordinate position of the template's length and width reference system. In other words, it is the position coordinate of a full-edge certificate after scaling it to the length and width defined by the template.

[0080] For example, the regular expression `^name$` would be positioned on the anchor template as `[(67,83)(153,115)]`, where the first point represents the top-left pixel coordinates and the second point represents the bottom-right pixel coordinates. A cube has four vertices, but since the frame in the template is a standard rectangle, it is abbreviated. It can be understood that the coordinates can include all four points.

[0081] In one example, before acquiring the image to be corrected, corresponding anchor point templates are pre-configured based on the image type. The anchor point template can be a set of preset anchor points, where each preset anchor point set includes at least one preset anchor point piece of information, and each preset anchor point piece of information corresponds to a text block in the image. For example, for configuring an anchor point template for a professional certificate, each preset anchor point piece of information in the template corresponds to text information such as the name, date, certificate number, and certificate level on the professional certificate. In one example, the anchor point template includes pixels of a standard edge image; for example, the pixels for an identity document are 856*540. It can be understood that the above pixel values ​​can be set according to actual needs. Furthermore, the aspect ratio of these pixels is used as a reference system for the positions of the preset anchor points included in the anchor point template.

[0082] In S103, the text information in the image to be corrected is recognized to obtain at least one text block, which includes text characters and text block coordinates.

[0083] OCR (Optical Character Recognition) refers to the process by which electronic devices (such as scanners or digital cameras) examine characters printed on paper and then translate their shapes into computer text using character recognition methods. In other words, it involves scanning text documents, analyzing the image files, and extracting text and layout information. Error correction and utilizing auxiliary information to improve recognition accuracy are the most important aspects of OCR. Key metrics for evaluating the performance of an OCR system include: rejection rate, false recognition rate, recognition speed, user interface friendliness, product stability, ease of use, and feasibility.

[0084] In one example, such as Figure 3As shown, a general OCR device is used to recognize text information in the image to be corrected, obtaining the position and text content of the OCR text block on the image to be recognized. It can be understood that since the anchor point coordinates include four points, the recognized text block can be a rectangle. For example, the position and text content of the OCR text block on the image to be recognized can be represented as: [OCRResult(text=Name,text_region=((113,67),(166,67),(166,88),(113,88))),OCRResult(text=Certificate Level,text_region=((52,106),(134,108),(133,129),(52,127))),]. It can be understood that here, text_region represents the coordinates of the text block in the image to be corrected.

[0085] In one example, multiple regular expressions can be configured in a pre-configured anchor template to assist in recognizing text blocks. For instance, for the anchor corresponding to "certificate level," to prevent the OCR model from incorrectly segmenting "certificate level" from "Grade A," or from failing to recognize the complete "certificate level" due to occlusion or other reasons, multiple regular expressions can be configured in the template, including "certificate level Grade A / Grade B" and "book level." In this way, the OCR model can still accurately recognize text blocks in the image to be corrected.

[0086] In S104, the target text block is matched with multiple preset anchor points in the target preset anchor point set to obtain the target preset anchor point information that matches the target text block. In one example, each text block is matched against each preset anchor point in the target preset anchor point set, and if a match is successful, it is recorded.

[0087] In S105, a first matrix of the image to be corrected is determined based on the target preset anchor point information and the target text block. In one example, the first matrix is ​​used to transform the coordinates of the preset anchor points in the coordinate system of the anchor point template (i.e., the preset anchor point set) into the coordinates of the text block on the image to be corrected.

[0088] In S106, the inverse of the first matrix is ​​calculated to obtain the second matrix. In one example, before calculating the inverse of the first matrix, the coordinates of each vertex of the certificate in the image to be recognized can also be calculated based on the first matrix. For example: for any anchor point template coordinates (x... i ,y i ), satisfying formula (1):

[0089]

[0090] H is the first matrix;

[0091] h 11 …h 33 These are the parameters in the first matrix;

[0092] x i The x-coordinate in the anchor point template coordinates;

[0093] y i The vertical coordinate in the anchor point template coordinate system;

[0094] z is the transformation coefficient.

[0095] For example, when the solution is obtained After z is 24, 28, and 4 respectively, for Dividing by z gives the image coordinates (6, 7).

[0096] Solving for the four points (0,0), (width,0), (width,height), and (0,height) yields the positions of the four vertices of the anchor point template corresponding to the identity certificate in the image to be corrected. For example, based on the four points (0,0), (856,0), (856,540), and (0,540), multiplying these four points in matrix form by H (i.e., formula (1)) yields [24.22,43.96,1.08]. Dividing 24.22 and 43.96 by 1.08 respectively gives the coordinates of the four points of the anchor point template corresponding to the identity certificate in the image to be corrected.

[0097] In S107, a perspective transformation is performed on the image to be corrected based on the second matrix to obtain the target image. In one example, after obtaining the coordinates of the four anchor point templates on the image to be corrected, the inverse matrix of the first matrix (i.e., the second matrix) is directly used to perform a perspective transformation on the image to be corrected to obtain the target image, as shown below. Figure 4 As shown.

[0098] To improve the accuracy of text recognition in images to be corrected, such as Figure 5 As shown, as an example, the preset anchor point information includes preset anchor point coordinates and regular expressions. S104 may include:

[0099] S501: Based on the text characters in the target text block, match them with the regular expressions in multiple preset anchor information in the target preset anchor set to obtain the target preset anchor information that matches the target text block;

[0100] Accordingly, S105 may include:

[0101] S502: Based on the preset anchor point coordinates of the target preset anchor point information and the text block coordinates of the target text block, determine the first matrix of the image to be corrected. The first matrix is ​​a matrix used to transform the preset anchor point coordinates in the preset anchor point set into the text block coordinates in the image to be corrected.

[0102] In this way, by matching the text characters in the target text block with the regular expressions in the multiple preset anchor information in the target preset anchor set, the target preset anchor information that matches the target text block can be obtained, which can improve the accuracy of recognizing text information in the image to be corrected.

[0103] In step S501, the text characters in the target text block are matched against regular expressions in multiple preset anchor information in the target preset anchor set to obtain target preset anchor information that matches the target text block. In one example, each text block is matched against each preset anchor information in the target preset anchor set, and if a match is successful, it is recorded. For example, at least one text block identified in the image to be corrected is matched against each preset anchor information in the anchor template corresponding to the identity verification, resulting in the following three results:

[0104] (1) Matched preset anchor point information:

[0105] text_region:[[71,211],[441,211],[441,239],[71,239]]

[0106] regexes:[^date\d{4}year\d{1,2}month\d{1,2}day$]

[0107] Recognized text block: date

[0108] OCRResult(text=August 4, 2000, text_region=((50,145),(280,146),(279,168),(50,167)))

[0109] (2) Matched preset anchor point information:

[0110] text_region:[[304,448],[755,450],[755,481],[304,480]]

[0111] regexes:['^[1-9]\\d{5}(18|19|20|21)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\ \d{3}[0-9Xx]$','^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$”]

[0112] The identified text blocks:

[0113] OCRResult(text=00000000000000000, text_region=((197,294),(455,294),(455,314),(197,314)))

[0114] (3) Matched preset anchor point information:

[0115] text_region:[[72,281],[517,281],[517,307],[72,307]]

[0116] regexes:[^address$]

[0117] The identified text blocks:

[0118] OCRResult(text=A Province B City C District,text_region=((48,186),(302,189),(302,214),(47,211)))

[0119] In S502, a first matrix of the image to be corrected is determined based on the coordinates of the preset anchor points in the target preset anchor point information and the coordinates of the text blocks in the target text blocks. The first matrix is ​​used to transform the coordinates of the preset anchor points in the preset anchor point set into the coordinates of the text blocks in the image to be corrected. In one example, the first matrix is ​​determined based on at least one result obtained from the matching in S501 above. Since the matrix in formula (1) is not a full-rank matrix, h 33 The default value is 1, and after basic matrix transformations, a full-rank matrix with 8 degrees of freedom is obtained. Since each matching result includes 4 vertices, and each coordinate (x...)... i ,y i Each matrix contains two data points, so only one matching result is needed to solve for the first matrix.

[0120] To reduce the error in transforming the image to be corrected using the first matrix, such as Figure 6As shown, as an example, after S105, it may also include:

[0121] S601: Determine the third matrix based on multiple first matrices using linear regression;

[0122] Accordingly, S106 may include:

[0123] S602: Replace the first matrix with the third matrix;

[0124] S603: Calculate the inverse of the third matrix to obtain the second matrix.

[0125] Thus, based on multiple first matrices, a third matrix is ​​determined through linear regression, and a second matrix for transforming the image to be corrected is determined based on the third matrix. This reduces the error caused by transforming the image to be corrected using the first matrices.

[0126] In step S601, a third matrix is ​​determined using linear regression based on multiple first matrices. In one example, because the positions of the text blocks recognized and marked by the general OCR model in the image to be corrected may not completely coincide with the original text positions in the image, transforming the image to be corrected using the first matrix obtained from a single preset anchor point matching result will result in bias. Therefore, using linear regression to fit multiple preset anchor point matching results can reduce the error caused by transforming the image to be corrected using the first matrix.

[0127] In one example, based on S502, multiple matching results are used for calculation and solution, and the third matrix is ​​determined through linear regression. For example, each of the three matching results includes 4 points, and each point includes two data points (i.e., x-coordinate and y-coordinate), so the total number of x-coordinates is 3*4*2=24. The above matrix is ​​transformed into a linear regression problem, and the linear regression expression is obtained, i.e., formula (2):

[0128] Y~h1x1+h2x2+h3x3+h4x4+h5x5+h6x6+h7x7+h8x8+e (2)

[0129] Where h1…h8 are the parameters in the matrix to be solved;

[0130] Y is the dependent variable in the linear regression expression;

[0131] x1…x8 represents 8 data points from multiple matching results;

[0132] e represents the linear regression error.

[0133] Then, according to formula (3), we can solve for h1…h8, and substitute them into formula (4) to obtain the third matrix.

[0134]

[0135]

[0136] Where N is the number of data points;

[0137] H3 is the third matrix.

[0138] To improve the efficiency of matching text blocks in a target image, such as Figure 7 As shown, as an example, S107 may also include:

[0139] S701: In response to the selection operation of the target recognition region in the target image, the text information corresponding to the target region in the target image is recognized to obtain the first text recognition result. The multiple identifiable regions in the target image correspond one-to-one with the coordinates of multiple preset anchor points in the target preset anchor point set. The target recognition region is any one of the multiple identifiable regions.

[0140] Thus, in response to the selection operation of the target recognition region in the target image, the text information corresponding to the target region in the target image is recognized, and the first text recognition result is obtained, which can improve the efficiency of matching text blocks in the target image.

[0141] In step S701, in response to the selection operation of a target recognition region in the target image, the text information corresponding to the target region in the target image is recognized to obtain a first text recognition result. Multiple identifiable regions in the target image correspond one-to-one with the coordinates of multiple preset anchor points in a set of preset anchor points. The target recognition region can be any one of the multiple identifiable regions. In one example, the user can select a target recognition region in the target image according to their needs. The target recognition region can be any text block in the target image. For example, if the user selects the "certificate number" region in the target image, the corresponding number information will be recognized.

[0142] To improve the accuracy of recognizing text information in target images, such as Figure 8 As shown, as an example, S701 may include:

[0143] S801: Compare the first text recognition result with the text characters in at least one text block to obtain a comparison result, which is used to indicate whether there is a recognition error in the text characters in at least one text block;

[0144] S802: If the comparison result indicates that a character in at least one text block has been misrecognized, the character in at least one text block shall be corrected based on the first text recognition result.

[0145] Thus, by comparing the first text recognition result with the text characters in at least one text block, and thereby correcting the text characters in at least one text block, the accuracy of recognizing text information in the target image can be improved.

[0146] In S801, the first text recognition result is compared with the text characters in at least one text block to obtain a comparison result. For example, the text recognition result "certificate serial number" is compared with "certificate number" and the comparison result indicates a recognition error.

[0147] In S802, if the comparison result indicates that a character in at least one text block has been misrecognized, the character in at least one text block is corrected based on the first text recognition result. For example, when the comparison result indicates a recognition error, the text recognition result "certificate number" is corrected based on "certificate number".

[0148] To improve user-friendliness, such as Figure 9 As shown, as an example, after S107, it may also include:

[0149] S901: Display the target image.

[0150] In one example, before displaying the target image, the portion of the target image excluding identification objects such as certificates is cropped, and the cropped target image is then displayed.

[0151] The above describes a specific implementation of an image correction method provided in this application. Based on the image correction method provided in the above embodiments, this application also provides a specific implementation of an image correction device, as described in the following embodiments.

[0152] like Figure 10 As shown in the embodiment of this application, an image correction device 1000 is provided, which includes:

[0153] Acquisition module 1001 is used to acquire the image to be corrected;

[0154] The first determining module 1002 is used to determine a target preset anchor point set corresponding to the image type of the image to be corrected from a pre-configured set of multiple preset anchor points according to the image type of the image to be corrected. The target preset anchor point set includes multiple preset anchor point information, and the preset anchor point information includes preset anchor point coordinates and regular expressions. The image type of the image to be corrected and the preset anchor point set correspond one-to-one.

[0155] The recognition module 1003 is used to recognize text information in the image to be corrected and obtain at least one text block, the text block including text characters and text block coordinates;

[0156] The matching module 1004 is used to match the target text block with multiple preset anchor information in the target preset anchor set to obtain the target preset anchor information that matches the target text block. The target text block is any one of at least one text block, and the target preset anchor information is any one of multiple preset anchor information.

[0157] The second determining module 1005 is used to determine the first matrix of the image to be corrected based on the target preset anchor point information and the target text block;

[0158] Calculation module 1006 is used to calculate the inverse of the first matrix to obtain the second matrix;

[0159] The transformation module 1007 is used to perform perspective transformation on the image to be corrected according to the second matrix to obtain the target image.

[0160] In the image correction device 1000 provided in this application embodiment, after the acquisition module 1001 acquires the image to be corrected, the first determining module 1002 determines a target preset anchor point set corresponding to the image type of the image to be corrected from a pre-configured set of multiple preset anchor points according to the image type of the image to be corrected. The recognition module 1003 recognizes the text information in the image to be corrected to obtain at least one text block, and then the matching module 1004 matches the target text block with the multiple preset anchor point information in the target preset anchor point set to obtain the target preset anchor point information that matches the target text block. The second determining module 1005 determines a first matrix of the image to be corrected based on the target preset anchor point information and the target text block. The calculation module 1006 calculates the inverse matrix of the first matrix to obtain a second matrix, and the transformation module 1007 performs perspective transformation on the image to be corrected based on the second matrix to obtain the target image.

[0161] Thus, by determining the corresponding set of preset anchor points based on the image type of the image to be corrected, the image correction method can be applied to various image types and improve recognition accuracy. By matching text blocks in the image to be corrected with pre-set anchor point information, the accuracy of determining the matrix transformation equation can be improved, thereby improving the accuracy of image correction. Furthermore, since this method identifies text information in the image to be corrected rather than object edges, it does not rely on edge detection technology and can identify images where object edges are occluded, thus reducing the limitations of traditional image correction methods.

[0162] As another embodiment of this application, in order to improve the accuracy of recognizing text information in the image to be corrected, the matching module 1004 described above can be specifically used for:

[0163] Based on the text characters in the target text block, match them with the regular expressions in multiple preset anchor information in the target preset anchor set to obtain the target preset anchor information that matches the target text block;

[0164] Accordingly, the second determining module 1005 described above can be specifically used for:

[0165] Based on the coordinates of the preset anchor points in the target preset anchor point information and the coordinates of the target text block, a first matrix of the image to be corrected is determined. The first matrix is ​​used to transform the coordinates of the preset anchor points in the preset anchor point set into the coordinates of the text blocks in the image to be corrected.

[0166] As another embodiment of this application, in order to reduce the error of transforming the image to be corrected through the first matrix, the image correction device 1000 may further include:

[0167] The third determination module 1008 is used to determine the third matrix based on multiple first matrices through linear regression.

[0168] The fourth determining module 1009 is used for

[0169] Accordingly, the aforementioned calculation module 1006 may include:

[0170] Replacement unit 10061 is used to replace the first matrix with the third matrix;

[0171] The calculation unit 10062 is used to calculate the inverse of the third matrix to obtain the second matrix.

[0172] As another embodiment of this application, in order to improve the efficiency of matching text blocks in a target image, the image correction device 1000 may further include:

[0173] The fifth determining module 1010 is used to respond to the selection operation of the target recognition region in the target image, recognize the text information corresponding to the target region in the target image, and obtain the first text recognition result. The multiple identifiable regions in the target image correspond one-to-one with the coordinates of multiple preset anchor points in the target preset anchor point set, and the target recognition region is any one of the multiple identifiable regions.

[0174] As another embodiment of this application, in order to improve the accuracy of recognizing text information in the target image, the fifth determining module 1010 may include:

[0175] The comparison unit 10101 is used to compare the first text recognition result with the text characters in at least one text block to obtain a comparison result, which is used to indicate whether there is a recognition error in the text characters in at least one text block;

[0176] The correction unit 10102 is used to correct the text characters in at least one text block according to the first text recognition result when the comparison result indicates that a text character in at least one text block has a recognition error.

[0177] In another embodiment of this application, to improve user-friendliness, the image correction device 1000 may further include:

[0178] Display module 1011 is used to display the target image.

[0179] Based on the image correction method and apparatus provided in the above embodiments, this application also provides an electronic device 1100, such as... Figure 11 As shown:

[0180] It includes a processor 1101, a memory 1102, and a computer program stored in the memory 1102 and executable on the processor 1101. When the computer program is executed by the processor 1101, it implements the various processes of the above-described image correction method embodiments and achieves the same technical effect.

[0181] Specifically, the processor 1101 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0182] Memory 1102 may include mass storage for data or instructions. For example, and not limitingly, memory 1102 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 1102 may include removable or non-removable (or fixed) media. Where appropriate, memory 1102 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 1102 is non-volatile solid-state memory.

[0183] In certain embodiments, the memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Thus, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this application.

[0184] The processor 1101 implements any of the image correction methods described in the above embodiments by reading and executing computer program instructions stored in the memory 1102.

[0185] In one example, the electronic device may also include a communication interface 1103 and a bus 1110. As an example, such as... Figure 11 As shown, the processor 1101, memory 1102, and communication interface 1103 are connected through bus 1110 and complete communication with each other.

[0186] The communication interface 1103 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.

[0187] Bus 1110 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 1110 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.

[0188] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the various processes of the above-described image correction method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0189] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.

[0190] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0191] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0192] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0193] The above are merely specific embodiments of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.

Claims

1. An image correction method characterized by, include: Obtain the image to be corrected; Based on the image type of the image to be corrected, a target preset anchor point set corresponding to the image type of the image to be corrected is determined from a pre-configured set of multiple preset anchor points. The target preset anchor point set includes multiple preset anchor point information, and the preset anchor point information includes preset anchor point coordinates. The image type of the image to be corrected and the target preset anchor point set are in one-to-one correspondence. The target preset anchor point set also includes pixels of a standard edge image, and the aspect ratio of the pixels is used as a position reference system for the preset anchor points. The text information in the image to be corrected is identified to obtain at least one text block, the text block including text characters and text block coordinates; The target text block is matched with multiple preset anchor information in the target preset anchor point set to obtain target preset anchor information that matches the target text block. The target text block is any one of the at least one text block, and the target preset anchor information is any one of the multiple preset anchor information. Based on the target preset anchor point information and the target text block, determine the first matrix of the image to be corrected; The first matrix is ​​used to transform the coordinates of the preset anchor points on the target preset anchor point information into the coordinates of the target text block; Based on multiple first matrices, the third matrix is ​​determined through linear regression. Replace the first matrix with the third matrix; Calculate the inverse of the third matrix to obtain the second matrix; Based on the second matrix, a perspective transformation is performed on the image to be corrected to obtain the target image.

2. The method of claim 1, wherein, The preset anchor information also includes regular expressions. The step of matching the target text block with multiple preset anchor information in the target preset anchor set to obtain target preset anchor information that matches the target text block includes: Based on the text characters in the target text block, the regular expressions in multiple preset anchor information in the target preset anchor set are matched to obtain the target preset anchor information that matches the target text block. The step of determining the first matrix of the image to be corrected based on the target preset anchor point information and the target text block includes: Based on the preset anchor point coordinates of the target preset anchor point information and the text block coordinates of the target text block, a first matrix of the image to be corrected is determined. The first matrix is ​​a matrix used to transform the target preset anchor point coordinates in the target preset anchor point set into the target text block coordinates in the image to be corrected.

3. The method according to any one of claims 1-2, characterized in that, After performing perspective transformation on the image to be corrected according to the second matrix to obtain the target image, the process further includes: In response to the selection operation of the target recognition region in the target image, the text information corresponding to the target region in the target image is recognized to obtain a first text recognition result. The multiple identifiable regions in the target image correspond one-to-one with the coordinates of multiple preset anchor points in the target preset anchor point set. The target recognition region is any one of the multiple identifiable regions.

4. The method of claim 3, wherein, The step of responding to the selection operation of a target recognition region in the target image, recognizing the text information corresponding to the target region in the target image, and obtaining a first text recognition result includes: The first text recognition result is compared with the text characters in the at least one text block to obtain a comparison result, which is used to indicate whether there is a recognition error in the text characters in the at least one text block; If the comparison result indicates that a character in the at least one text block is misrecognized, the character in the at least one text block is corrected based on the first text recognition result.

5. The method according to any of claims 1-2, characterized by, After performing perspective transformation on the image to be corrected according to the second matrix to obtain the target image, the process further includes: Display the target image.

6. An image correction apparatus characterized by comprising: include: The acquisition module is used to acquire the image to be corrected. The first determining module is configured to determine a target preset anchor point set corresponding to the image type of the image to be corrected from a pre-configured set of multiple preset anchor points, based on the image type of the image to be corrected. The target preset anchor point set includes multiple preset anchor point information, each of which includes preset anchor point coordinates and a regular expression. The image type of the image to be corrected corresponds one-to-one with the target preset anchor point set. The target preset anchor point set also includes pixels of a standard edge image, the aspect ratio of which is used as a positional reference for the preset anchor points. The recognition module is used to recognize the text information in the image to be corrected and obtain at least one text block, wherein the text block includes text characters and text block coordinates; The matching module is used to match the target text block with multiple preset anchor information in the target preset anchor set to obtain target preset anchor information that matches the target text block. The target text block is any one of the at least one text block, and the target preset anchor information is any one of the multiple preset anchor information. The second determining module is used to determine the first matrix of the image to be corrected based on the target preset anchor point information and the target text block; The first matrix is ​​used to transform the coordinates of the preset anchor points on the target preset anchor point information into the coordinates of the target text block; The third determination module is used to determine the third matrix based on multiple first matrices through linear regression. A replacement unit, used to replace the first matrix with the third matrix; The calculation module is used to calculate the inverse of the third matrix to obtain the second matrix; The transformation module is used to perform perspective transformation on the image to be corrected according to the second matrix to obtain the target image.

7. An electronic device, comprising: The device includes: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the image correction method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the image correction method as described in any one of claims 1-5.

9. A computer program product, characterised in that, The instructions in the computer program product, when executed by a processor of an electronic device, cause the electronic device to perform the image correction method of any one of claims 1-5.