CN113852730B - Inclination angle determining method and related equipment thereof - Google Patents

Inclination angle determining method and related equipment thereof Download PDF

Info

Publication number
CN113852730B
CN113852730B CN202111144273.XA CN202111144273A CN113852730B CN 113852730 B CN113852730 B CN 113852730B CN 202111144273 A CN202111144273 A CN 202111144273A CN 113852730 B CN113852730 B CN 113852730B
Authority
CN
China
Prior art keywords
projection
image
projection angle
angle
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111144273.XA
Other languages
Chinese (zh)
Other versions
CN113852730A (en
Inventor
许广军
张军
黄国庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
iFlytek Co Ltd
Original Assignee
iFlytek Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by iFlytek Co Ltd filed Critical iFlytek Co Ltd
Priority to CN202111144273.XA priority Critical patent/CN113852730B/en
Publication of CN113852730A publication Critical patent/CN113852730A/en
Application granted granted Critical
Publication of CN113852730B publication Critical patent/CN113852730B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/00002Diagnosis, testing or measuring; Detecting, analysing or monitoring not otherwise provided for
    • H04N1/00071Diagnosis, testing or measuring; Detecting, analysing or monitoring not otherwise provided for characterised by the action taken
    • H04N1/00082Adjusting or controlling
    • H04N1/00087Setting or calibrating
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/00127Connection or combination of a still picture apparatus with another apparatus, e.g. for storage, processing or transmission of still picture signals or of information associated with a still picture
    • H04N1/00249Connection or combination of a still picture apparatus with another apparatus, e.g. for storage, processing or transmission of still picture signals or of information associated with a still picture with a photographic apparatus, e.g. a photographic printer or a projector
    • H04N1/00267Connection or combination of a still picture apparatus with another apparatus, e.g. for storage, processing or transmission of still picture signals or of information associated with a still picture with a photographic apparatus, e.g. a photographic printer or a projector with a viewing or projecting apparatus, e.g. for reading image information from a film
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/00127Connection or combination of a still picture apparatus with another apparatus, e.g. for storage, processing or transmission of still picture signals or of information associated with a still picture
    • H04N1/00326Connection or combination of a still picture apparatus with another apparatus, e.g. for storage, processing or transmission of still picture signals or of information associated with a still picture with a data reading, recognizing or recording apparatus, e.g. with a bar-code apparatus
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/00795Reading arrangements
    • H04N1/00798Circuits or arrangements for the control thereof, e.g. using a programmed control device or according to a measured quantity
    • H04N1/00819Self-calibrating reading means

Abstract

The application discloses a tilt angle determining method and related equipment thereof, wherein the method comprises the following steps: after the image to be corrected is acquired, initializing a projection angle range and a projection angle interval; determining at least one candidate projection angle according to the projection angle range and the projection angle interval; projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle; selecting a target projection angle satisfying a first condition from the candidate projection angles according to the image projection results; updating the projection angle range and the projection angle interval according to the target projection angle and the projection angle interval, and continuously executing the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval until the inclination angle of the image to be corrected is determined according to the target projection angle when the preset stop condition is reached. The accuracy of the image inclination angle can be improved, and therefore the structural information extraction effect can be improved.

Description

Inclination angle determining method and related equipment thereof
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method for determining an inclination angle and a related device thereof.
Background
In some application scenarios (e.g., examination papers, etc.), structured information may be extracted from an acquired image of some paper objects (e.g., paper test papers, paper answer cards, etc.), and then subsequent processing (e.g., scoring, etc.) may be performed based on the structured information.
In fact, when an image is acquired for a paper object, the text content in the acquired image of the paper object may be displayed in an inclined state (as shown in fig. 1) due to the nonstandard placement position of the paper object, so in order to improve the effect of extracting structured information, after the acquired image is acquired, the acquired image may be rotated according to the inclination angle estimated by an operator for the acquired image, so that the text content in the rotated acquired image is displayed in a normal state (as shown in fig. 2); and then carrying out structural information extraction processing on the rotated acquired image.
However, the manual estimation process of the inclination angle has defects, so that the estimated inclination angle is inaccurate, and thus the text content in the acquired image cannot be rotated to the display state shown in fig. 2, and the extraction effect of the structured information is not ideal.
Disclosure of Invention
The embodiment of the application mainly aims to provide a tilt angle determining method and related equipment, which can improve the accuracy of an image tilt angle, so that the extraction effect of structured information can be improved.
The embodiment of the application provides a method for determining an inclination angle, which comprises the following steps:
after the image to be corrected is acquired, initializing a projection angle range and a projection angle interval;
determining at least one candidate projection angle according to the projection angle range and the projection angle interval;
projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle;
selecting a target projection angle meeting a first condition from the at least one candidate projection angle according to an image projection result of the at least one candidate projection angle;
updating the projection angle range according to the target projection angle and the projection angle interval, updating the projection angle interval, and continuing to execute the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval until the inclination angle of the image to be corrected is determined according to the target projection angle when a preset stop condition is reached.
In one possible implementation manner, the updating the projection angle range according to the target projection angle and the projection angle interval includes:
adding the target projection angle and the projection angle interval to obtain an upper projection angle limit;
subtracting the projection angle of the target from the projection angle interval to obtain a lower limit of the projection angle;
and updating the projection angle range according to the projection angle lower limit and the projection angle upper limit.
In one possible implementation manner, the process for acquiring the image to be corrected includes:
after acquiring an acquisition image aiming at an object to be extracted, preprocessing the acquisition image to obtain the image to be corrected.
In one possible embodiment, the preprocessing includes at least one of binarization processing, edge extraction processing, and content area boundary identification processing.
In a possible implementation manner, when the preprocessing includes content region boundary identification processing, the preprocessing the acquired image to obtain the image to be corrected includes:
projecting the acquired image according to the horizontal direction to obtain a horizontal projection result;
Determining an upper boundary of the content area and a lower boundary of the content area according to the horizontal projection result;
projecting the acquired image according to the vertical direction to obtain a vertical projection result;
determining a left boundary of the content area and a right boundary of the content area according to the vertical projection result;
and extracting the image to be corrected from the acquired image according to the upper boundary of the content area, the lower boundary of the content area, the left boundary of the content area and the right boundary of the content area.
In a possible implementation manner, the determining the upper boundary of the content area and the lower boundary of the content area according to the horizontal projection result includes:
filtering the horizontal projection result to obtain a first projection filtering result; determining the upper boundary of the content area according to the projection position meeting the preset upper boundary condition in the first projection filtering result, and determining the lower boundary of the content area according to the projection position meeting the preset lower boundary condition in the first projection filtering result;
and/or the number of the groups of groups,
the determining the left boundary of the content area and the right boundary of the content area according to the vertical projection result comprises the following steps:
Filtering the vertical projection result to obtain a second projection filtering result; and determining the left boundary of the content area according to the projection position meeting the preset left boundary condition in the second projection filtering result, and determining the right boundary of the content area according to the projection position meeting the preset right boundary condition in the second projection filtering result.
In one possible embodiment, the method further comprises:
performing downsampling processing on the image to be corrected to obtain downsampled image data;
the step of projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle, comprising the following steps:
and projecting the downsampled image data according to each candidate projection angle to obtain an image projection result of each candidate projection angle.
In one possible implementation manner, the determining process of the downsampled image data includes:
sampling the image to be corrected at intervals according to a first direction and a first interval to obtain the downsampled image data;
or,
the determining process of the downsampled image data includes:
Sampling the image to be corrected at intervals according to a second direction and a second interval to obtain the downsampled image data;
or,
the determining process of the downsampled image data includes:
sampling the image to be corrected at intervals according to a first direction and a first interval to obtain first image sampling data; sampling the first image sampling data at intervals according to a second direction and a second interval to obtain the downsampled image data;
or,
the determining process of the downsampled image data includes:
sampling the image to be corrected at intervals according to a second direction and a second interval to obtain second image sampling data; and performing interval sampling on the second image sampling data according to the first direction and the first interval to obtain the downsampled image data.
In one possible embodiment, the method further comprises:
after acquiring an acquired image aiming at an object to be extracted, carrying out segmentation processing on the acquired image to obtain N image slices; wherein N is a positive integer;
determining the image to be corrected according to the nth image slice; after acquiring the inclination angle of the image to be corrected, determining the inclination angle of the image to be corrected as the inclination angle of the nth image slice; wherein N is a positive integer, N is less than or equal to N;
And determining the inclination angles of the acquired images according to the inclination angles of the N image slices.
In a possible implementation manner, the determining the tilt angle of the acquired image according to the tilt angles of the N image slices includes:
performing regression analysis processing on the inclination angles of the N image slices to obtain a regression function;
determining a check function to be used according to the regression function;
performing verification processing on the inclination angle of the nth image slice according to the to-be-used verification function to obtain a verification result of the nth image slice; wherein N is a positive integer, N is less than or equal to N;
and when the verification results of the N image slices meet the second condition, carrying out preset statistical analysis processing on the inclination angles of the N image slices to obtain the inclination angles of the acquired images.
The embodiment of the application also provides a device for determining the inclination angle, which comprises the following steps:
the initialization unit is used for initializing a projection angle range and a projection angle interval after the image to be corrected is acquired;
a determining unit, configured to determine at least one candidate projection angle according to the projection angle range and the projection angle interval;
the projection unit is used for projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle;
A screening unit, configured to select, according to an image projection result of the at least one candidate projection angle, a target projection angle that satisfies a first condition from the at least one candidate projection angle;
and the updating unit is used for updating the projection angle range according to the target projection angle and the projection angle interval, updating the projection angle interval and returning to the determining unit to continue to execute the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval until the inclination angle of the image to be corrected is determined according to the target projection angle when a preset stop condition is reached.
The embodiment of the application also provides equipment, which comprises: a processor, memory, system bus;
the processor and the memory are connected through the system bus;
the memory is used to store one or more programs, the one or more programs comprising instructions, which when executed by the processor, cause the processor to perform any of the methods of tilt angle determination provided by the embodiments of the present application.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores instructions, and when the instructions are run on the terminal equipment, the terminal equipment is caused to execute any implementation mode of the inclination angle determining method provided by the embodiment of the application.
The embodiment of the application also provides a computer program product, which when being run on a terminal device, causes the terminal device to execute any implementation mode of the inclination angle determining method provided by the embodiment of the application.
Based on the technical scheme, the application has the following beneficial effects:
in the technical scheme provided by the application, after an image to be corrected (for example, image data shown in fig. 1) is acquired, a projection angle range and a projection angle interval are initialized; determining at least one candidate projection angle according to the projection angle range and the projection angle interval; projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle; selecting a target projection angle meeting a first condition from at least one candidate projection angle according to an image projection result of the at least one candidate projection angle; and updating the projection angle range according to the target projection angle and the projection angle interval, updating the projection angle interval, and continuously executing the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval and the subsequent steps until the inclination angle of the image to be corrected is determined according to the target projection angle when a preset stop condition is reached, so that the inclination angle of the image to be corrected can accurately represent the inclination degree of text content in the image to be corrected, thereby improving the accuracy of the image inclination angle, and further improving the extraction effect of structured information.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a diagram showing image data with tilt angle according to an embodiment of the present application;
FIG. 2 is a view showing image data without inclination angle according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a projection histogram according to an embodiment of the present application;
FIG. 4 is a schematic view of another projection histogram according to an embodiment of the present application;
FIG. 5 is a flowchart of a tilt angle determining method according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a result of edge extraction for a character according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a boundary of a content area according to an embodiment of the present application;
FIG. 8 is a schematic diagram of a content area image according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of an inclination angle determining apparatus according to an embodiment of the present application.
Detailed Description
In the study on the acquired image of the paper object, the inventor finds that when the acquired image is projected, if the projection direction of the acquired image is parallel to the line direction of the text in the acquired image, the same line of characters in the acquired image are projected to the same position, and different line of characters are projected to different positions, so that the projection histogram (such as the projection histogram shown in fig. 3) of the acquired image shows that the projection histogram of each text line has a large number of character projection points, but the projection position of each line blank area has no character projection point, so that the projection histogram of the acquired image has a large variance value; if an included angle exists between the projection direction of the collected image and the line direction of the text in the collected image, different characters in the same line in the collected image may be projected to different positions, so that each projection position in the projection histogram (for example, the projection histogram shown in fig. 4) of the collected image has some character projection points, and thus the projection histogram of the collected image has a smaller variance value.
In addition, the inventors have found that: if the included angle between the projection direction of the acquired image and the line direction of the Chinese in the acquired image is larger, the variance value of the projection histogram of the acquired image is smaller; however, if the angle between the projection direction of the acquired image and the line direction in the acquired image is smaller, the variance value of the projection histogram of the acquired image is larger.
Based on the above findings, in order to solve the technical problems in the background section, an embodiment of the present application provides a tilt angle determining method, including: after the image to be corrected is acquired, initializing a projection angle range and a projection angle interval; determining at least one candidate projection angle according to the projection angle range and the projection angle interval; projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle; selecting a target projection angle meeting a first condition from at least one candidate projection angle according to an image projection result of the at least one candidate projection angle; and updating the projection angle range according to the target projection angle and the projection angle interval, updating the projection angle interval, and continuously executing the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval and the subsequent steps until the inclination angle of the image to be corrected is determined according to the target projection angle when a preset stop condition is reached, so that the inclination angle of the image to be corrected can accurately represent the inclination degree of text content in the image to be corrected, thereby improving the accuracy of the image inclination angle, and further improving the extraction effect of structured information.
In addition, the embodiment of the present application is not limited to the execution subject of the tilt angle determination method, and for example, the tilt angle determination method provided by the embodiment of the present application may be applied to a data processing device such as a terminal device or a server. The terminal device may be a cursor reader (Optical Mark Reader, OMR), a smart phone, a computer, a personal digital assistant (Personal Digital Assitant, PDA), or a tablet computer, among others. The servers may be stand alone servers, clustered servers, or cloud servers.
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Method embodiment one
Referring to fig. 5, a flowchart of a tilt angle determining method according to an embodiment of the present application is shown.
The inclination angle determining method provided by the embodiment of the application comprises the following steps of S1-S8:
S1: and acquiring an image to be corrected.
Wherein, the "image to be corrected" is used to represent image data requiring inclination angle determination processing; moreover, the embodiment of the present application does not limit the acquisition process of the "image to be corrected" (i.e., the implementation of S1), and may specifically include, for example: after acquiring an acquired image for an object to be extracted, the acquired image is directly determined as an image to be corrected.
The "object to be extracted" refers to an object (e.g., a paper object, a metal object, and other objects capable of performing image acquisition processing) that needs to perform extraction of structured information; the embodiment of the application is not limited to the object to be extracted, and for example, the object to be extracted can be a paper answer sheet, a paper test paper, a paper file and the like.
The above-mentioned "the collection image of the object to be extracted" is obtained by image collection processing by image collection equipment (for example, camera, scanning equipment, etc.) for the object to be extracted; furthermore, the embodiment of the present application is not limited to "the acquired image of the object to be extracted", and for example, it may be the image data shown in fig. 1.
In order to further improve accuracy of the tilt angle, the embodiment of the present application further provides another possible implementation manner of S1, which may specifically include: after acquiring an acquisition image aiming at an object to be extracted, preprocessing the acquisition image to obtain an image to be corrected.
Wherein, "pretreatment" may be preset; also, the embodiment of the present application is not limited to "preprocessing", and for example, it may specifically include at least one of binarization processing, edge extraction processing, and content area boundary recognition processing.
The binarization processing is used for converting the gray value of a pixel point in one image data into 0 or 255 so that the converted image data can be presented in a black-and-white effect; the embodiment of the present application is not limited to the implementation of the "binarization process", and may be implemented by any method that can perform binarization conversion processing (e.g., an oxford method (OTSU), a background method, etc.) on image data, for example, existing or future.
The "edge extraction processing" is for extracting edge contour information appearing in one image data so that the extracted image data can highlight the edge contour information in the image data (for example, a character edge extraction image shown in fig. 6 is for highlighting edge contour information of each character); moreover, embodiments of the present application are not limited to the implementation of "edge extraction processing", and may be implemented using any edge extraction method (e.g., canny edge detection algorithm, horizontal-vertical difference method, etc.), for example, existing or future.
The "content area boundary recognition processing" is used to perform boundary recognition processing for a content aggregation area (e.g., text and/or graphics aggregation area, etc.) in one image data. Wherein the "content aggregation area" is used to record useful information carried by the image data.
The embodiment of the present application is not limited to the implementation of the "content area boundary recognition processing", and may be implemented by any method that can perform content area detection processing for one image data, existing or occurring in the future, for example.
In addition, in order to improve the accuracy of detecting the content area, the embodiment of the present application also provides a possible implementation manner of "content area boundary identifying process", and in order to facilitate understanding of this implementation manner, the following description is made with reference to an example.
As an example, when the above-described "preprocessing" includes the content area boundary recognition processing, the determination process of the image to be corrected may include steps 11 to 15:
step 11: and projecting the acquired image of the object to be extracted according to the horizontal direction to obtain a horizontal projection result.
The "horizontal projection result" is used to represent a distribution state of projection positions obtained after each pixel point in the acquired image of the object to be extracted is projected according to the horizontal direction, so that the "horizontal projection result" can accurately represent the number of character projection points appearing on each projection position when the projection is performed according to the horizontal direction, and thus the "horizontal projection result" can represent the number of character pixel points existing in each row of the pixel points of the acquired image.
The "character pixel" refers to a pixel constituting a character (for example, a pixel represented in a black state in fig. 1).
In addition, the embodiment of the present application is not limited to the expression of "horizontal projection result", and for example, the expression may be performed using a projection histogram (such as the projection histogram of fig. 3 or the projection histogram shown in fig. 4).
Step 12: and determining the upper boundary of the content area and the lower boundary of the content area according to the horizontal projection result.
The "upper boundary of the content area" is used to represent the upper boundary position of the area where the text is located in the "captured image of the object to be extracted" described above (the upper boundary of the content area shown in fig. 7).
The "lower boundary of the content area" is used to indicate the lower boundary position of the area where the text is located in the above-described "captured image of the object to be extracted" (lower boundary of the content area shown in fig. 7).
The embodiment of the present application is not limited to the implementation of step 12, and for example, it may specifically include steps 21 to 23:
step 21: and filtering the horizontal projection result to obtain a first projection filtering result.
Wherein the "filtering process" is used for performing noise point filtering processing for one data (e.g., projection histogram, etc.); furthermore, embodiments of the present application are not limited to "filtering processes," and may be implemented, for example, using any filtering algorithm (e.g., median filtering, etc.) that may be present or occur in the future.
Step 22: and determining the upper boundary of the content area according to the projection position meeting the preset upper boundary condition in the first projection filtering result.
The "preset upper boundary condition" may be preset, for example, it may specifically be: the projection position which is the most upper position when projection is performed in the horizontal direction and the number of character projection points is higher than the first threshold value.
In addition, the embodiment of the present application is not limited to the implementation of step 22, and may specifically include: firstly, determining the ordinate of a projection position meeting a preset upper boundary condition in a first projection filtering result as an upper boundary ordinate; and determining the set of all pixel points with the ordinate of the upper boundary in the acquired image of the object to be extracted as the upper boundary of the content area.
Step 23: and determining the lower boundary of the content area according to the projection position meeting the preset lower boundary condition in the first projection filtering result.
The "preset lower boundary condition" may be preset, for example, it may specifically be: the projection position which is the lowest position when the projection is performed in the horizontal direction and the number of character projection points is higher than the first threshold value.
In addition, the embodiment of the present application is not limited to the implementation of step 23, and may specifically include: firstly, determining the ordinate of a projection position meeting a preset lower boundary condition in a first projection filtering result as a lower boundary ordinate; and determining the set of all pixel points with the ordinate of the lower boundary in the acquired image of the object to be extracted as the lower boundary of the content area.
Based on the above-mentioned related content of step 12, after the horizontal projection result is obtained, the upper boundary of the content area and the lower boundary of the content area of the "collected image of the object to be extracted" may be determined by referring to the number of character pixels existing in each row of pixels in the "collected image of the object to be extracted" recorded by the horizontal projection result.
Step 13: and projecting the acquired image of the object to be extracted according to the vertical direction to obtain a vertical projection result.
It should be noted that, the relevant content of step 13 is similar to that of step 11 above, and only "horizontal" in the relevant content of step 11 above is replaced by "vertical", and "pixel points of each row" is replaced by "pixel points of each column".
Step 14: and determining the left boundary of the content area and the right boundary of the content area according to the vertical projection result.
The "left boundary of the content area" is used to represent the left boundary position of the area where the text is located in the "captured image of the object to be extracted" described above (the left boundary of the content area shown in fig. 7).
The "content area right boundary" is used to represent the right boundary position of the area where the text is located in the above-described "captured image of the object to be extracted" (the content area right boundary shown in fig. 7).
Embodiments of the present application are not limited to the implementation of step 14, and may specifically include, for example, steps 31-33:
step 31: and filtering the vertical projection result to obtain a second projection filtering result.
Note that, the relevant content of the "filtering process" is referred to the relevant content of the "filtering process" in step 21 above.
Step 32: and determining the left boundary of the content area according to the projection position meeting the preset left boundary condition in the second projection filtering result.
The "preset left boundary condition" may be preset, for example, it may specifically be: the projection position is the position furthest to the left when the projection is performed in the vertical direction and the number of character projection points is higher than the second threshold value.
In addition, the embodiment of the present application is not limited to the implementation of step 32, and may specifically include: firstly, determining the abscissa of a projection position meeting a preset left boundary condition in a second projection filtering result as a left boundary abscissa; and determining the set of all pixel points with the left boundary abscissa in the acquired image of the object to be extracted as the left boundary of the content area.
Step 33: and determining the right boundary of the content area according to the projection position meeting the preset right boundary condition in the second projection filtering result.
The "preset right boundary condition" may be preset, for example, it may specifically be: the projection position is the position furthest to the right when the projection is performed in the vertical direction and the number of character projection points is higher than a second threshold value.
In addition, the embodiment of the present application is not limited to the implementation of step 33, and may specifically include: firstly, determining the abscissa of the projection position meeting the preset right boundary condition in the second projection filtering result as the right boundary abscissa; and determining the set of all pixel points with the right boundary abscissa in the acquired image of the object to be extracted as the right boundary of the content area.
Based on the above-mentioned related content of step 14, after the vertical projection result is obtained, the left boundary of the content area and the right boundary of the content area of the "collected image of the object to be extracted" may be determined by referring to the number of character pixels existing in each column of pixels in the "collected image of the object to be extracted" recorded by the vertical projection result.
Step 15: and extracting an image to be corrected from the acquired image of the object to be extracted according to the upper boundary of the content area, the lower boundary of the content area, the left boundary of the content area and the right boundary of the content area.
In the embodiment of the application, after the upper boundary, the lower boundary, the left boundary and the right boundary of the content area are obtained, image clipping processing can be performed on the acquired image of the object to be extracted according to the four boundaries to obtain a content area image (such as the content area image shown in the figure and 8) in the acquired image of the object to be extracted; and determining the content area image as an image to be corrected.
Based on the above-mentioned related contents of step 11 to step 15, after obtaining an image data, determining an upper boundary and a lower boundary of a content gathering area in the image data according to a projection result of the image data in a horizontal direction, and determining a left boundary and a right boundary of the content gathering area in the image data according to a projection result of the image data in a vertical direction; and extracting the local image of the content gathering area from the image data by referring to the upper boundary, the lower boundary, the left boundary and the right boundary of the content gathering area, so that the local image only comprises useful information carried by the image data, and the local image can better represent the image information carried by the image data.
To facilitate an understanding of another possible embodiment of "S1" above, the following description is made in connection with both cases.
In case 1, when the above-described "preprocessing" includes binarization processing, edge extraction processing, and text boundary recognition processing, S1 may specifically include: firstly, carrying out binarization processing on the acquired image of the object to be extracted to obtain first image data, so that the first image data presents image information carried by the acquired image of the object to be extracted in a black-and-white effect; performing edge extraction processing on the first image data to obtain second image data, so that the second image data can highlight edge contour information (such as character edge contour and/or graphic edge contour) in the first image data; finally, the second image data is subjected to content area boundary recognition processing to obtain an image to be corrected (as shown in fig. 8), so that the image to be corrected can better represent useful information (such as character information, graphic information and the like) carried by the acquired image of the object to be extracted.
In case 2, the "captured image of the object to be extracted" described above may occur as follows: in the acquired image of the object to be extracted, a part of text content (for example, a student answer trace in a test paper) is darker in color, but another part of text content (for example, an original question in the test paper) is lighter in color, so in order to avoid missing character information, S1 may specifically include: firstly, carrying out text edge extraction processing on the acquired image of the object to be extracted to obtain third image data, so that the edge contour of each character in the acquired image of the object to be extracted can be highlighted by the third image data; then, carrying out graph edge extraction processing on the third image data to obtain fourth image data, so that the edge contour of each graph of the acquired image of the object to be extracted can be further highlighted by the fourth image data; and finally, carrying out content area boundary recognition processing on the fourth image data to obtain an image to be corrected, so that the image to be corrected can better represent character information and graphic information carried by the acquired image of the object to be extracted.
It should be noted that, the embodiment of the present application is not limited to the implementation of the word edge extraction process, and for example, the embodiment may be implemented by using a Canny edge detection algorithm; the embodiment of the present application is not limited to the above-described "pattern edge extraction process", and may be implemented by, for example, a horizontal-vertical difference method.
Based on the above-described content related to S1, after acquiring an acquired image for an object to be extracted, an image to be corrected may be determined from the acquired image so that the tilt angle of the acquired image can be automatically identified by the subsequent determination process of the tilt angle of the image to be corrected (i.e., S1-S8).
S2: the projection angle range and projection angle interval are initialized.
Wherein "projection angle range" is used to denote a selectable range of projection angles; furthermore, the embodiment of the present application does not limit the initialization result of the "projection angle range", and for example, it may be specifically [ -90 °,90 ° ].
"projection angle interval" means an angle difference between adjacent two candidate projection angles when the candidate projection angles are selected from the above-described "projection angle range"; furthermore, the embodiment of the present application does not limit the initialization result of the "projection angle interval", and may be, for example, 10 °.
S3: at least one candidate projection angle is determined based on the projection angle range and the projection angle interval.
Wherein "candidate projection angle" is used to indicate the projection direction of the reference required when projecting the image to be corrected.
In addition, embodiments of the present application are not limited to "at least one candidate projection angle", and for example, when the projection angle range is [ -90 °,90 ° ] and the projection angle interval is 10 °, the "at least one candidate projection angle" may include-90 °, -80 °, -70 °, … … (and so on), 70 °, 80 °,90 °.
S4: and projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle.
The image projection result of the mth candidate projection angle is used for representing a projection position distribution state obtained after each pixel point in the image to be corrected is projected according to the mth candidate projection angle, so that the image projection result of the mth candidate projection angle can accurately represent the number of character projection points appearing on each projection position when the image is projected according to the mth candidate projection angle. M is a positive integer, M is less than or equal to M, M is a positive integer, and M represents the number of candidate projection angles in the at least one candidate projection angle.
The embodiment of the present application is not limited to the expression of the "image projection result of the mth candidate projection angle", and may be expressed by using, for example, a projection histogram (such as the projection histogram of fig. 3 or the projection histogram shown in fig. 4).
S5: and selecting a target projection angle meeting the first condition from the at least one candidate projection angle according to an image projection result of the at least one candidate projection angle.
Wherein, the first condition can be preset; moreover, the embodiment of the present application is not limited to the "first condition", and for example, when the above-described "image projection result" is represented by a projection histogram, the first condition may specifically be that the variance value reaches the maximum (or that the variance difference value reaches the maximum).
It can be seen that, for the "projection histogram of the mth candidate projection angle", if the variance value of the "projection histogram of the mth candidate projection angle" is higher than the variance value of the projection histogram of any one of the other candidate projection angles (or the variance difference value of the "projection histogram of the mth candidate projection angle" is higher than the variance difference value of the projection histogram of any one of the other candidate projection angles), it can be determined that the "projection histogram of the mth candidate projection angle" satisfies the first condition, so that it can be determined that the image projection result of the mth candidate projection angle satisfies the first condition, and therefore the "mth candidate projection angle" can be determined as the target projection angle. Wherein M is a positive integer, M is less than or equal to M, M is a positive integer, and M represents the number of candidate projection angles in the at least one candidate projection angle.
In addition, the embodiment of the present application is not limited to the above-described calculation process of the "variance value", and for example, it may be implemented using the formulas (1) - (2).
In the method, in the process of the application,a variance value indicating the "projection histogram of the mth candidate projection angle"; l (L) m The number of projection positions in the "projection histogram of the mth candidate projection angle" (or the length of the projection region in the "projection histogram of the mth candidate projection angle"); />The number of character projection points appearing at the i-th projection position in the "projection histogram of the m-th candidate projection angle" is represented.
In addition, the embodiment of the present application is not limited to the above-described calculation process of the "variance difference value", and for example, it may be implemented using the formula (3).
In the formula, deltaH m A variance difference value indicating the "projection histogram of the mth candidate projection angle";a variance value indicating the "projection histogram of the mth candidate projection angle"; />A variance value representing the "projection histogram of the m+1th candidate projection angle"; />The variance value of the "projection histogram of the m-1 st candidate projection angle" is shown.
Based on the above-mentioned content related to S5, after obtaining the image projection result of at least one candidate projection angle, a first statistical analysis (for example, calculating a variance value or calculating a variance difference value) may be performed on the image projection result of each candidate projection angle to obtain a projection analysis result of each candidate projection angle; and referring to the projection analysis results of the respective candidate projection angles, selecting a target projection angle satisfying the first condition from the at least one candidate projection angle so that the projection analysis result of the target projection angle can be closer to the projection analysis result (the character projection point distribution state shown as the projection histogram in fig. 3) obtained when projection is performed in the line direction in the "image to be corrected".
S6: judging whether a preset stopping condition is met, if so, executing S9; if not, S7-S8 are performed.
Wherein, the 'preset stop condition' can be preset; the embodiment of the application is not limited to the preset stop condition, for example, the projection angle interval of the current wheel is not higher than the preset inclination angle identification precision, and the update times of the target projection angle can reach the preset times threshold.
Note that, the content related to the "tilt angle recognition accuracy" is referred to the content related to the "tilt angle recognition accuracy" in step 41 below.
S7: and updating the projection angle range according to the target projection angle and the projection angle interval.
In the embodiment of the application, if the preset stopping condition is not met, the difference between the projection analysis result of the target projection angle and the projection analysis result obtained when the projection is performed in the line direction of the Chinese character in the image to be corrected is still larger, so that the projection angle range can be updated by referring to the target projection angle and the projection angle interval of the current wheel; and the updating process may specifically include: firstly, adding the projection angle of the target and the projection angle interval to obtain an upper limit of the projection angle, and subtracting the projection angle of the target and the projection angle interval to obtain a lower limit of the projection angle; and updating the projection angle range (shown as formula (4)) according to the projection angle lower limit and the projection angle upper limit.
Wherein R is new Representing the updated projection angle range;representing a lower projection angle limit in the updated projection angle range; />Representing projection angles in the updated projection angle rangeAn upper limit of the degree; a is that score Representing a target projection angle of the current wheel; ΔA now Representing the projection angle interval of the current wheel.
S8: the projection angle interval is updated and execution returns to S3.
In the embodiment of the application, after the projection angle range is updated, the projection angle interval can be continuously updated, so that the updated projection angle interval is smaller than the projection angle interval before updating, and the updated projection angle interval can be more suitable for selecting each candidate projection angle from the updated projection angle range.
In addition, the embodiment of the application does not limit the updating process of the projection angle interval, for example, the projection angle interval corresponding to the next round of circulation can be searched from the pre-constructed mapping relation. Wherein, the mapping relation is used for recording the projection angle interval corresponding to each round of circulation.
In order to further improve the effect of determining the tilt angle, the projection angle interval may be updated with reference to the tilt angle identification accuracy set in advance. Based on this, the embodiment of the present application also provides another possible implementation of the update procedure of the "projection angle interval", which may specifically include steps 41-42:
Step 41: and determining the interval to be used according to the projection angle interval and the inclination angle identification precision.
The "inclination angle recognition accuracy" refers to an inclination angle recognition accuracy set in advance for image data; furthermore, the embodiment of the present application is not limited to "inclination angle recognition accuracy", and for example, it may be specifically 0.1 °.
In addition, the embodiment of the present application is not limited to the implementation of step 41, and may specifically include, for example, as shown in equation (5): if the ratio between the projection angle interval and the inclination angle identification precision is determined to be even, the precision multiple can be determined according to the 'ratio between the projection angle interval and the inclination angle identification precision'; then determining the product of the inclination angle identification precision and the precision multiple as an interval to be used; however, if it is determined that the ratio between the projection angle interval and the inclination angle identification accuracy is an odd number, the inclination angle identification accuracy may be determined as the interval to be used.
Wherein DeltaA use Representing an interval to be used; ΔA now Representing the projection angle interval of the current wheel (i.e., the projection angle interval before updating); a, a dis Indicating a preset inclination angle recognition accuracy; m is m acc Representing a multiple of precision.
In addition, the embodiment of the present application is not limited to the determination process of the "precision multiple", and for example, it may specifically include: all factors of the ratio are determined (for example, all factors of 10 include 1,2,5,10) according to the ratio (for example, 10) between the projection angle interval and the inclination angle identification accuracy; selecting at least one candidate factor (e.g., 1,2, 5) satisfying a third condition from among all factors; finally, a candidate factor (e.g., 2) is randomly selected from the at least one candidate factor, and determined as a multiple of precision. The "third condition" may be preset, for example, specifically may be: a factor that is not equal to the above-described "ratio between projection angle interval and inclination angle recognition accuracy".
Step 42: and updating the projection angle interval by using the interval to be used.
In the embodiment of the present application, after the interval to be used is obtained, the projection angle interval may be updated according to the interval to be used (for example, the interval to be used may be directly determined as the updated projection angle interval), so that the updated projection angle interval is smaller than the projection angle interval before updating.
Based on the above-mentioned related content of S8, after the update is completed for the projection angle range, the update for the projection angle interval may be continued, so that the projection angle interval after the update is smaller than the projection angle interval before the update, and the step S3 and the subsequent steps are executed again, so as to implement the next round of update process for the target projection angle.
S9: and determining the inclination angle of the image to be corrected according to the target projection angle.
In the embodiment of the present application, if it is determined that the preset stopping condition is reached, the projection analysis result of the "target projection angle" may be determined to be almost similar to the projection analysis result obtained when the projection is performed in the line direction of the image to be corrected, so that the tilt angle of the image to be corrected may be determined directly according to the target projection angle, so that the tilt angle may accurately represent the tilt state of the line in the image to be corrected, so that the rotation process may be performed on the image to be corrected based on the tilt angle, so that the line in the rotated image to be corrected may be displayed in a normal state (as shown in fig. 2).
The embodiment of the present application is not limited to the implementation of S9, and may be implemented by any method that can determine the tilt angle of an object with reference to the projection angle of the object, which is present or occurs in the future.
Based on the above-mentioned related content of S1 to S9, for the tilt angle determining method provided by the embodiment of the present application, after obtaining the image to be corrected, the projection angle range and the projection angle interval are initialized; determining at least one candidate projection angle according to the projection angle range and the projection angle interval; projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle; selecting a target projection angle meeting a first condition from at least one candidate projection angle according to an image projection result of the at least one candidate projection angle; and updating the projection angle range according to the target projection angle and the projection angle interval, updating the projection angle interval, and continuously executing the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval and the subsequent steps until the inclination angle of the image to be corrected is determined according to the target projection angle when a preset stop condition is reached, so that the inclination angle of the image to be corrected can accurately represent the inclination degree of text content in the image to be corrected, thereby improving the accuracy of the image inclination angle, and further improving the extraction effect of structured information.
Method embodiment II
In practice, since the number of characters in each text line in one image data is relatively large, in order to improve the determination efficiency of the inclination angle, the image data may be downsampled to reduce the number of characters in the image data; and then performing inclination angle determination processing on the downsampling processing result of the image data. Based on this, the embodiment of the present application also provides another possible implementation manner of the inclination angle determining method, in this implementation manner, the inclination angle determining method may further include S10-S11 in addition to S1-S3 and S5-S9 described above:
s10: and carrying out downsampling treatment on the image to be corrected to obtain downsampled image data.
The downsampling process is used for reducing the number of pixels in image data; moreover, embodiments of the present application are not limited to "downsampling" implementations, and may be implemented using any sampling method, either existing or occurring in the future, for example. For ease of understanding, the following description is provided in connection with four examples.
Example 1, S10 may specifically include: and sampling the image to be corrected at intervals according to the first direction and the first interval to obtain downsampled image data.
The "first direction" may be preset, for example, it may be a horizontal direction.
The "first interval" is used to denote a distance between adjacent two sampling pixel points when interval sampling is performed in the first direction; furthermore, embodiments of the present application are not limited to "first interval", and for example, it may be K pixel points. Wherein K is a positive integer.
Example 2, S10 may specifically include: and performing interval sampling on the image to be corrected according to the second direction and the second interval to obtain downsampled image data.
The "second direction" may be predetermined, and may be, for example, a vertical direction.
"second interval" is used to denote the distance between two adjacent sampling pixels when interval sampling is performed in the second direction; also, embodiments of the present application are not limited to "second spaces", which may be K pixels, for example. Wherein K is a positive integer.
As is known from the above-described matters related to examples 1 and 2, in some cases, sampling processing in a certain direction may be performed on an image to be corrected, so that image data after the sampling processing can have fewer pixels, so that the subsequent tilt angle determination processing may be performed with reference to fewer pixels, which is advantageous in improving the tilt angle determination efficiency.
Example 3, S10 may specifically include: firstly, sampling an image to be corrected at intervals according to a first direction and a first interval to obtain first image sampling data; and then the first image sampling data is sampled at intervals according to the second direction and the second interval, so as to obtain downsampled image data.
Example 4, S10 may specifically include: sampling the image to be corrected at intervals according to a second direction and a second interval to obtain second image sampling data; and performing interval sampling on the second image sampling data according to the first direction and the first interval to obtain downsampled image data.
As is clear from the above-described matters related to examples 3 and 4, in some cases, sampling processing in two directions may be performed for an image to be corrected, so that image data after the sampling processing can have fewer pixels, which is advantageous for further improving the downsampling effect, and thus for further improving the tilt angle determination efficiency.
Based on the above-mentioned related content of S10, after the image to be corrected is obtained, the downsampling process may be performed on the image to be corrected to obtain downsampled image data, so that the number of pixels in the downsampled image data is smaller than the number of pixels in the image to be corrected.
It should be noted that the embodiment of the present application is not limited to the execution time of S10, and for example, it may be executed after the execution of S1 is completed and before the execution of S11.
S11: and projecting the downsampled image data according to each candidate projection angle to obtain an image projection result of each candidate projection angle.
It should be noted that, the relevant content of S11 is similar to the relevant content of S4 above, and the "image to be corrected" in the relevant content of S4 above is merely replaced by "downsampled image data".
It should be noted that the embodiment of the present application is not limited to the execution time of S11, and for example, it may be executed after the execution of S10 is completed and before the execution of S5.
Based on the above-mentioned related content of S10 to S11, in the tilt angle determining method provided by the embodiment of the present application, after an image to be corrected is obtained, downsampling processing may be performed on the image to be corrected to obtain downsampled image data, so that the number of pixels in the downsampled image data is smaller than the number of pixels in the image to be corrected; and determining the inclination angle of the image to be corrected based on the downsampled image data, so that the determination efficiency of the inclination angle is improved, and the determination effect of the inclination angle is improved.
Method example III
In order to improve the accuracy of the tilt angle, the embodiment of the present application also provides another possible implementation manner of the tilt angle determining method, in this implementation manner, the tilt angle determining method may further include S12-S14 in addition to some or all of the above steps (e.g., S2-S9, or S2-S3 and S5-S11):
s12: after acquiring an acquired image aiming at an object to be extracted, cutting the acquired image to obtain N image slices. Wherein N is a positive integer.
The "splitting process" may be preset, for example, it may specifically be: the slicing is performed according to a preset slicing rule (or according to a preset slice size). The "preset slicing rule" (or, preset slice size) may be preset.
S13: the image to be corrected is determined from the nth image slice so that, after the inclination angle of the image to be corrected is acquired, the inclination angle of the image to be corrected is determined as the inclination angle of the nth image slice. Wherein N is a positive integer, and N is less than or equal to N.
The "tilt angle of the nth image slice" is used to indicate the tilt state of the line of text in the nth image slice.
It can be seen that, for the nth image slice, the image to be corrected may be determined first according to the nth image slice (for example, the nth image slice may be directly determined as the image to be corrected; or the nth image slice may be preprocessed to obtain the image to be corrected); determining the inclination angle of the image to be corrected by using the S2-S9 (or S2-S3 and S5-S11); finally, the tilt angle of the image to be corrected is determined as the tilt angle of the nth image slice, so that the "tilt angle of the nth image slice" can represent the tilt state of the line of text in the nth image slice. Wherein N is a positive integer, and N is less than or equal to N.
S14: the tilt angle of the acquired image is determined from the tilt angles of the N image slices.
In the embodiment of the present application, after the inclination angle of the 1 st image slice to the inclination angle of the nth image slice are obtained, the inclination angle of the acquired image of the object to be extracted may be determined according to the inclination angles of the N image slices; and the determining process may specifically include: and performing second statistical analysis processing on the inclination angles of the N image slices to obtain the inclination angle of the acquired image of the object to be extracted. The "second statistical analysis process" may be preset, and the embodiment of the present application is not limited to the "second statistical analysis process", and for example, it may be specifically an averaging process.
In addition, in order to further improve the accuracy of the inclination angle, the embodiment of the present application also provides another possible implementation manner of S14, which may specifically include S141-S146:
s141: regression analysis processing is carried out on the inclination angles of the N image slices, and a regression function is obtained.
Wherein, the regression function is used for expressing the quantitative relation between the image data variable and the inclination angle variable; moreover, embodiments of the present application are not limited to this "regression function", and for example, it may be expressed by a linear regression function f (x) =a×x+b. Wherein "x" refers to an image data variable; f (x) is the tilt angle variation; both "a" and "b" are coefficients in the "linear regression function" described above.
In addition, the embodiment of the present application is not limited to the implementation of the "regression analysis process", and may be implemented using any regression analysis algorithm (e.g., least square method, etc.) existing or appearing in the future, for example. To facilitate an understanding of the least squares method, the following description is made in connection with an example.
Assuming that the above "regression function" is f (X) =a×x+b, the set of N image slices is denoted as x= { X 1 ,x 2 ,…,x N The set of tilt angles for N image slices is denoted as z= { Z 1 ,z 2 ,…,z N }。
As an example, based on the above assumption, the tilt angle estimation may be performed on each image slice by using the above "regression function" to obtain the estimated tilt angle of each image slice; and the set of these estimated tilt angles can be expressed as f= { F (x 1 ),f(x 2 ),…,f(x N ) }. Wherein f (x) n ) Representing the estimated tilt angle of the nth image slice. N is a positive integer, N is less than or equal to N, and N is a positive integer.
Based on this, the residual sum between F and Z can be expressed by the formula (6), so in order to calculate "a" and "b", the partial derivatives of "a" and "b" can be obtained by first calculating the partial derivatives of "a" and "b" based on the formula (6), respectively; then making the partial derivative of a and the partial derivative of b equal to 0 to obtain two equations; finally, based on the two equations, the solutions result in "a" and "b" (as shown in equations (7) - (10)).
Wherein ε represents the sum of residuals between F and Z; x is x n Representing an nth image slice; z n Representing the tilt angle of the nth image slice; f (x) n ) Representing the estimated tilt angle of the nth image slice, and f (x n )=a×x n +b; n is a positive integer, N is less than or equal to N, and N is a positive integer.
Wherein a represents a coefficient a in f (x) =a×x+b; b represents a coefficient b in f (x) =a×x+b; x is x n Representing an nth image slice; z n Representing the tilt angle of the nth image slice; f (x) n ) Representing the estimated tilt angle of the nth image slice, and f (x n )=a×x n +b; n is a positive integer, N is less than or equal to N, and N is a positive integer.
Based on the above-mentioned related content of S141, after the tilt angles of the respective image slices are acquired, regression analysis processing may be performed on the tilt angles of all the image slices first to obtain a regression function, so that the regression function can represent a quantitative relationship between the image data variable and the tilt angle variable.
S142: and determining a check function to be used according to the regression function.
Wherein a "check function to be used" is used to check whether the quantitative relationship between the inclination angle of each image slice and each image slice corresponds to the quantitative relationship shown by the above-mentioned "regression function".
In addition, the embodiment of the present application is not limited to the "check function to be used", and for example, when the "regression function" is f (x) =a×x+b, the check function to be used may be represented by the formula (11).
In θ n Representing a verification result of the nth image slice; x is x n Representing an nth image slice; z n Representing the tilt angle of the nth image slice; f (x) n ) Representing the estimated tilt angle of the nth image slice, and f (x n )=a×x n +b; n is a positive integer, N is less than or equal to N, and N is a positive integer; delta represents a preset parameter; and the δ may be preset, for example, δ=3.
If θ n The larger the number relationship between the n-th image slice and the tilt angle of the n-th image slice is, the more the quantitative relationship shown by the above-mentioned "regression function" is not met, and thus the lower the reliability degree of the tilt angle of the n-th image slice is; if theta is n The smaller the number relationship between the n-th image slice and the tilt angle of the n-th image slice is, the more the quantitative relationship shown by the above-described "regression function" is satisfied, and thus the higher the degree of reliability of the tilt angle of the n-th image slice is.
S143: and performing verification processing on the inclination angle of the nth image slice according to the to-be-used verification function to obtain a verification result of the nth image slice. Wherein N is a positive integer, and N is less than or equal to N.
In the embodiment of the application, after the check function to be used is obtained, the nth image slice x can be obtained n The tilt angle z of the nth image slice n Inputting the check function to be used to obtain a check result theta of the nth image slice n So that the theta is n The degree of confidence in the tilt angle of the nth image slice can be expressed so that the θ can be referenced later n The tilt angle of the above-described "captured image of the object to be extracted" is determined. Wherein N is a positive integer, and N is less than or equal to N.
S144: judging whether the verification results of the N image slices meet a second condition, if so, executing S145; if not, S146 is performed.
Here, the "second condition" may be preset, for example, in order to increase the accuracy of the tilt angle as much as possible, and if the "verification result" is determined by the above formula (11), the second condition may be: the verification results of the N image slices are lower than a preset verification threshold value.
S145: and carrying out preset statistical analysis processing on the inclination angles of the N image slices to obtain the inclination angle of the acquired image of the object to be extracted.
The "preset statistical analysis process" may be preset, for example, it may be specifically an averaging process.
Therefore, in the embodiment of the application, after the verification results of the N image slices are determined to meet the second condition, the reliability degree of the verification results of the N image slices can be determined to be higher, so that the inclination angles of the N image slices can be subjected to preset statistical analysis processing to obtain the inclination angle of the acquired image of the object to be extracted, so that the inclination angle can more accurately represent the inclination degree of the text content in the acquired image of the object to be extracted, which is beneficial to further improving the extraction effect of the structured information.
S146: generating alarm prompt information and carrying out preset sending processing on the alarm prompt information.
The alarm prompt information is used for informing a user that the inclination angle of the acquired image of the object to be extracted cannot be determined.
The preset sending process is used for sending the alarm prompt information to the user; moreover, the embodiment of the present application is not limited to the implementation of the "preset transmission process", and for ease of understanding, the following description will be made with reference to two examples.
Example 1, when the execution subject of the tilt angle determining method provided by the embodiment of the present application is a terminal device, the "preset transmission process" may specifically include at least one of steps 51 to 53:
step 51: the terminal equipment displays the alarm prompt information on a display screen.
Step 52: the terminal device sends the alarm prompt information to the user by means of a mail sending function (or a short message sending function).
Step 53: the terminal equipment plays the audio data of the alarm prompt information by means of a loudspeaker.
Example 2, when the execution subject of the tilt angle determining method provided by the embodiment of the present application is a server, the "preset transmission process" may specifically include: firstly, a server sends alarm prompt information to terminal equipment; and then the terminal equipment sends the alarm prompt information to the user according to at least one of the steps 51-53.
Based on the above-mentioned related content of S146, after determining that the verification results of the N image slices do not meet the second condition, it may be determined that at least one verification result with relatively low reliability exists in the verification results of the N image slices, so in order to reduce the adverse effects of these "verification results with relatively low reliability" as much as possible, the tilt angle determination process is directly ended, and an alarm prompt message is generated and sent, so that the user can learn from the alarm prompt message that the tilt angle of the "collected image of the object to be extracted" cannot be determined by using the tilt angle determination method provided by the embodiment of the present application.
Based on the above-mentioned related content of S14, after the inclination angles of the N image slices are obtained, the inclination angle of the "collected image of the object to be extracted" may be determined with reference to the inclination angles of the N image slices, so that the inclination angle may more accurately represent the inclination degree of the text content in the "collected image of the object to be extracted", which is beneficial to further improving the effect of extracting the structured information.
Based on the above-mentioned content related to S12 to S14, for some application scenarios (for example, application scenarios with relatively high requirements for accuracy of the inclination angle), after acquiring an acquired image of an object to be extracted, the acquired image may be subjected to segmentation processing to obtain at least one image slice; and determining the inclination angle of the acquired image of the object to be extracted by referring to the inclination angles of all the image slices after determining the inclination angles of all the image slices, so that the inclination angle can more accurately represent the inclination degree of the text content in the acquired image of the object to be extracted, and the extraction effect of the structured information is further improved.
Based on the tilt angle determining method provided in the above method embodiment, the embodiment of the present application further provides a tilt angle determining device, which is explained and illustrated below with reference to the accompanying drawings.
Device embodiment
The device embodiment describes the inclination angle determining device, and the related content is referred to the above method embodiment.
Referring to fig. 9, a schematic diagram of a tilt angle determining apparatus according to an embodiment of the present application is shown.
The inclination angle determining apparatus 900 provided in the embodiment of the present application includes:
an initializing unit 901, configured to initialize a projection angle range and a projection angle interval after an image to be corrected is acquired;
a determining unit 902, configured to determine at least one candidate projection angle according to the projection angle range and the projection angle interval;
a projection unit 903, configured to project the image to be corrected according to each candidate projection angle, to obtain an image projection result of each candidate projection angle;
a screening unit 904, configured to select, according to an image projection result of the at least one candidate projection angle, a target projection angle that meets a first condition from the at least one candidate projection angle;
an updating unit 905, configured to update the projection angle range according to the target projection angle and the projection angle interval, update the projection angle interval, and return to the determining unit 902 to continue to perform the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval until a preset stopping condition is reached, and determine an inclination angle of the image to be corrected according to the target projection angle.
In a possible implementation manner, the updating unit 905 includes:
a range updating subunit, configured to sum the target projection angle and the projection angle interval to obtain an upper projection angle limit; subtracting the projection angle of the target from the projection angle interval to obtain a lower limit of the projection angle; and updating the projection angle range according to the projection angle lower limit and the projection angle upper limit.
In one possible embodiment, the inclination angle determining apparatus 900 further includes:
and the preprocessing unit is used for preprocessing the acquired image of the object to be extracted after acquiring the acquired image to obtain the image to be corrected.
In one possible embodiment, the preprocessing includes at least one of binarization processing, edge extraction processing, and content area boundary identification processing.
In one possible implementation, the preprocessing includes content region boundary identification processing, and the preprocessing unit includes:
the first projection subunit is used for projecting the acquired image according to the horizontal direction to obtain a horizontal projection result;
a first determining subunit, configured to determine an upper boundary of the content area and a lower boundary of the content area according to the horizontal projection result;
The second projection subunit is used for projecting the acquired image according to the vertical direction to obtain a vertical projection result;
a second determining subunit, configured to determine a left boundary of the content area and a right boundary of the content area according to the vertical projection result;
and the image extraction subunit is used for extracting the image to be corrected from the acquired image according to the upper boundary of the content area, the lower boundary of the content area, the left boundary of the content area and the right boundary of the content area.
In a possible embodiment, the first determining subunit is specifically configured to: filtering the horizontal projection result to obtain a first projection filtering result; and determining the upper boundary of the content area according to the projection position meeting the preset upper boundary condition in the first projection filtering result, and determining the lower boundary of the content area according to the projection position meeting the preset lower boundary condition in the first projection filtering result.
In a possible embodiment, the second determining subunit is specifically configured to: filtering the vertical projection result to obtain a second projection filtering result; and determining the left boundary of the content area according to the projection position meeting the preset left boundary condition in the second projection filtering result, and determining the right boundary of the content area according to the projection position meeting the preset right boundary condition in the second projection filtering result.
In one possible embodiment, the inclination angle determining apparatus 900 further includes:
the downsampling unit is used for performing downsampling processing on the image to be corrected to obtain downsampled image data;
the projection unit 903 is specifically configured to: and projecting the downsampled image data according to each candidate projection angle to obtain an image projection result of each candidate projection angle.
In a possible implementation manner, the downsampling unit is specifically configured to: and performing interval sampling on the image to be corrected according to a first direction and a first interval to obtain the downsampled image data.
In a possible implementation manner, the downsampling unit is specifically configured to: and performing interval sampling on the image to be corrected according to a second direction and a second interval to obtain the downsampled image data.
In a possible implementation manner, the downsampling unit is specifically configured to: sampling the image to be corrected at intervals according to a first direction and a first interval to obtain first image sampling data; and performing interval sampling on the first image sampling data according to a second direction and a second interval to obtain the downsampled image data.
In a possible implementation manner, the downsampling unit is specifically configured to: sampling the image to be corrected at intervals according to a second direction and a second interval to obtain second image sampling data; and performing interval sampling on the second image sampling data according to the first direction and the first interval to obtain the downsampled image data.
In one possible embodiment, the inclination angle determining apparatus 900 further includes:
the segmentation unit is used for carrying out segmentation processing on the acquired image after acquiring the acquired image aiming at the object to be extracted to obtain N image slices; wherein N is a positive integer;
a slice angle acquisition unit for determining the image to be corrected according to an nth image slice; after acquiring the inclination angle of the image to be corrected, determining the inclination angle of the image to be corrected as the inclination angle of the nth image slice; wherein N is a positive integer, N is less than or equal to N;
and the image angle acquisition unit is used for determining the inclination angle of the acquired image according to the inclination angles of the N image slices.
In a possible embodiment, the image angle acquisition unit is specifically configured to: performing regression analysis processing on the inclination angles of the N image slices to obtain a regression function; determining a check function to be used according to the regression function; performing verification processing on the inclination angle of the nth image slice according to the to-be-used verification function to obtain a verification result of the nth image slice; wherein N is a positive integer, N is less than or equal to N; and when the verification results of the N image slices meet the second condition, carrying out preset statistical analysis processing on the inclination angles of the N image slices to obtain the inclination angles of the acquired images.
Further, an embodiment of the present application also provides a tilt angle determining apparatus, including: a processor, memory, system bus;
the processor and the memory are connected through the system bus;
the memory is for storing one or more programs, the one or more programs comprising instructions, which when executed by the processor, cause the processor to perform any of the methods of tilt angle determination described above.
Further, an embodiment of the present application further provides a computer readable storage medium, where instructions are stored, which when executed on a terminal device, cause the terminal device to perform any one of the implementation methods of the tilt angle determination method described above.
Further, the embodiment of the application also provides a computer program product, which when being run on a terminal device, causes the terminal device to execute any implementation method of the above-mentioned inclination angle determination method.
From the above description of embodiments, it will be apparent to those skilled in the art that all or part of the steps of the above described example methods may be implemented in software plus necessary general purpose hardware platforms. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network communication device such as a media gateway, etc.) to execute the method described in the embodiments or some parts of the embodiments of the present application.
It should be noted that, in the present description, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different manner from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
It is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A tilt angle determination method, the method comprising:
after acquiring an acquisition image aiming at an object to be extracted, preprocessing the acquisition image to obtain an image to be corrected; the preprocessing comprises content area boundary recognition processing, the preprocessing of the collected image to obtain the image to be corrected comprises the following steps:
projecting the acquired image according to the horizontal direction to obtain a horizontal projection result;
filtering the horizontal projection result to obtain a first projection filtering result; determining an upper boundary of the content area according to a projection position meeting a preset upper boundary condition in the first projection filtering result, wherein the preset upper boundary condition is a projection position with the highest position and the number of character projection points being higher than a first threshold value when projection is carried out according to the horizontal direction, and determining a lower boundary of the content area according to a projection position meeting a preset lower boundary condition in the first projection filtering result, and the preset lower boundary condition is a projection position with the lowest position and the number of character projection points being higher than the first threshold value when projection is carried out according to the horizontal direction;
Projecting the acquired image according to the vertical direction to obtain a vertical projection result;
filtering the vertical projection result to obtain a second projection filtering result; determining a left boundary of the content area according to the projection positions meeting a preset left boundary condition in the second projection filtering result, wherein the preset left boundary condition is a projection position which is the leftmost position when projection is carried out in the vertical direction and has the number of character projection points higher than a second threshold value, and determining a right boundary of the content area according to the projection positions meeting a preset right boundary condition in the second projection filtering result, and the preset right boundary condition is a projection position which is the rightmost position when projection is carried out in the vertical direction and has the number of character projection points higher than the second threshold value;
extracting the image to be corrected from the acquired image according to the upper boundary of the content area, the lower boundary of the content area, the left boundary of the content area and the right boundary of the content area;
after the image to be corrected is acquired, initializing a projection angle range and a projection angle interval;
determining at least one candidate projection angle according to the projection angle range and the projection angle interval;
Projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle;
selecting a target projection angle meeting a first condition from the at least one candidate projection angle according to an image projection result of the at least one candidate projection angle;
updating the projection angle range according to the target projection angle and the projection angle interval, updating the projection angle interval, and continuing to execute the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval until the inclination angle of the image to be corrected is determined according to the target projection angle when a preset stop condition is reached.
2. The method of claim 1, wherein updating the projection angle range based on the target projection angle and the projection angle interval comprises:
adding the target projection angle and the projection angle interval to obtain an upper projection angle limit;
subtracting the projection angle of the target from the projection angle interval to obtain a lower limit of the projection angle;
and updating the projection angle range according to the projection angle lower limit and the projection angle upper limit.
3. The method of claim 1, wherein the preprocessing further comprises at least one of binarization processing and edge extraction processing.
4. The method according to claim 1, wherein the method further comprises:
performing downsampling processing on the image to be corrected to obtain downsampled image data;
the step of projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle, comprising the following steps:
and projecting the downsampled image data according to each candidate projection angle to obtain an image projection result of each candidate projection angle.
5. The method of claim 4, wherein the determining of the downsampled image data comprises:
sampling the image to be corrected at intervals according to a first direction and a first interval to obtain the downsampled image data;
or,
the determining process of the downsampled image data includes:
sampling the image to be corrected at intervals according to a second direction and a second interval to obtain the downsampled image data;
or,
the determining process of the downsampled image data includes:
Sampling the image to be corrected at intervals according to a first direction and a first interval to obtain first image sampling data; sampling the first image sampling data at intervals according to a second direction and a second interval to obtain the downsampled image data;
or,
the determining process of the downsampled image data includes:
sampling the image to be corrected at intervals according to a second direction and a second interval to obtain second image sampling data; and performing interval sampling on the second image sampling data according to the first direction and the first interval to obtain the downsampled image data.
6. The method according to any one of claims 1-5, further comprising:
after acquiring an acquired image aiming at an object to be extracted, carrying out segmentation processing on the acquired image to obtain N image slices; wherein N is a positive integer;
determining the image to be corrected according to the nth image slice; after acquiring the inclination angle of the image to be corrected, determining the inclination angle of the image to be corrected as the inclination angle of the nth image slice; wherein N is a positive integer, N is less than or equal to N;
and determining the inclination angles of the acquired images according to the inclination angles of the N image slices.
7. The method of claim 6, wherein determining the tilt angle of the acquired image from the tilt angles of the N image slices comprises:
performing regression analysis processing on the inclination angles of the N image slices to obtain a regression function;
determining a check function to be used according to the regression function;
performing verification processing on the inclination angle of the nth image slice according to the to-be-used verification function to obtain a verification result of the nth image slice; wherein N is a positive integer, N is less than or equal to N;
and when the verification results of the N image slices meet the second condition, carrying out preset statistical analysis processing on the inclination angles of the N image slices to obtain the inclination angles of the acquired images.
8. A tilt angle determining apparatus, comprising:
the preprocessing unit is used for preprocessing the acquired image of the object to be extracted after acquiring the acquired image to obtain an image to be corrected;
the preprocessing includes content area boundary identification processing, and the preprocessing unit includes:
the first projection subunit is used for projecting the acquired image according to the horizontal direction to obtain a horizontal projection result;
The first determination subunit is used for carrying out filtering processing on the horizontal projection result to obtain a first projection filtering result; determining an upper boundary of the content area according to a projection position meeting a preset upper boundary condition in the first projection filtering result, wherein the preset upper boundary condition is a projection position with the highest position and the number of character projection points being higher than a first threshold value when projection is carried out according to the horizontal direction, and determining a lower boundary of the content area according to a projection position meeting a preset lower boundary condition in the first projection filtering result, and the preset lower boundary condition is a projection position with the lowest position and the number of character projection points being higher than the first threshold value when projection is carried out according to the horizontal direction;
the second projection subunit is used for projecting the acquired image according to the vertical direction to obtain a vertical projection result;
the second determining subunit is used for carrying out filtering processing on the vertical projection result to obtain a second projection filtering result; determining a left boundary of the content area according to the projection positions meeting a preset left boundary condition in the second projection filtering result, wherein the preset left boundary condition is a projection position which is the leftmost position when projection is carried out in the vertical direction and has the number of character projection points higher than a second threshold value, and determining a right boundary of the content area according to the projection positions meeting a preset right boundary condition in the second projection filtering result, and the preset right boundary condition is a projection position which is the rightmost position when projection is carried out in the vertical direction and has the number of character projection points higher than the second threshold value;
An image extraction subunit, configured to extract the image to be corrected from the acquired image according to the upper boundary of the content area, the lower boundary of the content area, the left boundary of the content area, and the right boundary of the content area;
the initialization unit is used for initializing a projection angle range and a projection angle interval after the image to be corrected is acquired;
a determining unit, configured to determine at least one candidate projection angle according to the projection angle range and the projection angle interval;
the projection unit is used for projecting the image to be corrected according to each candidate projection angle to obtain an image projection result of each candidate projection angle;
a screening unit, configured to select, according to an image projection result of the at least one candidate projection angle, a target projection angle that satisfies a first condition from the at least one candidate projection angle;
and the updating unit is used for updating the projection angle range according to the target projection angle and the projection angle interval, updating the projection angle interval and returning to the determining unit to continue to execute the step of determining at least one candidate projection angle according to the projection angle range and the projection angle interval until the inclination angle of the image to be corrected is determined according to the target projection angle when a preset stop condition is reached.
9. An apparatus, the apparatus comprising: a processor, memory, system bus;
the processor and the memory are connected through the system bus;
the memory is for storing one or more programs, the one or more programs comprising instructions, which when executed by the processor, cause the processor to perform the method of any of claims 1-7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein instructions, which when run on a terminal device, cause the terminal device to perform the method of any of claims 1 to 7.
CN202111144273.XA 2021-09-28 2021-09-28 Inclination angle determining method and related equipment thereof Active CN113852730B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111144273.XA CN113852730B (en) 2021-09-28 2021-09-28 Inclination angle determining method and related equipment thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111144273.XA CN113852730B (en) 2021-09-28 2021-09-28 Inclination angle determining method and related equipment thereof

