A method for correcting the skewness of scanned images

By identifying straight line segments in the scanned image and calculating the tilt angle for rotation, combined with the intersection angle of the straight lines and the judgment of the inverted state, the complex and inefficient problem of scanning image correction in the prior art is solved, and a simple and efficient correction effect is achieved.

CN117749956BActive Publication Date: 2026-11-17NINGBO DELI KEBEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311777141.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-21
Publication Date
2026-11-17
Estimated Expiration
2043-12-21

AI Technical Summary

Technical Problem

Existing scanning image correction methods require a large number of deep learning samples and the correction process is complex and inefficient.

Method used

By identifying the straight line segments of the target to be corrected in the scanned image, calculating the tilt angle and rotating them, and combining the intersection angle judgment of the straight line segments with the judgment of the upside-down state, simple and efficient correction can be achieved.

Benefits of technology

It simplifies the correction process, improves correction efficiency and accuracy, and is suitable for correcting targets that can be placed arbitrarily.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117749956B_ABST
    Figure CN117749956B_ABST
Patent Text Reader

Abstract

This invention relates to a method for correcting skewed scanned images, comprising: preprocessing the scanned image to obtain a first image; identifying a first straight line segment of the target to be corrected in the first image, calculating the tilt angle of the first straight line segment, and rotating the target to be corrected using the tilt angle to obtain a second image; identifying a second straight line segment of the target to be corrected in the second image, calculating the tilt angle of the second straight line segment to obtain a second tilt angle; determining whether the second tilt angle of the target to be corrected is less than a preset angle; if so, keeping the second image unchanged; if not, rotating the target to be corrected in the second image using the second tilt angle to update the second image; when the target to be corrected in the second image is inverted, rotating the target to be corrected in the second image by 180° to obtain a corrected image. This method has a simple correction process, high correction efficiency and accuracy, and is easy for users to operate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method for correcting the distortion of scanned images. Background Technology

[0002] Image scanning refers to scanning documents or paper documents using a printer to obtain a scanned image of the document or paper document. However, during the scanning process, it is often encountered that the document or paper document is not placed correctly, resulting in a certain degree of tilt in the generated document image, which affects the visual quality of the image.

[0003] To address the aforementioned technical problems, a Chinese invention patent with application number CN202111508488.5 (publication number CN114358137A) discloses an automatic image correction method for scanned archival documents based on deep learning. This method obtains principal component region images through brightness correction and principal component detection of the scanned document, reducing the impact of black-and-white edges and brightness variations on subsequent correction estimation. Then, a two-stage correction strategy is designed. The first stage uses deep learning for correction in four directions (major direction correction); the second stage performs minor correction in two ways: one based on deep learning in 91 directions, and the other based on pixel projection. The minor correction is completed by comprehensively judging the results of the two minor corrections, yielding the corrected result. Although the above correction method can achieve automatic correction of scanned images, it requires a large number of deep learning samples, and the correction process is complex and slow. Therefore, further improvements to the existing technology are needed. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a scanning image correction method that is simple in the correction process and has high correction efficiency, in contrast to the above-mentioned prior art.

[0005] The technical solution adopted by the present invention to solve the above-mentioned technical problems is: a scanning image correction method, characterized by comprising the following steps:

[0006] Step 1: Preprocess the scanned image to obtain a first image, which contains the target to be corrected;

[0007] Step 2: Locate the first straight line segment of the target to be corrected in the first image, calculate the tilt angle of the first straight line segment, and obtain the first tilt angle of the target to be corrected.

[0008] Step 3: Rotate the target to be corrected in the first image according to the calculated first tilt angle to obtain the image of the target to be corrected after the first rotation, and record this image as the second image;

[0009] Step 4: Following the same method as in Step 2, find the second straight line segment of the target to be corrected in the second image. This second straight line segment intersects with the first straight line segment. Calculate the tilt angle of the second straight line segment to obtain the second tilt angle of the target to be corrected.

[0010] Step 5: Determine whether the second tilt angle of the target to be corrected is less than the preset angle. If yes, proceed to step 6; otherwise, use the second tilt angle to rotate the target to be corrected in the second image, update the second image, and proceed to step 6.

[0011] Step 6: Determine whether the target to be corrected in the second image is upside down. If so, rotate the target to be corrected in the second image by 180°, update the second image, and use the second image as the corrected image; otherwise, use the second image as the corrected image.

[0012] To correct the vertical state of the target, a step a is provided between steps 5 and 6, or step a is provided after step 6.

[0013] Step a: Determine whether the target to be corrected in the second image is in a vertical state. If so, rotate the target to be corrected in the second image by 90° and update the second image; otherwise, keep the target to be corrected in the second image as is.

[0014] Preferably, the preprocessing in step 1 includes at least one of cropping and filtering.

[0015] Since ID cards, bank cards, and other documents are frequently scanned in the existing technology, in order to correct the skewness of scanned images of these documents, it is preferable that the target to be corrected in step 1 is square.

[0016] Furthermore, the specific steps for finding the first straight line segment of the target to be corrected in step 2 are as follows:

[0017] Identify the positions of the four vertices of the target to be corrected in the first image. The vertex at the top right corner of the target to be corrected is denoted as A, the vertex at the bottom right corner as B, the vertex at the top left corner as C, and the vertex at the bottom left corner as D. The first line segment is at least one of the lines AC, BD, AB, or CD.

[0018] Preferably, the first straight line segment is straight line AC and straight line BD, and the first tilt angle of the target to be corrected in step 2 is calculated based on straight lines AC and BD.

[0019] Furthermore, the second straight line segment is straight line AB and straight line CD, and the second tilt angle of the target to be corrected in step 4 is calculated based on straight line AB and straight line CD.

[0020] In the above scheme, the specific process of determining whether the target to be corrected in the second image is in a vertical state in step a is as follows:

[0021] Determine whether the length of line AB or line CD is equal to the preset width value. If yes, determine that the target to be corrected in the second image is not in a vertical state; otherwise, determine that the target to be corrected in the second image is in a vertical state.

[0022] or,

[0023] Determine whether the length of line AB is less than the length of line AC. If so, determine that the target to be corrected in the second image is not in a vertical state; otherwise, determine that the target to be corrected in the second image is in a vertical state.

[0024] To determine whether the target to be corrected is inverted, the specific process in step 6 of judging whether the target in the second image is inverted is as follows:

[0025] The number of valid black dots in the target area to be corrected is used to determine whether the target is currently upside down.

[0026] Preferably, the target to be corrected is at least one of an ID card, student ID, bank card, meal card, or business card.

[0027] Compared with existing technologies, the advantages of this invention are as follows: On the one hand, by finding the first straight line segment of the target to be corrected in the image and calculating the first tilt angle based on the first straight line segment, the target to be corrected in the image is rotated according to the tilt angle to obtain an image after one correction. This correction process is simple and efficient. On the other hand, by finding the second straight line segment in the image after one correction and calculating the second tilt angle based on the second straight line segment, and by comparing the second tilt angle with a preset angle, the image after one correction is judged again to improve the accuracy of correction. Finally, by judging the upside-down state of the target to be corrected, the complete correction of the target to be corrected is finally achieved. This method can correct targets that are placed arbitrarily and is easy for users to operate. Attached Figure Description

[0028] Figure 1 This is a flowchart of the scanning image correction method in an embodiment of the present invention;

[0029] Figure 2 The image shown is the ID card image to be corrected in this embodiment of the invention.

[0030] Figure 3 To Figure 2 The image obtained after correcting the ID card in the image. Detailed Implementation

[0031] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments.

[0032] like Figure 1 As shown, the scanned image correction method in this embodiment includes the following steps:

[0033] Step 1: Preprocess the scanned image to obtain a first image, which contains the target to be corrected;

[0034] The preprocessing includes at least one of cropping and filtering; in this embodiment, the preprocessing is cropping the scanned image.

[0035] Step 2: Locate the first straight line segment of the target to be corrected in the first image, calculate the tilt angle of the first straight line segment, and obtain the first tilt angle of the target to be corrected.

[0036] Step 3: Rotate the target to be corrected in the first image according to the calculated first tilt angle to obtain the image of the target to be corrected after the first rotation, and record this image as the second image;

[0037] Step 4: Following the same method as in Step 2, find the second straight line segment of the target to be corrected in the second image. This second straight line segment intersects with the first straight line segment. Calculate the tilt angle of the second straight line segment to obtain the second tilt angle of the target to be corrected.

[0038] Step 5: Determine whether the second tilt angle of the target to be corrected is less than the preset angle. If yes, proceed to step 6; otherwise, use the second tilt angle to rotate the target to be corrected in the second image, update the second image, and proceed to step 6.

[0039] In this embodiment, the preset angle ranges from 0° to 5°; the calculation of the second tilt angle is to prevent errors in the calculation of the tilt angle of the first straight line segment during the first rotation, and to further improve the accuracy of correction.

[0040] Step 6: Determine whether the target to be corrected in the second image is upside down. If so, rotate the target to be corrected in the second image by 180°, update the second image, and use the second image as the corrected image; otherwise, use the second image as the corrected image.

[0041] There is a step a between steps 5 and 6 above, or there is a step a after step 6;

[0042] Step a: Determine whether the target to be corrected in the second image is in a vertical state. If so, rotate the target to be corrected in the second image by 90° and update the second image; otherwise, keep the target to be corrected in the second image as is.

[0043] Since the certificates and paper documents in the existing technology are basically square, for example, the target to be corrected is an ID card, student ID card, bank card, meal card, business card or various kinds of paper, which are all square. Therefore, the target to be corrected in this embodiment is square.

[0044] To facilitate understanding of the above correction method, this embodiment uses an ID card as an example to illustrate the process. The specific steps for finding the first straight line segment of the target to be corrected in this embodiment are as follows:

[0045] Identify the positions of the four vertices of the target to be corrected in the first image, such as... Figure 2 As shown, the vertex at the top right of the target to be corrected is denoted as A, the vertex at the bottom right as B, the vertex at the top left as C, and the vertex at the bottom left as D. The first straight line segment is at least one of the lines AC, BD, AB, or CD. In this embodiment, the first straight line segment is lines AC and BD. The first tilt angle of the target to be corrected is calculated based on lines AC and BD, and this first tilt angle is the average slope of lines AC and BD. The second straight line segment is lines AB and CD. In step 4, the second tilt angle of the target to be corrected is calculated based on lines AB and CD, and this second tilt angle is the average slope of lines AB and CD. The corrected ID card is shown below. Figure 3 As shown.

[0046] Since the width of an ID card is less than its length, in order to identify whether the ID card is not in a horizontal state, the specific process for determining whether the target to be corrected in the second image is in a vertical state in this embodiment is as follows: determine whether the length of line AB or line CD is equal to a preset width value (the preset width value is the width of the ID card, which is a fixed value). If yes, then the target to be corrected in the second image is determined not to be in a vertical state; if no, then the target to be corrected in the second image is determined to be in a vertical state; or, determine whether the length of line AB is less than the length of line AC. If yes, then the target to be corrected in the second image is determined not to be in a vertical state; if no, then the target to be corrected in the second image is determined to be in a vertical state.

[0047] The specific process for determining whether the target to be corrected in the second image is inverted is as follows: The number of valid black dots in the designated area of ​​the target to be corrected determines whether the target is inverted. Before determining whether the ID card is inverted, the front and back of the ID card are identified. When the ID card is identified as being on the front, the designated area for the target is the area where the "Resident ID Card" text is located on the front. If the front of the ID card is not inverted, the area where the "Resident ID Card" text is located is horizontally in the middle of the ID card. When the ID card is identified as being on the back, the designated area for the target is the face area on the back. If the back of the ID card is not inverted, the face area is on the right side of the ID card. Specifically, the identification of the area where the "Resident ID Card" text is located and the face area can be done by pixel traversal, determining whether the target is inverted by judging the number of valid black dots in either the "Resident ID Card" text area or the face area.

[0048] This embodiment also relates to a computer-readable storage medium having a computer program stored thereon, which is executed by a processor, such as a scanned image correction method.

[0049] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for correcting the skewness of a scanned image, characterized in that... Includes the following steps: Step 1: Preprocess the scanned image to obtain a first image, which contains the target to be corrected; Step 2: Locate the first straight line segment of the target to be corrected in the first image, calculate the tilt angle of the first straight line segment, and obtain the first tilt angle of the target to be corrected. Step 3: Rotate the target to be corrected in the first image according to the calculated first tilt angle to obtain the image of the target to be corrected after the first rotation, and record this image as the second image; Step 4: Following the same method as in Step 2, find the second straight line segment of the target to be corrected in the second image. This second straight line segment intersects with the first straight line segment. Calculate the tilt angle of the second straight line segment to obtain the second tilt angle of the target to be corrected. Step 5: Determine whether the second tilt angle of the target to be corrected is less than the preset angle. If yes, proceed to step 6; otherwise, use the second tilt angle to rotate the target to be corrected in the second image, update the second image, and proceed to step 6. Step 6: Determine whether the target to be corrected in the second image is upside down. If so, rotate the target to be corrected in the second image by 180°, update the second image, and use the second image as the corrected image; otherwise, use the second image as the corrected image.

2. The scanning image correction method according to claim 1, characterized in that: There is a step a between step 5 and step 6, or there is a step a after step 6; Step a: Determine whether the target to be corrected in the second image is in a vertical state. If so, rotate the target to be corrected in the second image by 90° and update the second image; otherwise, keep the target to be corrected in the second image as is.

3. The scanning image correction method according to claim 2, characterized in that: The preprocessing in step 1 includes at least one of cropping and filtering.

4. The scanning image correction method according to claim 2, characterized in that: In step 1, the target to be corrected is square.

5. The scanning image correction method according to claim 4, characterized in that: The specific steps for finding the first straight line segment of the target to be corrected in step 2 are as follows: Identify the positions of the four vertices of the target to be corrected in the first image. The vertex at the top right corner of the target to be corrected is denoted as A, the vertex at the bottom right corner as B, the vertex at the top left corner as C, and the vertex at the bottom left corner as D. The first line segment is at least one of the lines AC, BD, AB, or CD.

6. The scanning image correction method according to claim 5, characterized in that: The first straight line segment is straight line AC and straight line BD, and the first tilt angle of the target to be corrected in step 2 is calculated based on straight lines AC and BD.

7. The scanning image correction method according to claim 6, characterized in that: The second straight line segment is line AB and line CD. The second tilt angle of the target to be corrected in step 4 is calculated based on line AB and line CD.

8. The scanning image correction method according to claim 7, characterized in that: The specific process for determining whether the target to be corrected in the second image is in a vertical state in step a is as follows: Determine whether the length of line AB or line CD is equal to the preset width value. If yes, determine that the target to be corrected in the second image is not in a vertical state; otherwise, determine that the target to be corrected in the second image is in a vertical state. or, Determine whether the length of line AB is less than the length of line AC. If so, determine that the target to be corrected in the second image is not in a vertical state; otherwise, determine that the target to be corrected in the second image is in a vertical state.

9. The scanning image correction method according to claim 8, characterized in that: The specific process for determining whether the target to be corrected in the second image is in an upside-down state in step 6 is as follows: The number of valid black dots in the target area to be corrected is used to determine whether the target is currently upside down.

10. The scanning image correction method according to any one of claims 4 to 9, characterized in that: The target to be corrected is at least one of the following: ID card, student ID, bank card, meal card, or business card.

Citation Information

Patent Citations

  • File scanning copy image automatic correction method based on deep learning

    CN114358137A

  • Scanning deviation correction method and device, storage medium and computer equipment

    CN112215756A

  • Method for calibrating printing deviation of spray head of ink-jet printer

    CN116373459A