Image Skew Correction Method, Device, Storage Medium, and Computer Equipment
By converting the original image into a grayscale image and rotating the method of calculating the variance value, the problem of insufficient accuracy and robustness of image tilt correction in the prior art is solved, and a higher precision image correction is achieved.
Patent Information
- Application Number
- CN202210239043.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-11
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-03-11
AI Technical Summary
The accuracy and robustness of the image tilt correction method in the prior art are insufficient, and especially in the OCR recognition process, it is susceptible to improper threshold value or parameter selection.
By converting the original image into a grayscale image, determining the center point and rotating different angles at the same direction to obtain multiple rotating images, calculating the variance of the projected integral value, selecting the rotation image with the largest variance as the correction reference, and performing image tilt correction.
Improve the accuracy and robustness of image tilt correction, avoid errors caused by poor threshold value or parameter selection, and enhance the accuracy and reliability of correction.
Smart Images

Figure CN114495105B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and in particular, to a method, device, storage medium, and computer device for image skew correction. Background Art
[0002] During the process of using the OCR (Optical Character Recognition) algorithm to recognize characters in an image, detecting and correcting the skew angle of the image is an important preprocessing task, which is directly related to the accuracy of OCR recognition. Existing technologies generally use methods such as the minimum circumscribed rectangle method of the edge contour, the straight line fitting method, the Hough transform method, and the Fourier transform to the frequency domain to detect the skew angle of the image, and then perform an affine transformation based on the skew angle to achieve angle correction.
[0003] However, the correction methods of existing technologies may involve image processing operations such as edge extraction, filtering, morphological operations, and straight line detection, which highly depend on specific scene thresholds (and parameters). Once the thresholds or parameters are selected improperly, the effect is often greatly reduced. Therefore, the accuracy and robustness of the correction methods cannot meet the requirements of industrial applications. Summary of the Invention
[0004] Embodiments of this application provide a method, device, storage medium, and computer device for image skew correction, which can solve the problems of poor accuracy and low robustness in the existing image skew correction methods. The technical solutions are as follows:
[0005] In a first aspect, embodiments of this application provide a method for image skew correction, the method includes:
[0006] Obtain an original image;
[0007] Convert the original image into a grayscale image;
[0008] Determine the center point of the grayscale image;
[0009] Rotate the grayscale image in the same direction by different angles with the center point as the reference point to obtain n rotated images; where n is an integer greater than 1;
[0010] Calculate the variances of m projection integral values corresponding to each rotated image to obtain n variance values; where m is an integer greater than 1;
[0011] Determine the maximum value among the n variance values, and determine the rotated image corresponding to the maximum value;
[0012] Perform skew correction on the original image according to the rotation angle of the determined rotated image.
[0013] Second aspect, embodiments of the present application provide an apparatus for skew correction of an image. The apparatus includes:
[0014] An acquisition unit, configured to acquire an original image;
[0015] A conversion unit, configured to convert the original image into a grayscale image;
[0016] A determination unit, configured to determine the center point of the grayscale image;
[0017] A rotation unit, configured to rotate the grayscale image in the same direction by different angles with the center point as a reference point to obtain n rotated images; where n is an integer greater than 1;
[0018] A calculation unit, configured to calculate the variances of m projection integral values corresponding to each rotated image to obtain n variance values; where m is an integer greater than 1;
[0019] The determination unit is further configured to determine the maximum value among the n variance values, and determine the rotated image corresponding to the maximum value;
[0020] A correction unit, configured to perform skew correction on the original image according to the rotation angle of the determined rotated image.
[0021] Third aspect, embodiments of the present application provide a computer storage medium. The computer storage medium stores multiple instructions, and the instructions are suitable for being loaded and executed by a processor to perform the above method steps.
[0022] Fourth aspect, embodiments of the present application provide a computer device, which may include: a processor and a memory; where the memory stores a computer program, and the computer program is suitable for being loaded and executed by the processor to perform the above method steps.
[0023] The beneficial effects brought by the technical solutions provided by some embodiments of the present application at least include:
[0024] The grayscale image obtained by converting the original image is rotated multiple times in the same direction based on the center point to obtain multiple rotated images, and then the variance values of each rotated image are calculated according to the projection integral values of each rotated image. Then, the original image is skew-corrected according to the rotation angle of the rotated image with the largest variance value. It can be seen that the skew correction process of the present application does not involve steps such as edge extraction, filtering, morphological operations, and line detection that rely on threshold or parameter settings, thereby avoiding various errors caused by poor selection of thresholds or parameters. Therefore, the skew correction method of the present application can improve the accuracy and robustness of correction compared with the prior art. Description of the Drawings
[0025] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0026] Figure 1 is a schematic flowchart of the image skew correction method provided by the embodiments of the present application;
[0027] Figure 2 is a schematic diagram of the principle for calculating the center point of the rotated image provided by the embodiments of the present application;
[0028] Figure 3 is a schematic diagram of the principle for generating n rotated images provided by the embodiments of the present application;
[0029] Figure 4 is a schematic diagram of the principle for obtaining the projection integral value by row summation and column summation provided by the embodiments of the present application;
[0030] Figure 5 is a schematic structural diagram of an image skew correction device provided by the present application;
[0031] Figure 6 is a schematic structural diagram of a computer device provided by the present application. Detailed implementation manners
[0032] To make the objectives, technical solutions and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the drawings.
[0033] It should be noted that the image skew correction method provided by the present application is generally executed by a computer device. Correspondingly, the image skew correction device is generally set in the computer device.
[0034] Various communication client applications can be installed on the computer device of the present application, such as: video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0035] The computer device can be hardware or software. When the computer device is hardware, it can be various computer devices with a display screen, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, etc. When the computer device is software, it can be installed in the above-listed computer devices. It can be implemented as multiple software or software modules (for example, used to provide distributed services), or can be implemented as a single software or software module, which is not specifically limited herein.
[0036] When the computer device is hardware, a display device and a camera can also be installed thereon. The display device can be various devices capable of implementing a display function, and the camera is used to collect a video stream. For example, the display device can be a cathode ray tube display (CR for short), a light-emitting diode display (LED for short), an electronic ink screen, a liquid crystal display (LCD for short), a plasma display panel (PDP for short), etc. Users can use the display device on the computer device to view information such as text, pictures, and videos displayed.
[0037] Next, in combination with the attached Figure 1 , a method for correcting the inclination of an image provided by an embodiment of the present application will be introduced in detail. Among them, the image inclination correction device in the embodiment of the present application can be Figure 1 the computer device shown.
[0038] Please refer to Figure 1 , which is a schematic flowchart of a method for correcting the inclination of an image provided by an embodiment of the present application. As Figure 2 shown, the method of the embodiment of the present application may include the following steps:
[0039] S101. Obtain an original image.
[0040] Among them, the inclination correction device can obtain a color original image through an image scanning unit, or import the original image from other devices. The original image of the present application is used for subsequent OCR to obtain character text. The original image includes blank rows or columns, and the blank rows or columns are the areas between character rows or character columns. The original image of the present application can be an image containing characters generated by scanning an electronic document, a card, a certificate, a bill, or a form.
[0041] S102. Convert the original image into a grayscale image.
[0042] Among them, the obtained original image is a color image, the color image is a three-channel image, and the grayscale image is a one-channel image. The method for converting the color original image into a grayscale image includes but is not limited to the following methods:
[0043] Method 1. Convert the pixel values of each pixel of the original image into grayscale values according to the following formula:
[0044] Gray = (R × 19595 + G × 38469 + B × 7472) >> 16;
[0045] Where Gray represents the grayscale value, R represents the red pixel value, B represents the blue pixel value, G represents the green pixel value, and >> represents the right shift operator.
[0046] Method 2: Convert the original image to a grayscale image using the formula Gray = R * 0.299 + G * 0.587 + B * 0.114. Here, R is the red pixel value of the pixel in the original image, G represents the red pixel value of the pixel in the original image, B represents the blue pixel value of the pixel in the original image, and Gray represents the grayscale value obtained after conversion.
[0047] Method 3: Perform the conversion using Gray = (R + G + B) / 3. Here, G represents the red pixel value of the pixel in the original image, B represents the blue pixel value of the pixel in the original image, and Gray represents the grayscale value obtained after conversion.
[0048] S103. Determine the center point of the grayscale image.
[0049] Generally, the shape of the grayscale image is a rectangle, and the center point of the grayscale image is the geometric center, that is, the intersection point of the two diagonals of the rectangle.
[0050] For example, as shown in Figure 2 If the length of the grayscale image is a and the width is b, establish a rectangular coordinate system based on the grayscale image, and use the upper left vertex of the grayscale image as the origin (0, 0). The coordinates of the other three vertices of the grayscale image are as shown in Figure 2 Then the coordinates of the center point C are (a / 2, b / 2).
[0051] S104. Use the center point as a reference point to rotate the grayscale image in the same direction by different angles to obtain n rotated images.
[0052] The inclination correction device rotates the grayscale image in the same direction n - 1 times with the center point as the reference point. Each rotation angle is different, and n rotated images are obtained. The n rotated images include the grayscale image in the original position. The rotation direction can be clockwise or counterclockwise. The number of rotations and the resolution of the rotation angle in this application can be determined according to actual needs. The more rotations and the higher the resolution, the higher the correction accuracy.
[0053] For example, as shown in the schematic diagram of Figure 3 Rotate the grayscale image counterclockwise to obtain n rotated images. The rotation angles of the n rotated images are respectively 、 、…、 . Optionally, the maximum rotation angle is 180 degrees, that is, = 180 degrees, and the difference between adjacent two rotation angles is 1 degree, that is, Degree, that is, the resolution is 1 degree, which can not only ensure the accuracy of calibration but also reduce the amount of calculation.
[0054] S105. Calculate the variances of the m projection integral values corresponding to each rotated image to obtain n variance values.
[0055] Among them, the variance represents the degree of dispersion among multiple data. In addition to the variance of this application, the range, interquartile range, standard deviation or coefficient of variation can also be used to represent the degree of dispersion. Assume that the resolution of the rotated image is a×b, that is, the rotated image consists of a pixel rows and b pixel columns. First, calculate the m projection integral values corresponding to the rotated image. The projection integral values can be row projection integral values and column projection integral values.
[0056] When it is a column projection integral value, m≤b and m is an integer. Select m pixel columns from the b pixel columns included in the rotated image, and perform pixel summation on the pixels included in each pixel column to obtain the column projection integral value.
[0057] For example: a = 50, b = 100, m = b = 100. The rotated image consists of 50 pixel columns and 100 pixel columns. Each of the 100 pixel columns contains 50 pixels, and each pixel corresponds to a gray value. Sum the 50 gray values corresponding to each pixel column to obtain the column projection integral value of this column, and finally obtain 100 column projection integral values.
[0058] When it is a row projection integral value, select m pixel rows from the a pixel rows included in the rotated image, m≤a and m is an integer, and perform pixel value summation on the pixels included in each pixel row to obtain the row projection integral value. For the m projection integral values corresponding to each rotated image, calculate the variance to obtain n variance values. The variance value represents the variance of the m projection integral values, and each rotated image corresponds to a variance value.
[0059] For example: a = 50, b = 100, m = a = 50. The rotated image consists of 50 pixel columns and 100 pixel columns. Each of the 50 pixel rows contains 100 pixels, and each pixel corresponds to a gray value. Sum the 100 gray values corresponding to each pixel row to obtain the row projection integral value of this row, and finally obtain 50 row projection integral values.
[0060] See Figure 4 the schematic diagrams of the rotated image obtained by summing by row and by column shown in Figure 4 In the rotated image of , each square represents a pixel, and each pixel corresponds to a gray value.
[0061] Optionally, the grayscale image is rotated in parallel in the same direction to obtain n rotated images, and the variance values of each rotated image are calculated in parallel. For example, n CPUs or GPUs are used to run simultaneously, and each CPU or GPU executes a calculation task of generating a rotated image and calculating the variance value, which can improve the calculation efficiency and reduce the calculation time.
[0062] S106. Determine the maximum value among the n variance values, and determine the rotated image corresponding to the maximum value.
[0063] Among them, the n variance values corresponding to the n rotated images are arranged in ascending or descending order, then the maximum value among the n variance values is determined, and then the rotated image corresponding to the maximum value is determined among the n rotated images.
[0064] S107. Perform skew correction on the original image according to the rotation angle of the determined rotated image.
[0065] In a possible embodiment, when the projection integral value is the column projection integral value, calculate the difference between the rotation angle of the determined rotated image and 90 degrees;
[0066] If the difference is greater than 0, rotate the original image counterclockwise based on the difference;
[0067] If the difference is less than 0, rotate the original image clockwise based on the difference.
[0068] In another possible embodiment, when the projection integral value is the row projection integral value, if A ≤ 90 degrees, rotate the original image counterclockwise based on A; where A is the rotation angle of the determined rotated image;
[0069] If A > 90 degrees, calculate the difference between A and 180 degrees;
[0070] If the difference is greater than 0, rotate the original image counterclockwise based on the difference;
[0071] If the difference is less than 0, rotate the original image clockwise based on the difference.
[0072] When correcting the tilt angle of an image in an embodiment of the present application, a grayscale image obtained by converting an original image is rotated multiple times in the same direction based on a center point to obtain multiple rotated images. Then, variance values of the respective rotated images are calculated according to the projection integral values of the respective rotated images. Then, the original image is corrected for tilt according to the rotation angle of the rotated image with the largest variance value. It can be seen from this that the tilt correction process of the present application does not involve steps such as edge extraction, filtering, morphological operations, and line detection that rely on threshold or parameter settings, thereby avoiding various errors caused by poor selection of thresholds or parameters. Therefore, the tilt correction method of the present application can improve the accuracy and robustness of correction compared with the prior art.
[0073] The following is an embodiment of the apparatus of the present application, which can be used to execute the method embodiment of the present application. For details not disclosed in the embodiment of the apparatus of the present application, please refer to the method embodiment of the present application.
[0074] Please refer to Figure 5 , which shows a schematic structural diagram of an image tilt correction apparatus provided by an exemplary embodiment of the present application, hereinafter referred to as apparatus 5. This apparatus 5 can be implemented in whole or in part as a tilt correction apparatus through software, hardware, or a combination of both. Apparatus 5 includes: an acquisition unit 501, a conversion unit 502, a determination unit 503, a rotation unit 504, a calculation unit 505, and a correction unit 506.
[0075] The acquisition unit 501 is configured to acquire an original image;
[0076] The conversion unit 502 is configured to convert the original image into a grayscale image;
[0077] The determination unit 503 is configured to determine the center point of the grayscale image;
[0078] The rotation unit 504 is configured to rotate the grayscale image in the same direction by different angles with the center point as a reference point to obtain n rotated images; where n is an integer greater than 1;
[0079] The calculation unit 505 is configured to calculate the variance of m projection integral values corresponding to each rotated image to obtain n variance values; where m is an integer greater than 1;
[0080] The determination unit 503 is further configured to determine the maximum value among the n variance values and determine the rotated image corresponding to the maximum value;
[0081] The correction unit 506 is configured to correct the tilt of the original image according to the rotation angle of the determined rotated image.
[0082] In one or more possible embodiments, calculating the variance of m projection integral values corresponding to each rotated image to obtain n variance values includes:
[0083] Sum the grayscale values of each pixel included in the rotated image column by column to obtain m projection integral values;
[0084] Among them, the tilt correction of the original image according to the determined rotation angle of the rotated image includes:
[0085] Calculate the difference between the determined rotation angle of the rotated image and 90 degrees;
[0086] If the difference is greater than 0, rotate the original image counterclockwise based on the difference;
[0087] If the difference is less than 0, rotate the original image clockwise based on the difference.
[0088] In one or more possible embodiments, calculating the variances of the m projection integral values corresponding to each rotated image to obtain n variance values includes:
[0089] Sum the grayscale values of each pixel included in the rotated image row by row to obtain m projection integral values;
[0090] Among them, the tilt correction of the original image according to the determined rotation angle of the rotated image includes:
[0091] If A ≤ 90 degrees, rotate the original image counterclockwise based on A; where A is the determined rotation angle of the rotated image;
[0092] If A > 90 degrees, calculate the difference between A and 180 degrees;
[0093] If the difference is greater than 0, rotate the original image counterclockwise based on the difference;
[0094] If the difference is less than 0, rotate the original image clockwise based on the difference.
[0095] In one or more possible embodiments, the rotation direction is counterclockwise, the difference in the rotation angle between two adjacent rotated images is 1 degree, and the maximum rotation angle is 180 degrees.
[0096] In one or more possible embodiments, converting the original image into a grayscale image includes:
[0097] Average the red pixel value, blue pixel value, and green pixel value of each pixel in the original image to obtain the grayscale value of the pixel.
[0098] In one or more possible embodiments, the grayscale image is rotated in parallel in the same direction to obtain n rotated images, and the variance values of the respective rotated images are calculated in parallel.
[0099] In one or more possible embodiments, the original image is an image generated from a scanned electronic document, card, certificate, bill, or form.
[0100] It should be noted that when the device 5 provided in the above embodiment executes the image skew correction method, only the above division of each functional module is used for illustration. In practical applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above functions. In addition, the image skew correction device provided in the above embodiment and the image skew correction method embodiment belong to the same concept. The implementation process is detailed in the method embodiment and will not be repeated here.
[0101] The serial numbers of the embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.
[0102] The embodiments of the present application also provide a computer storage medium. The computer storage medium may store multiple instructions, and the instructions are suitable for being loaded and executed by a processor to perform the method steps of the embodiments as described above Figure 1 The specific execution process can refer to Figure 1 the specific description of the embodiments shown, and will not be repeated here.
[0103] The present application also provides a computer program product. The computer program product stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the image skew correction method as described in each of the above embodiments.
[0104] Please refer to Figure 6 which is a schematic structural diagram of a skew correction device provided by an embodiment of the present application. As Figure 6 shown, the skew correction device 600 may include: at least one processor 601, at least one network interface 604, a user interface 603, a memory 605, and at least one communication bus 602.
[0105] Among them, the communication bus 602 is used to realize the connection and communication between these components.
[0106] Among them, the user interface 603 may include a touch screen and a camera.
[0107] Among them, the network interface 604 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0108] Among them, the processor 601 may include one or more processing cores. The processor 601 connects various parts within the entire tilt correction device 600 through various interfaces and lines, and executes various functions of the tilt correction device 600 and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 605, and by calling the data stored in the memory 605. Optionally, the processor 601 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 601 may integrate a combination of one or several of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 601 and may be implemented separately by a single chip.
[0109] Among them, the memory 605 may include random access memory (RAM) and may also include read-only memory. Optionally, the memory 605 includes a non-transitory computer-readable storage medium. The memory 605 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 605 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store the data involved in the above-mentioned various method embodiments. Optionally, the memory 605 may also be at least one storage device located far from the aforementioned processor 601. As Figure 6 shown, the memory 605, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and application programs.
[0110] In Figure 6In the tilt correction device 600 shown, the user interface 603 is mainly used to provide an interface for the user to input data and obtain the data input by the user; the processor 601 can be used to call the application program stored in the memory 605 and specifically execute as Figure 2 shown in the method, and the specific process can be referred to Figure 2 shown, which will not be elaborated here.
[0111] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory or a random access memory, etc.
[0112] The above-disclosed are only the preferred embodiments of the present application. Of course, the scope of the rights of the present application cannot be limited thereby. Therefore, equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.
Claims
1. An image skew correction method, characterized in that, including: Obtain the original image; Convert the pixel values of each pixel of the original image into grayscale values according to the following formula: Gray = (R × 19595 + G × 38469 + B × 7472) >> 16; where Gray represents the grayscale value, R represents the red pixel value, B represents the blue pixel value, G represents the green pixel value, and >> represents the right shift operator; Determine the center point of the grayscale image; Using the center point as a reference point, rotate the grayscale image in the same direction by different angles to obtain n rotated images; where n is an integer greater than 1; Calculate the variances of the m projection integral values corresponding to each rotated image to obtain n variance values; where m is an integer greater than 1, the grayscale image is rotated in the same direction to obtain n rotated images in parallel, and the variance values of each rotated image are calculated in parallel; calculating the m projection integral values corresponding to each rotated image includes: the resolution of the rotated image is a × b, that is, the rotated image consists of a pixel rows and b pixel columns; when the projection integral value is the column projection integral value, m ≤ b and m is an integer, select m pixel columns from the b pixel columns included in the rotated image, and sum the pixels included in each pixel column to obtain the column projection integral value; When the projection integral value is the row projection integral value, select m pixel rows from the a pixel rows included in the rotated image, m ≤ a and m is an integer, and sum the pixel values of the pixels included in each pixel row to obtain the row projection integral value; Determine the maximum value among the n variance values, and determine the rotated image corresponding to the maximum value; Perform skew correction on the original image according to the rotation angle of the determined rotated image.
2. The method according to claim 1, wherein The performing skew correction on the original image according to the rotation angle of the determined rotated image includes: Calculate the difference between the rotation angle of the determined rotated image and 90 degrees; If the difference is greater than 0, rotate the original image counterclockwise based on the difference; If the difference is less than 0, rotate the original image clockwise based on the difference.
3. The method according to claim 1, the calculating the variances of the m projection integral values corresponding to each rotated image to obtain n variance values includes: Sum the grayscale values of each pixel included in the rotated image row by row to obtain m projection integral values; Wherein, the performing skew correction on the original image according to the rotation angle of the determined rotated image includes: If A ≤ 90 degrees, rotate the original image counterclockwise based on A; where A is the rotation angle of the determined rotated image; If A > 90 degrees, calculate the difference between A and 180 degrees; If the difference is greater than 0, rotate the original image counterclockwise based on the difference; If the difference is less than 0, rotate the original image clockwise based on the difference.
4. The method according to claim 1 or 2 or 3, characterized in that, The rotation direction is counterclockwise, the difference between the rotation angles of two adjacent rotated images is 1 degree, and the maximum rotation angle is 180 degrees.
5. The method according to claim 1, wherein The original image is an image generated from a scanned electronic document, card, certificate, bill, or form.
6. An image skew correction device, characterized in that, including: An obtaining unit for obtaining the original image; A conversion unit for converting the pixel values of each pixel of the original image into grayscale values according to the following formula: Gray = (R × 19595 + G × 38469 + B × 7472) >> 16; where Gray represents the grayscale value, R represents the red pixel value, B represents the blue pixel value, G represents the green pixel value, and >> represents the right shift operator; A determination unit for determining the center point of the grayscale image; A rotation unit for rotating the grayscale image in the same direction by different angles with the center point as the reference point to obtain n rotated images; where n is an integer greater than 1; A calculation unit for calculating the variances of m projection integral values corresponding to each rotated image to obtain n variance values; where m is an integer greater than 1, the grayscale image is rotated in the same direction to obtain n rotated images in parallel, and the variances of each rotated image are calculated in parallel; the resolution of the rotated image is a × b, that is, the rotated image is composed of a pixel rows and b pixel columns; when the projection integral value is the column projection integral value, m ≤ b and m is an integer, m pixel columns are selected from the b pixel columns included in the rotated image, and the pixels included in each pixel column are summed to obtain the column projection integral value; When the projection integral value is the row projection integral value, m pixel rows are selected from the a pixel rows included in the rotated image, m ≤ a and m is an integer, and the pixel values of the pixels included in each pixel row are summed to obtain the row projection integral value; The determination unit is further configured to determine the maximum value among the n variance values and determine the rotated image corresponding to the maximum value; A correction unit for performing skew correction on the original image according to the rotation angle of the determined rotated image.
7. A computer storage medium, characterized in that, The computer storage medium stores multiple instructions, and the instructions are adapted to be loaded and executed by a processor to perform the method steps of any one of claims 1 to 5.
8. A computer device, characterized in that, Including: A processor and a memory; where the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the method steps of any one of claims 1 to 5.
Citation Information
Patent Citations
Method for correcting license plate slant based on rotating projection
CN105488501A
Inclined image correction method based on combination of minimum area bounding box and projection method
CN111681173A