Publications (2)

Publication Number Publication Date
CN113852730A CN113852730A (en) 2021-12-28
CN113852730B true CN113852730B (en) 2023-12-01

Family

ID=78980402

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111144273.XA Active CN113852730B (en) 2021-09-28 2021-09-28 Inclination angle determining method and related equipment thereof

Country Status (1)

Country Link
CN (1) CN113852730B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6282326B1 (en) * 1998-12-14 2001-08-28 Eastman Kodak Company Artifact removal technique for skew corrected images
CN101833648A (en) * 2009-03-13 2010-09-15 汉王科技股份有限公司 Method for correcting text image
CN105279506A (en) * 2015-09-29 2016-01-27 大连民族大学 Manchu script central axis positioning method
CN106447615A (en) * 2016-08-02 2017-02-22 浪潮软件股份有限公司 Tilt correction method for scanning document image
CN112101351A (en) * 2020-09-07 2020-12-18 凌云光技术股份有限公司 Projection-based text line rotation correction method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9288362B2 (en) * 2014-02-03 2016-03-15 King Fahd University Of Petroleum And Minerals Technique for skew detection of printed arabic documents

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6282326B1 (en) * 1998-12-14 2001-08-28 Eastman Kodak Company Artifact removal technique for skew corrected images
CN101833648A (en) * 2009-03-13 2010-09-15 汉王科技股份有限公司 Method for correcting text image
CN105279506A (en) * 2015-09-29 2016-01-27 大连民族大学 Manchu script central axis positioning method
CN106447615A (en) * 2016-08-02 2017-02-22 浪潮软件股份有限公司 Tilt correction method for scanning document image
CN112101351A (en) * 2020-09-07 2020-12-18 凌云光技术股份有限公司 Projection-based text line rotation correction method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Susanto Ronny.Skew detection based on vertical projection in latin character recognition of text document image. International Journal of Engineering & Technology.2018,全文. *
程立.基于投影轮廓的文本图像倾斜检测.中国图象图形学报.2015,第1-2节. *

Also Published As

Publication number Publication date
CN113852730A (en) 2021-12-28

Similar Documents

Publication Publication Date Title
US8023741B2 (en) Methods and systems for detecting numerals in a digital image
JP5616308B2 (en) Document modification detection method by character comparison using character shape feature
CN105046200B (en) Electronic paper marking method based on straight line detection
CN113569863B (en) Document checking method, system, electronic equipment and storage medium
CN111626292B (en) Text recognition method of building indication mark based on deep learning technology
CN112288693A (en) Round hole detection method and device, electronic equipment and storage medium
US11704476B2 (en) Text line normalization systems and methods
CN111695540A (en) Video frame identification method, video frame cutting device, electronic equipment and medium
CN115346227B (en) Method for vectorizing electronic file based on layout file
CN114255468A (en) Handwriting recognition method and related equipment thereof
BE1026159B1 (en) IMAGE PROCESSING SYSTEM AND IMAGE PROCESSING METHOD
CN111652140A (en) Method, device, equipment and medium for accurately segmenting questions based on deep learning
CN114495141A (en) Document paragraph position extraction method, electronic equipment and storage medium
CN104077562B (en) A kind of scanning direction determination methods of test paper
CN113852730B (en) Inclination angle determining method and related equipment thereof
CN115083008A (en) Moving object detection method, device, equipment and storage medium
Boiangiu et al. Handwritten documents text line segmentation based on information energy
CN112149654B (en) Invoice text information identification method based on deep learning
CN113887375A (en) Text recognition method, device, equipment and storage medium
CN112861861A (en) Method and device for identifying nixie tube text and electronic equipment
CN114648751A (en) Method, device, terminal and storage medium for processing video subtitles
CN112085683A (en) Depth map reliability detection method in significance detection
CN115631493B (en) Text region determining method, system and related device
CN113627320B (en) Engineering drawing comparison device and method based on computer vision
CN115984316B (en) Industrial image edge extraction method and device for complex environment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant