CN110598575B - Form layout analysis and extraction method and related device - Google Patents

Form layout analysis and extraction method and related device Download PDF

Info

Publication number
CN110598575B
CN110598575B CN201910773607.6A CN201910773607A CN110598575B CN 110598575 B CN110598575 B CN 110598575B CN 201910773607 A CN201910773607 A CN 201910773607A CN 110598575 B CN110598575 B CN 110598575B
Authority
CN
China
Prior art keywords
chains
line
picture
single communication
chain
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
CN201910773607.6A
Other languages
Chinese (zh)
Other versions
CN110598575A (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 CN201910773607.6A priority Critical patent/CN110598575B/en
Publication of CN110598575A publication Critical patent/CN110598575A/en
Application granted granted Critical
Publication of CN110598575B publication Critical patent/CN110598575B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/40Document-oriented image-based pattern recognition
    • G06V30/41Analysis of document content
    • G06V30/413Classification of content, e.g. text, photographs or tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/40Document-oriented image-based pattern recognition
    • G06V30/41Analysis of document content
    • G06V30/414Extracting the geometrical structure, e.g. layout tree; Block segmentation, e.g. bounding boxes for graphics or text
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)

Abstract

The embodiment of the application discloses a form layout analysis and extraction method and a related device, wherein the method comprises the following steps: acquiring a picture containing a form layout; determining a plurality of single-connected chain sets which accord with table grid line constraint conditions in the picture, wherein each single-connected chain set in the plurality of single-connected chain sets comprises at least one single-connected chain, the single-connected chains correspond to transverse or vertical short line segments in the picture, and the table line constraint conditions refer to that the directions of the single-connected chains are the same and are in the same straight line; generating reference table grid lines corresponding to each single communication chain set according to at least one single communication chain contained in each single communication chain set; and generating a table layout of the picture according to a plurality of reference table lines corresponding to the plurality of single connected chain sets. The method and the device are beneficial to improving the efficiency and the accuracy of the extraction of the form layout.

Description

Form layout analysis and extraction method and related device
Technical Field
The application relates to the technical field of computers, in particular to a form layout analysis and extraction method and a related device.
Background
In recent years, with the development of information technology, in an informatization system of industries such as finance, judicial, social security, education, medical treatment and the like, scanning and information structuring identification are often required to be performed on existing paper document materials, automatic identification and layout analysis extraction are required to be performed on a form in the information system, and otherwise, subsequent structuring processing and layout reprocessing processing cannot be performed on a character identification result in the form. The existing method mainly detects a single connected chain through a DSCC algorithm, and further performs layout analysis on the table. However, when the cell is small and the text is large, the cell is erroneously cut, and the cell position is determined by adopting the mode of connecting the intersection points after the grid lines are detected, so that the method is time-consuming, is excessively dependent on the intersection points, easily causes the cell to be erroneously detected, has the problems of high information extraction cost and low efficiency, and has the problem of smaller application range because different extraction templates are required to be configured for the webpages with different structures.
Disclosure of Invention
The embodiment of the application provides a method and a related device for analyzing and extracting form layout, so as to improve the efficiency and accuracy of the equipment for analyzing and extracting form layout.
In a first aspect, an embodiment of the present application provides a method for analyzing and extracting a form layout, including:
acquiring a picture containing a form layout;
determining a plurality of single-connected chain sets in the picture, wherein the single-connected chain sets conform to a table line constraint condition, each single-connected chain set in the plurality of single-connected chain sets comprises at least one single-connected chain, the single-connected chains correspond to a transverse or vertical short line section in the picture, and the table line constraint condition means that the directions of the single-connected chains are the same and are in the same straight line;
generating reference table grid lines corresponding to each single communication chain set according to at least one single communication chain contained in each single communication chain set;
and generating the table layout of the picture according to a plurality of reference table lines corresponding to the plurality of single communication chain sets.
In a second aspect, an embodiment of the present application provides a form layout analysis and extraction apparatus, including a processing unit and a communication unit, where,
the processing unit is used for acquiring pictures containing form layouts through the communication unit; determining a plurality of single-connected chain sets in the picture, wherein the single-connected chain sets conform to a table grid line constraint condition, each single-connected chain set in the plurality of single-connected chain sets comprises at least one single-connected chain, the single-connected chains correspond to a transverse or vertical short line segment in the picture, and the table line constraint condition means that the directions of the single-connected chains are the same and are in the same straight line; generating reference table grid lines corresponding to each single communication chain set according to at least one single communication chain contained in each single communication chain set; and generating the table layout of the picture according to a plurality of reference table lines corresponding to the plurality of single communication chain sets.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor, the programs including instructions for performing steps in any of the methods of the first aspect of the embodiments of the present application.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium, where the computer-readable storage medium stores a computer program for electronic data exchange, where the computer program causes a computer to perform some or all of the steps as described in any of the methods of the first aspect of the embodiments of the present application.
In a fifth aspect, embodiments of the present application provide a computer program product, wherein the computer program product comprises a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps described in any of the methods of the first aspect of embodiments of the present application. The computer program product may be a software installation package.
It can be seen that in the embodiment of the present application, after a picture including a table layout is obtained, a plurality of single-connected chain sets meeting the constraint conditions of table grid lines in the picture may be determined, and then, according to at least one single-connected chain included in each single-connected chain set, reference table grid lines corresponding to each single-connected chain set are generated; finally, generating the table layout of the picture according to a plurality of reference table grid lines corresponding to the plurality of single-connected chain sets, wherein the reference table grid lines generated by the plurality of single-connected chain sets meeting the constraint conditions of the table grid lines in the picture are determined, so that the table layout is obtained, the complexity of table detection is reduced, and the efficiency and the accuracy of extracting the table layout are improved.
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 below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of an electronic device according to an embodiment of the present application;
fig. 2 is a flow chart of a method for analyzing and extracting form layout according to an embodiment of the present application;
FIG. 3a (1) is a schematic diagram of an extraction of a lateral single connected chain provided in an embodiment of the present application;
FIG. 3a (2) is a schematic diagram of an extraction vertical single connectivity chain provided in an embodiment of the present application;
FIG. 3b is a schematic diagram of a single strand of a screening assay according to an embodiment of the present application;
FIG. 3c is a schematic diagram of a linear single-communication-chain extraction provided in an embodiment of the present application;
FIG. 3d is a schematic diagram of extracting single connected chains according to reference grid lines provided in an embodiment of the present application;
FIG. 4 is a schematic diagram of a single connectivity chain connection provided in an embodiment of the present application;
Fig. 5a is a schematic diagram of misjudgment of a form line due to oversized text according to an embodiment of the present application;
fig. 5b is a schematic diagram of misjudging a form line due to a square stamp according to an embodiment of the present application;
FIG. 5c is a schematic diagram of another misjudgment of a form line due to a square stamp according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 7 is a functional unit block diagram of a form layout analysis and extraction device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
As shown in fig. 1, fig. 1 is a schematic diagram of an electronic device 100, where the electronic device 100 includes a picture obtaining device 110 and a table extracting device 120, where the picture obtaining device 110 obtains a picture including a table layout, and the table extracting device 120 is used to extract a single communication chain and process the single communication chain to obtain the table layout. The electronic device according to the embodiments of the present application may include various handheld devices, vehicle-mounted devices, wearable devices, computing devices, or other processing devices connected to a wireless modem, and various forms of User Equipment (UE), mobile Station (MS), terminal devices (terminal devices), and so on.
At present, the form layout is mainly characterized in that after a single Connected Chain is detected through DSCC (Directional Single-Connected Chain), the single Connected Chain which is possibly a form line is screened out through the length, then the form line is reduced by connecting the single Connected Chain, and finally the position of a cell is determined through the intersection point position of the form line, so that the form layout is analyzed. However, this method is time-consuming when there are many detected straight lines, and easily causes the cells to be erroneously detected.
Based on this, the embodiment of the present application proposes a form layout analysis and extraction method to solve the above problem, and the following detailed description of the embodiment of the present application is provided.
Referring to fig. 2, fig. 2 is a flow chart of a method for analyzing and extracting a form layout, which is applied to the electronic device shown in fig. 1, according to the embodiment of the present application, as shown in the fig. 1, the method for analyzing and extracting a form layout includes:
s201, obtaining a picture containing a form layout;
the picture of the form layout may be any picture given by the user and containing the form, and the picture may be a picture obtained by shooting, scanning or any other method.
S202, determining a plurality of single-connected chain sets in the picture, wherein the single-connected chain sets conform to a table grid line constraint condition, each single-connected chain set in the plurality of single-connected chain sets comprises at least one single-connected chain, the single-connected chains correspond to a transverse or vertical short line segment in the picture, and the table line constraint condition means that the directions of the single-connected chains are the same and are in the same straight line;
The single communication chain is divided into a transverse section and a vertical section, and the transverse section or the vertical section corresponds to characters, seals, table lines and the like in the picture. For example, the lateral single-pass chain may be constituted by image runs of 1 pixel in lateral width, and each image run is flanked by and only one run communicates with, except for two runs at the head and tail ends. Each single-connected-chain set of the plurality of single-connected-chain sets includes one or more single connected chains corresponding to each table line.
In a specific implementation, extracting all single connected chains in the picture, screening at least one single connected chain belonging to the same table line from all the single connected chains, and sequencing the at least one single connected chain from left to right or from top to bottom.
S203, generating reference table grid lines corresponding to each single communication chain set according to at least one single communication chain contained in each single communication chain set;
wherein each set of single connected chains includes one or more single connected chains belonging to the same table line.
In a specific implementation, the plurality of single communication chains arranged in each single communication chain set are connected from left to right or from top to bottom to obtain the reference table grid lines.
S204, generating the table layout of the picture according to a plurality of reference table lines corresponding to the plurality of single communication chain sets.
The reference table grid lines are straight lines obtained by connecting each single communication chain in each single communication chain set. And obtaining a reference table by connecting and combining the reference table lines, and performing illegal table filtering on the reference table to obtain the table layout of the picture.
It can be seen that in the embodiment of the present application, after a picture including a table layout is obtained, a plurality of single-connected chain sets meeting the constraint conditions of table grid lines in the picture may be determined, and then, according to at least one single-connected chain included in each single-connected chain set, reference table grid lines corresponding to each single-connected chain set are generated; finally, generating the table layout of the picture according to a plurality of reference table grid lines corresponding to the plurality of single-connected chain sets, wherein the reference table grid lines generated by the plurality of single-connected chain sets meeting the constraint conditions of the table grid lines in the picture are determined, so that the table layout is obtained, the complexity of table detection is reduced, and the efficiency and the accuracy of extracting the table layout are improved.
In one possible example, the determining the plurality of single connected chain sets in the picture that meet the table grid line constraint includes: detecting and extracting all single connected chains in the picture; screening a plurality of single communication chains meeting preset conditions in all the single communication chains; dividing the single communication chains into a plurality of single communication chain sets according to table line constraint conditions, wherein the table line constraint conditions are identical in direction and are in the same straight line.
All single communication chains in the picture are detected and extracted, all transverse single communication chains and all vertical single communication chains can be extracted through a DSCC algorithm, the directional single communication chains are combined under certain constraint conditions, and a straight line can be rapidly and accurately extracted. And after extracting all the single communication chains, screening a plurality of single communication chains meeting the requirements according to preset conditions, and sequentially sorting the screened single communication chains transversely and vertically to determine a single communication chain set belonging to the same table line.
In specific implementation, as shown in fig. 3a (1), all the horizontal single-connected chains are extracted according to the picture, as shown in fig. 3a (2), all the vertical single-connected chains are extracted according to the picture, then the extracted horizontal single-connected chains and vertical single-connected chains are screened, single-connected chains with excessively short lengths, non-straight lines and the like are removed, and then the single-connected chains belonging to the same table line are divided into a single-connected chain set.
Therefore, a plurality of single-connected chain sets meeting the constraint conditions of the table grid lines can be obtained by screening and sequencing all the extracted single-connected chains, so that the detection efficiency and accuracy of the single-connected chains of the table grid lines are improved, and the extraction speed of the table layout is accelerated.
In one possible example, the screening the single-connected chains that meet the preset condition from among the all single-connected chains includes: acquiring an adaptive length threshold of the form layout in the picture; comparing each single communication chain in all the single communication chains with the self-adaptive length threshold, and eliminating the single communication chains with the length smaller than the self-adaptive length threshold to obtain single communication chains conforming to the self-adaptive length threshold; removing nonlinear single communication chains in the single communication chains meeting the self-adaptive length threshold to obtain single communication chains meeting the linear requirement; calculating the inclination angle of the single communication chain meeting the linear requirement, and marking the maximum angle as the main direction of the whole table; eliminating single communication chains of which the difference value between the inclination angle and the main direction exceeds a preset angle threshold value; and carrying out inclination correction on the single communication chains meeting the preset angle threshold according to the main direction to obtain a plurality of single communication chains meeting the preset condition.
The adaptive length threshold of the form layout in the picture can be obtained by an OTSU Ojin method, and the single connected chain with the too small length is removed according to the adaptive length threshold, wherein the threshold can be obtained through priori knowledge. The picture comprises an image foreground (namely a table) and a background, the proportion of the number of pixels belonging to the foreground to the whole image is marked as p, the proportion of the number of pixels of the background to the whole image is marked as q, and the length threshold of the single connected chain is determined according to the foreground proportion. For example, when the image size is long l×wide W and the foreground ratio is 50%, the lateral length threshold is greater than l×50% by 15%, and the vertical length threshold is w×50% by 20%, and single connected chains smaller than the length threshold are eliminated. And then, a straight line fitting method can be adopted, nonlinear single-connected chains are removed by judging the variance, finally, the inclination angle of each single-connected chain is calculated, the largest inclination angle is taken as the main direction of the extracted form layout, the single-connected chains with the inclination angle different from the main direction by more than a set threshold value are removed, wherein the set threshold value can be obtained through priori knowledge, and finally, the inclination correction is carried out on the picture by the main direction angle of the form.
In a specific implementation, the sizes of the scanned images are different, the sizes of the tables are also different, an adaptive threshold is obtained through an OTSU method, as shown in fig. 3b, fig. 3b is a schematic diagram of a single-connected chain screening method provided in an embodiment of the present application, a single-connected chain with a too small length is removed according to the adaptive threshold, as shown in fig. 3c, fig. 3c is a schematic diagram of straight-line single-connected chain extraction provided in an embodiment of the present application, a straight-line fitting method is adopted to remove a non-straight-line single-connected chain by determining the variance, for example, for a single-connected chain, each pixel point coordinate of the single-connected chain is determined, a straight line is determined according to each pixel point coordinate, so that the straight line passes through the pixel point coordinate of the single-connected chain as much as possible, the variance between the pixel point coordinate of the single-connected chain and the straight line is minimum, and when the variance is greater than a preset variance threshold, the single-connected chain is determined to be non-straight-line and removed. And calculating the inclination angle of the single connected chain after the removal, removing the single connected chain in the direction of the non-table grid line, such as an inclined straight line and the like, and performing inclination correction on the picture.
Therefore, the single communication chain set meeting the preset conditions can be screened based on the self-adaptive length threshold value, the inclination angle and the like of the single communication chain, so that the single communication chain with too short length, non-straight line and inclined direction is effectively removed, and the accuracy and the efficiency of the form layout extraction are improved.
In one possible example, the partitioning of the plurality of single connected chains into a plurality of single connected chain sets according to a table grid line constraint includes: acquiring the vertical difference value of any two transverse single-communication chains in the plurality of single-communication chains; when the vertical difference value is smaller than a first preset threshold value, determining that any two transverse single communication chains are the same transverse grid line; all the transverse single communication chains on the same transverse table line are subjected to sorting treatment from left to right; or, acquiring the transverse difference value of any two vertical single communication chains in the plurality of single communication chains; when the transverse difference value is smaller than a second preset threshold value, determining that any two vertical single communication chains are the same vertical table grid line; all vertical single communication chains on the same vertical form line are subjected to sorting treatment from top to bottom; and determining a plurality of single-connected chain sets according to the ordered single-connected chains, wherein each single-connected chain set corresponds to the single-connected chains of one table line.
Wherein each table line corresponds to a single connected chain set, and a plurality of table lines correspond to a plurality of single connected chain sets. And acquiring the vertical difference value of any two transverse single-communication chains, and determining that the two single-communication chains belong to the same transverse grid line when the vertical difference value is smaller than a preset threshold value. And acquiring a transverse difference value of any two transverse single communication chains, and determining that the two vertical single communication chains belong to the same table line when the transverse difference value is smaller than a preset threshold value. And sequencing the single connected chains belonging to the same transverse grid line from left to right, and sequencing the single connected chains belonging to the same vertical grid line from top to bottom.
Therefore, whether the two single connected chains belong to the same table line can be determined based on calculation of the difference value between any two same-direction single connected chains, and the single connected chains belonging to the same table line are ordered to obtain a plurality of single connected chain sets meeting the table constraint conditions, so that the accuracy of extracting the table grid lines and the table layout is improved.
In one possible example, the determining the plurality of single connected chain sets in the picture that meet the table grid line constraint includes: extracting all single communication chains in the picture; determining grid line reference points for each single connected chain in the all single connected chains; determining a longitudinal reference grid line and a transverse reference grid line of each single communication chain in the picture by taking the grid line reference points as datum points; and determining a single connected chain set of a plurality of single connected chains which are completely positioned in the same reference grid line.
Any point on each single communication chain in the single communication chains can be determined to be a grid line reference point, the grid line reference point is taken as a datum point to serve as a longitudinal reference grid line and a transverse reference grid line, all transverse single communication chains in the same transverse reference grid line are taken as a single communication chain set, all vertical single communication chains in the same longitudinal reference grid line are taken as a single communication chain set, and a plurality of single communication chain sets corresponding to the multiple reference grid lines are obtained.
Therefore, the reference grid lines can be generated based on each single connected chain, and a plurality of single connected chain sets which are positioned on the same reference grid line are determined according to the reference grid lines and the single connected chains, so that the efficiency of extracting the table layout is improved.
In one possible example, the determining the set of single connected chains of the plurality of single connected chains that are all in the same reference grid line includes: determining a plurality of straight single communication chains in all single communication chains; determining at least one single communication chain in the same reference grid line according to the reference grid line of each straight single communication chain in the plurality of straight single communication chains; and sequencing the at least one single communication chain to obtain the plurality of single communication chain sets.
Wherein the reference grid lines are auxiliary tool lines made for each single connected chain that determine a set of multiple single connected chains. Determining longitudinal reference grid lines and transverse reference grid lines of each single communication chain according to the extracted single communication chains, and determining that at least one single communication chain overlapped with the transverse reference grid lines is positioned in the same transverse table grid line when the transverse reference grid lines of the transverse single communication chains are detected to be overlapped; when the coincidence of the longitudinal reference grid lines of the vertical single-connected chains is detected, determining that at least one single-connected chain coincident with the longitudinal reference grid lines is positioned at the same vertical grid line. And determining whether the single communication chain is positioned on the reference grid line according to the single communication chain and the corresponding reference grid line, if so, determining that the single communication chain is a linear single communication chain, and if not, determining that the single communication chain is a nonlinear single communication chain, and eliminating the nonlinear single communication chain. And determining the transverse reference grid lines of a plurality of transverse single-communication chains in the linear single-communication chains, and if the transverse reference grid lines of the transverse single-communication chains are in the same straight line, determining that the transverse single-communication chains belong to the same reference grid line to obtain a linear single-communication chain set. And eliminating the single communication chains with the length smaller than a preset threshold value in the single communication chains overlapped with the transverse reference line or the vertical reference line in the straight single communication chain set to obtain a plurality of single communication chain sets. As shown in fig. 3d, the dashed line in fig. 3d is a reference grid line, one point a of the single transverse communication chain H1 is taken as the reference grid line, the single transverse communication chain H1 coincides with the reference grid line, the point b of the single transverse communication chain H2 is taken as the reference grid line, the single transverse communication chain H2 coincides with the reference grid line, and the transverse reference lines of the single transverse communication chains H1 and H2 coincide, so that it can be determined that the single transverse communication chains H1 and H2 are straight lines and are on the same straight line, i.e. belong to the same transverse table grid line. The vertical single communication chain S1 takes one point c as a reference grid line, the single communication chain S1 is overlapped with the longitudinal reference grid line, the vertical single communication chain S2 takes the point d as a reference grid line, the single communication chain S2 is overlapped with the longitudinal reference grid line, and the vertical reference lines of the single communication chains S1 and S2 are overlapped, so that the single communication chains S1 and S2 can be judged to be straight lines and on the same straight line, namely, the single communication chains belong to the same vertical table grid line. Then the single connected chains belonging to the same table line are divided into a single connected chain set, and the single connected chains which do not coincide with the horizontal reference line or the vertical reference line are determined as non-linear single connected chains and eliminated.
Therefore, the nonlinear single-connected chain can be removed based on the reference grid lines of the single-connected chain, a single-connected chain set is obtained, and the accuracy of extracting the form layout is improved.
In one possible example, generating the form layout of the picture according to a plurality of reference form lines corresponding to the plurality of single connected chain sets includes: determining a reference table according to a plurality of reference table grid lines corresponding to the plurality of single communication chain sets; and filtering an illegal table according to an illegal table source and the reference table to obtain the table layout of the picture, wherein the illegal table is generated by the illegal table source, and the illegal table source comprises straight lines except for a table line in the picture which leads to erroneous judgment of the reference table line.
As shown in fig. 4, fig. 4 is a schematic diagram of single-connected chain connection provided in the embodiment of the present application, at least one single-connected chain included in each single-connected chain set is connected to obtain a reference table line, and a plurality of reference table lines obtained according to a plurality of single-connected chain sets are connected to obtain a reference table. The step of connecting at least one single communication chain included in each single communication chain set to obtain reference table grid lines comprises the following steps: judging whether a plurality of single communication chains on the same table line are broken lines or not; if yes, carrying out broken line connection on the plurality of single communication chains to obtain reference table grid lines; the broken line may be a broken line caused by the fact that the table grid lines are not printed clearly in the image, or the table grid lines are covered by other images.
In a specific implementation, in order to extract a table layout more accurately, after a reference table is generated, post-processing is performed on the reference table, illegal tables are filtered, and the table layout is extracted. The illegal form comprises a form formed by misjudgment of connecting lines due to a square seal or a font which is too large.
Therefore, the reference table can be generated based on the reference table line, and illegal tables in the reference table are filtered, so that the accuracy of extracting the table layout is improved.
In one possible example, the filtering the illegal table according to the illegal table source and the reference table to obtain the table layout of the picture includes: identifying the colors of all the reference table grid lines; identifying the straight lines except the table lines according to the colors, and filtering out erroneous judgment reference table lines to obtain the table layout of the picture; or, obtaining the line width of the reference table grid line to obtain a line width set; judging whether line widths larger than a preset width threshold exist in the line width set; if yes, filtering out reference table grid lines corresponding to the line width larger than a preset width threshold value, and obtaining the table layout of the picture; or, identifying morphological characteristics of the form layout; filtering out reference table grid lines corresponding to the reference table with the morphological characteristics not conforming to the preset morphological rules, and obtaining the table layout of the picture; or detecting straight lines except table lines in the picture through an image processing technology; calculating a horizontal pixel or a vertical pixel of the straight line; calculating the pixel overlapping degree of the straight line and all the reference table grid lines according to the transverse pixels or the vertical pixels; obtaining an accumulated value of the overlapping degree of each reference table grid line according to the pixel overlapping degree; and when judging that the accumulated value is greater than a preset text overlapping threshold, removing the reference table grid line corresponding to the straight line to obtain the table layout of the picture.
The method comprises the steps of identifying straight lines except table lines in the picture, wherein the straight lines except table lines lead to erroneous judgment of the reference table lines according to colors of all reference table lines, for example, the common seal colors are red or blue, and the table lines formed by the square seal can be removed by the seal colors; in practice, the width of the frame line of the square seal is far greater than the width of a common table grid line, and the table line far greater than the preset width threshold value of the table line can be removed by detecting the width of the table line of the table layout; form lines of a reference form which do not conform to form morphological features can also be removed through form morphological features of the form; the illegal form generated by the square seal can be removed by any one of the methods.
The illegal table can be removed according to the pixel overlapping degree of the straight line except the table line and the table line. For example, firstly, characters in the picture can be extracted in a connected domain mode during pretreatment; and then sequentially carrying out pixel overlapping degree calculation on each character and all detected table lines, wherein the pixel overlapping degree is the pixel overlapping degree as long as the pixel overlapping degree is the number of pixel points between the pixel points occupied by strokes in the characters and the table lines. And then, for each form line, obtaining an accumulated value of the overlapping degree of the form line, and finally determining a reference form line with the accumulated value of the overlapping degree larger than a preset character overlapping threshold value as a form line which is misidentified due to overlarge characters, and rejecting the form line.
In a specific implementation, as shown in fig. 5a, fig. 5a is a schematic diagram of misjudging a table line due to overlarge text, where when the text "eleven" in the diagram is overlarge, the horizontal sum "one" of the text "eleven" will be misjudged as a horizontal table line, and the vertical sum "ten" will be misjudged as a vertical table line. For oversized characters, preprocessing the picture to extract the characters 'eleven', performing overlapping degree calculation on the pixel points occupied by the strokes 'horizontal' in the characters and the pixel points of the misjudged horizontal table lines to obtain a horizontal table line overlapping degree accumulated value, performing overlapping degree calculation on the pixel points occupied by the strokes 'vertical' and the pixel points of the misjudged vertical table lines to obtain a vertical table line overlapping degree accumulated value, determining the vertical table line overlapping degree accumulated value as a table line misjudged due to oversized characters when the accumulated value is judged to be larger than a preset character overlapping threshold value, and eliminating the misjudged table line; and determining the rule as legal table grid lines when the accumulated value is judged to be smaller than the preset text overlap threshold.
Therefore, the speed of extracting the form layout can be increased and the accuracy of extracting the form layout can be improved by removing illegal forms caused by straight lines except form lines in the pictures.
In one possible example, the filtering the reference table grid lines corresponding to the reference table in which the morphological feature does not conform to the preset morphological rule includes: determining corner points of the table through the intersection point forms of the horizontal reference table grid lines and the vertical reference table grid lines; determining the number of unit tables in the reference table according to the corner points; determining morphological characteristics of the table according to the number of the unit tables, wherein the morphological characteristics comprise the number of corner points and the number of intersection points; and filtering out the reference table grid lines corresponding to the reference table which does not accord with the preset morphology rule according to the morphology features of the table.
The number of the tables is obtained by the number of intersection points of the horizontal table grid lines and the vertical table grid lines of the table layout, that is, by judging whether the intersection points are corner points of the tables, as shown in fig. 5b, fig. 5b is a schematic diagram of misjudgment of the table lines caused by the square seal, in the diagram, the intersection point 1 is an intersection point of the horizontal table grid lines X1 and the vertical table grid lines Y1, no pixel point exists on the left side and the upper side of the intersection point 1, and the intersection point 1 is a corner point of the upper left corner of the table to which the horizontal table grid lines X1 and the vertical table grid lines Y1 belong. The number of independent tables is determined by determining the number of corner points, for example, as shown in fig. 5b, where there are 8 corner points, two independent tables are detected. The legal form has at least two opposite form peripheral edges with intersection points, and the intersection points do not include corner points, for example, as shown in fig. 5b, the form generated by the square seal in the figure has intersection points on two edges, namely intersection point 2 and intersection point 3, but the two edges are adjacent edges instead of opposite edges, the form generated by the square seal is determined to be an illegal form, and corresponding form lines are removed.
In a specific implementation, there may be a situation that the square seal is located inside the table, as shown in fig. 5c, fig. 5c is another schematic diagram of misjudgment of the table line caused by the square seal provided in the embodiment of the present application, by detecting the number of intersection points of the table, determining the number of corner points according to the number of intersection points, and then rejecting the table line generated by the square seal according to the intersection points 4 and 5 and the morphological characteristics of the table. Or after the number of the corner points is determined, determining the coordinates of the corner points, judging whether the corner points are in each cell of the form layout according to the coordinates of the corner points, if so, determining the morphological characteristics of the cells with the corner points, and if the morphological characteristics do not accord with the preset morphological rules, eliminating the form which does not accord with the morphological characteristics of the form.
Therefore, illegal tables generated by the square seal can be removed in various modes, so that the speed of extracting the table layout is increased, and the accuracy of extracting the table layout is improved.
The present application is described in detail below in connection with a few examples.
Referring to fig. 6, in accordance with the embodiment shown in fig. 2, fig. 6 is a schematic structural diagram of an electronic device 600 provided in the embodiment of the present application, as shown in the fig. 1, the electronic device 600 includes an application processor 610, a memory 620, a communication interface 630, and one or more programs 621, where the one or more programs 621 are stored in the memory 620 and configured to be executed by the application processor 610, and the one or more programs 621 include instructions for executing the following steps;
Acquiring a picture containing a form layout;
determining a plurality of single-connected chain sets in the picture, wherein the single-connected chain sets conform to a table line constraint condition, each single-connected chain set in the plurality of single-connected chain sets comprises at least one single-connected chain, the single-connected chains correspond to a transverse or vertical short line section in the picture, and the table line constraint condition means that the directions of the single-connected chains are the same and are in the same straight line;
generating reference table grid lines corresponding to each single communication chain set according to at least one single communication chain contained in each single communication chain set;
and generating the table layout of the picture according to a plurality of reference table lines corresponding to the plurality of single communication chain sets.
It can be seen that in the embodiment of the present application, after a picture including a table layout is obtained, a plurality of single-connected chain sets meeting the constraint conditions of table grid lines in the picture may be determined, and then, according to at least one single-connected chain included in each single-connected chain set, reference table grid lines corresponding to each single-connected chain set are generated; finally, generating the table layout of the picture according to a plurality of reference table grid lines corresponding to the plurality of single-connected chain sets, wherein the reference table grid lines generated by the plurality of single-connected chain sets meeting the constraint conditions of the table grid lines in the picture are determined, so that the table layout is obtained, the complexity of table detection is reduced, and the efficiency and the accuracy of extracting the table layout are improved.
In one possible example, in the determining the plurality of sets of single connected chains in the picture that meet the table grid line constraint, the instructions in the program are specifically configured to: detecting and extracting all single connected chains in the picture; screening a plurality of single communication chains meeting preset conditions in all the single communication chains; dividing the single communication chains into a plurality of single communication chain sets according to the grid line constraint condition.
In one possible example, in the aspect of screening the plurality of single-connected chains meeting the preset condition among all the single-connected chains, the instructions in the program are specifically configured to perform the following operations: acquiring an adaptive length threshold of the form layout in the picture; comparing each single communication chain in all the single communication chains with the self-adaptive length threshold, and eliminating the single communication chains with the length smaller than the self-adaptive length threshold to obtain single communication chains conforming to the self-adaptive length threshold; removing nonlinear single communication chains in the single communication chains meeting the self-adaptive length threshold to obtain single communication chains meeting the linear requirement; calculating the inclination angle of the single communication chain meeting the linear requirement, and marking the maximum angle as the main direction of the whole table; eliminating single communication chains of which the difference value between the inclination angle and the main direction exceeds a preset angle threshold value; and carrying out inclination correction on the single communication chains meeting the preset angle threshold according to the main direction to obtain a plurality of single communication chains meeting the preset condition.
In one possible example, in terms of the partitioning of the plurality of single-connected chains into a plurality of single-connected chain sets according to table-grid constraints, the instructions in the program are specifically configured to: acquiring the vertical difference value of any two transverse single-communication chains in the plurality of single-communication chains; when the vertical difference value is smaller than a first preset threshold value, determining that any two transverse single communication chains are the same transverse grid line; all the transverse single communication chains on the same transverse table line are subjected to sorting treatment from left to right; or, acquiring the transverse difference value of any two vertical single communication chains in the plurality of single communication chains; when the transverse difference value is smaller than a second preset threshold value, determining that any two vertical single communication chains are the same vertical table grid line; all vertical single communication chains on the same vertical form line are subjected to sorting treatment from top to bottom; and determining a plurality of single-connected chain sets according to the ordered single-connected chains, wherein each single-connected chain set corresponds to the single-connected chains of one table line.
In one possible example, in the determining the plurality of sets of single connected chains in the picture that meet the table grid line constraint, the instructions in the program are specifically configured to: extracting all single communication chains in the picture; determining grid line reference points for each single connected chain in the all single connected chains; determining a longitudinal reference grid line and a transverse reference grid line of each single communication chain in the picture by taking the grid line reference points as datum points; and determining a single connected chain set of a plurality of single connected chains which are completely positioned in the same reference grid line.
In one possible example, in the determining a single connected chain set of a plurality of all the single connected chains that are all in a same reference grid line, the instructions in the program are specifically configured to: determining a plurality of straight single communication chains in all single communication chains; determining at least one single communication chain in the same reference grid line according to the reference grid line of each straight single communication chain in the plurality of straight single communication chains; and sequencing the at least one single communication chain to obtain a plurality of single communication chain sets.
In one possible example, in the aspect of generating the table layout of the picture according to the plurality of reference table lines corresponding to the plurality of single connected chain sets, the instructions in the program are specifically configured to: determining a reference table according to a plurality of reference table grid lines corresponding to the plurality of single communication chain sets; and filtering an illegal table according to an illegal table source and the reference table to obtain the table layout of the picture, wherein the illegal table is generated by the illegal table source, and the illegal table source comprises straight lines except for a table line in the picture which leads to erroneous judgment of the reference table line.
In one possible example, when the illegal source is a false judgment of a reference table line caused by a square seal, the method filters an illegal table according to the illegal source and the reference table to obtain the table layout aspect of the picture, and the instructions in the program are specifically configured to perform the following operations: identifying the colors of all the reference table grid lines; identifying the straight lines except the table lines according to the colors, and filtering out erroneous judgment reference table lines to obtain the table layout of the picture; or, obtaining the line width of the reference table grid line to obtain a line width set; judging whether line widths larger than a preset width threshold exist in the line width set; if yes, filtering out reference table grid lines corresponding to the line width larger than a preset width threshold value, and obtaining the table layout of the picture; or, identifying morphological characteristics of the form layout; filtering out reference table grid lines corresponding to the reference table with the morphological characteristics not conforming to the preset morphological rules, and obtaining the table layout of the picture; or detecting straight lines except table lines in the picture through an image processing technology; calculating a horizontal pixel or a vertical pixel of the straight line; calculating the pixel overlapping degree of the straight line and all the reference table grid lines according to the transverse pixels or the vertical pixels; obtaining an accumulated value of the overlapping degree of each reference table grid line according to the pixel overlapping degree; and when judging that the accumulated value is greater than a preset text overlapping threshold, removing the reference table grid line corresponding to the straight line to obtain the table layout of the picture.
In one possible example, in terms of filtering out the reference table ruled lines corresponding to the reference table whose morphological characteristics do not conform to the preset morphological rule, the instructions in the program are specifically configured to perform the following operations: determining corner points of the table through the intersection point forms of the horizontal reference table grid lines and the vertical reference table grid lines; determining the number of unit tables in the reference table according to the corner points; determining morphological characteristics of the table according to the number of the unit tables, wherein the morphological characteristics comprise the number of corner points and the number of intersection points; and filtering out the reference table grid lines corresponding to the reference table which does not accord with the preset morphology rule according to the morphology features of the table.
The foregoing description of the embodiments of the present application has been presented primarily in terms of a method-side implementation. It will be appreciated that the electronic device, in order to achieve the above-described functions, includes corresponding hardware structures and/or software modules that perform the respective functions. Those of skill in the art will readily appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied as hardware or a combination of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application may divide the functional units of the electronic device according to the above method example, for example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated in one processing unit. The integrated units may be implemented in hardware or in software functional units. It should be noted that, in the embodiment of the present application, the division of the units is schematic, which is merely a logic function division, and other division manners may be implemented in actual practice.
Fig. 7 is a functional block diagram of a form layout analysis and extraction apparatus 700 according to an embodiment of the present application. The form layout analysis and extraction apparatus 700 is applied to an electronic device including a processing unit 701 and a communication unit 702, wherein,
the processing unit 701 is configured to obtain, through the communication unit 702, a picture including a form layout; determining a plurality of single-connected chain sets in the picture, wherein the single-connected chain sets conform to a table grid line constraint condition, each single-connected chain set in the plurality of single-connected chain sets comprises at least one single-connected chain, the single-connected chains correspond to a transverse or vertical short line segment in the picture, and the table line constraint condition means that the directions of the single-connected chains are the same and are in the same straight line; generating reference table grid lines corresponding to each single communication chain set according to at least one single communication chain contained in each single communication chain set; and generating the table layout of the picture according to a plurality of reference table lines corresponding to the plurality of single communication chain sets.
The form layout analysis and extraction device 700 may further include a storage unit 703 for storing program codes and data of the electronic device. The processing unit 701 may be a processor, the communication unit 702 may be an internal communication interface, and the storage unit 703 may be a memory.
It can be seen that in the embodiment of the present application, after a picture including a table layout is obtained, a plurality of single-connected chain sets meeting the constraint conditions of table grid lines in the picture may be determined, and then, according to at least one single-connected chain included in each single-connected chain set, reference table grid lines corresponding to each single-connected chain set are generated; finally, generating the table layout of the picture according to a plurality of reference table grid lines corresponding to the plurality of single-connected chain sets, wherein the reference table grid lines generated by the plurality of single-connected chain sets meeting the constraint conditions of the table grid lines in the picture are determined, so that the table layout is obtained, the complexity of table detection is reduced, and the efficiency and the accuracy of extracting the table layout are improved.
In one possible example, in the determining a plurality of single connected chain sets meeting the grid line constraint condition in the picture, the processing unit 701 is specifically configured to: detecting and extracting all single connected chains in the picture; screening a plurality of single communication chains meeting preset conditions in all the single communication chains; dividing the single communication chains into a plurality of single communication chain sets according to the grid line constraint condition.
In one possible example, in the aspect of screening the plurality of single-connected chains that meet the preset condition among the all single-connected chains, the processing unit 701 is specifically configured to: acquiring an adaptive length threshold of the form layout in the picture; comparing each single communication chain in all the single communication chains with the self-adaptive length threshold, and eliminating the single communication chains with the length smaller than the self-adaptive length threshold to obtain single communication chains conforming to the self-adaptive length threshold; removing nonlinear single communication chains in the single communication chains meeting the self-adaptive length threshold to obtain single communication chains meeting the linear requirement; calculating the inclination angle of the single communication chain meeting the linear requirement, and marking the maximum angle as the main direction of the whole table; eliminating single communication chains of which the difference value between the inclination angle and the main direction exceeds a preset angle threshold value; and carrying out inclination correction on the single communication chains meeting the preset angle threshold according to the main direction to obtain a plurality of single communication chains meeting the preset condition.
In one possible example, in terms of the partitioning of the plurality of single-connected chains into a plurality of single-connected chain sets according to a table-grid constraint, the processing unit 701 is specifically configured to: acquiring the vertical difference value of any two transverse single-communication chains in the plurality of single-communication chains; when the vertical difference value is smaller than a first preset threshold value, determining that any two transverse single communication chains are the same transverse grid line; all the transverse single communication chains on the same transverse table line are subjected to sorting treatment from left to right; or, acquiring the transverse difference value of any two vertical single communication chains in the plurality of single communication chains; when the transverse difference value is smaller than a second preset threshold value, determining that any two vertical single communication chains are the same vertical table grid line; all vertical single communication chains on the same vertical form line are subjected to sorting treatment from top to bottom; and determining a plurality of single-connected chain sets according to the ordered single-connected chains, wherein each single-connected chain set corresponds to the single-connected chains of one table line.
In one possible example, in the determining a plurality of single connected chain sets meeting the grid line constraint condition in the picture, the processing unit 701 is specifically configured to: extracting all single communication chains in the picture; determining grid line reference points for each single connected chain in the all single connected chains; determining a longitudinal reference grid line and a transverse reference grid line of each single communication chain in the picture by taking the grid line reference points as datum points; and determining a single connected chain set of a plurality of single connected chains which are completely positioned in the same reference grid line.
In one possible example, in the determining a single connected chain set of multiple single connected chains that are all in the same reference grid line, the processing unit 701 is specifically configured to: determining a plurality of straight single communication chains in all single communication chains; determining at least one single communication chain in the same reference grid line according to the reference grid line of each straight single communication chain in the plurality of straight single communication chains; and sequencing the at least one single communication chain to obtain a plurality of single communication chain sets.
In one possible example, in the aspect of generating the table layout of the picture according to the plurality of reference table ruled lines corresponding to the plurality of single connected chain sets, the processing unit 701 is specifically configured to: determining a reference table according to a plurality of reference table grid lines corresponding to the plurality of single communication chain sets; and filtering an illegal table according to an illegal table source and the reference table to obtain the table layout of the picture, wherein the illegal table is generated by the illegal table source, and the illegal table source comprises straight lines except for a table line in the picture which leads to erroneous judgment of the reference table line.
In one possible example, when the illegal source is a false judgment of a reference table line caused by a square seal, the processing unit 701 is specifically configured to, according to the illegal source and the reference table, filter an illegal table to obtain the table layout aspect of the picture: identifying the colors of all the reference table grid lines; identifying the straight lines except the table lines according to the colors, and filtering out erroneous judgment reference table lines to obtain the table layout of the picture; or, obtaining the line width of the reference table grid line to obtain a line width set; judging whether line widths larger than a preset width threshold exist in the line width set; if yes, filtering out reference table grid lines corresponding to the line width larger than a preset width threshold value, and obtaining the table layout of the picture; or, identifying morphological characteristics of the form layout; filtering out reference table grid lines corresponding to the reference table with the morphological characteristics not conforming to the preset morphological rules, and obtaining the table layout of the picture; or detecting straight lines except table lines in the picture through an image processing technology; calculating a horizontal pixel or a vertical pixel of the straight line; calculating the pixel overlapping degree of the straight line and all the reference table grid lines according to the transverse pixels or the vertical pixels; obtaining an accumulated value of the overlapping degree of each reference table grid line according to the pixel overlapping degree; and when judging that the accumulated value is greater than a preset text overlapping threshold, removing the reference table grid line corresponding to the straight line to obtain the table layout of the picture.
In one possible example, in terms of filtering out the reference table ruled lines corresponding to the reference table whose morphological feature does not conform to the preset morphological rule, the processing unit 701 is specifically configured to: determining corner points of the table through the intersection point forms of the horizontal reference table grid lines and the vertical reference table grid lines; determining the number of unit tables in the reference table according to the corner points; determining morphological characteristics of the table according to the number of the unit tables, wherein the morphological characteristics comprise the number of corner points and the number of intersection points; and filtering out the reference table grid lines corresponding to the reference table which does not accord with the preset morphology rule according to the morphology features of the table.
The embodiment of the application also provides a computer storage medium, where the computer storage medium stores a computer program for electronic data exchange, where the computer program causes a computer to execute part or all of the steps of any one of the methods described in the embodiments of the method, where the computer includes an electronic device.
Embodiments of the present application also provide a computer program product comprising a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any one of the methods described in the method embodiments above. The computer program product may be a software installation package, said computer comprising an electronic device.
It should be noted that, for simplicity of description, the foregoing method embodiments are all expressed as a series of action combinations, but it should be understood by those skilled in the art that the present application is not limited by the order of actions described, as some steps may be performed in other order or simultaneously in accordance with the present application. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required in the present application.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, such as the above-described division of units, merely a division of logic functions, and there may be additional manners of dividing in actual implementation, such as multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, or may be in electrical or other forms.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units described above, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable memory. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a memory, including several instructions for causing a computer device (which may be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the above-mentioned method of the various embodiments of the present application. And the aforementioned memory includes: a U-disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Those of ordinary skill in the art will appreciate that all or a portion of the steps in the various methods of the above embodiments may be implemented by a program that instructs associated hardware, and the program may be stored in a computer readable memory, which may include: flash disk, read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk.
The foregoing has outlined rather broadly the more detailed description of embodiments of the present application, wherein specific examples are provided herein to illustrate the principles and embodiments of the present application, the above examples being provided solely to assist in the understanding of the methods of the present application and the core ideas thereof; meanwhile, as those skilled in the art will have modifications in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (11)

1. A form layout analysis and extraction method, comprising:
acquiring a picture containing a form layout;
determining a plurality of single-connected chain sets in the picture, wherein the single-connected chain sets conform to a table line constraint condition, each single-connected chain set in the plurality of single-connected chain sets comprises at least one single-connected chain, the single-connected chains correspond to a transverse or vertical short line section in the picture, and the table line constraint condition means that the directions of the single-connected chains are the same and are in the same straight line;
Generating reference table grid lines corresponding to each single communication chain set according to at least one single communication chain contained in each single communication chain set;
generating the table layout of the picture according to a plurality of reference table lines corresponding to the plurality of single communication chain sets, including: determining a reference table according to a plurality of reference table grid lines corresponding to the plurality of single communication chain sets; and filtering an illegal table according to an illegal table source and the reference table to obtain the table layout of the picture, wherein the illegal table is generated by the illegal table source, and the illegal table source comprises straight lines except for a table line in the picture which leads to erroneous judgment of the reference table line.
2. The method of claim 1, wherein the determining a plurality of sets of single connected chains in the picture that meet table grid line constraints comprises:
detecting and extracting all single connected chains in the picture;
screening a plurality of single communication chains meeting preset conditions in all the single communication chains;
dividing the single communication chains into a plurality of single communication chain sets according to the grid line constraint condition.
3. The method according to claim 2, wherein said screening a plurality of single-connected strands of all single-connected strands meeting a preset condition comprises:
Acquiring an adaptive length threshold of the form layout in the picture;
comparing each single communication chain in all the single communication chains with the self-adaptive length threshold, and eliminating the single communication chains with the length smaller than the self-adaptive length threshold to obtain single communication chains conforming to the self-adaptive length threshold;
removing nonlinear single communication chains in the single communication chains meeting the self-adaptive length threshold to obtain single communication chains meeting the linear requirement;
calculating the inclination angle of the single communication chain meeting the linear requirement, and marking the maximum angle as the main direction of the whole table;
eliminating single communication chains of which the difference value between the inclination angle and the main direction exceeds a preset angle threshold value;
and carrying out inclination correction on the single communication chains meeting the preset angle threshold according to the main direction to obtain a plurality of single communication chains meeting the preset condition.
4. A method according to claim 2 or 3, wherein said dividing said plurality of single connected chains into a plurality of single connected chain sets according to table grid line constraints, comprises:
acquiring the vertical difference value of any two transverse single-communication chains in the plurality of single-communication chains;
when the vertical difference value is smaller than a first preset threshold value, determining that any two transverse single communication chains are the same transverse grid line;
All the transverse single communication chains on the same transverse table line are subjected to sorting treatment from left to right; or alternatively, the first and second heat exchangers may be,
acquiring the transverse difference value of any two vertical single communication chains in the plurality of single communication chains;
when the transverse difference value is smaller than a second preset threshold value, determining that any two vertical single communication chains are the same vertical table grid line;
all vertical single communication chains on the same vertical form line are subjected to sorting treatment from top to bottom;
and determining a plurality of single-connected chain sets according to the ordered single-connected chains, wherein each single-connected chain set corresponds to the single-connected chains of one table line.
5. The method of claim 1, wherein the determining a plurality of sets of single connected chains in the picture that meet table grid line constraints comprises:
extracting all single communication chains in the picture;
determining grid line reference points for each single connected chain in the all single connected chains;
determining a longitudinal reference grid line and a transverse reference grid line of each single communication chain in the picture by taking the grid line reference points as datum points;
and determining a single connected chain set of a plurality of single connected chains which are completely positioned in the same reference grid line.
6. The method of claim 5, wherein determining a set of single connected chains of the plurality of all single connected chains that are all at a same reference grid line comprises:
determining a plurality of straight single communication chains in all single communication chains;
determining at least one single communication chain in the same reference grid line according to the reference grid line of each straight single communication chain in the plurality of straight single communication chains;
and sequencing the at least one single communication chain to obtain a plurality of single communication chain sets.
7. The method according to claim 1, wherein said filtering an illegal form from an illegal form source and said reference form to obtain said form layout of said picture comprises:
identifying the colors of all the reference table grid lines;
identifying the straight lines except the table lines according to the colors, and filtering out erroneous judgment reference table lines to obtain the table layout of the picture; or alternatively, the first and second heat exchangers may be,
acquiring line widths of the reference table grid lines to obtain a line width set;
judging whether line widths larger than a preset width threshold exist in the line width set;
if yes, filtering out reference table grid lines corresponding to the line width larger than a preset width threshold value, and obtaining the table layout of the picture; or alternatively, the first and second heat exchangers may be,
Identifying morphological characteristics of the form layout;
filtering out reference table grid lines corresponding to the reference table with the morphological characteristics not conforming to the preset morphological rules, and obtaining the table layout of the picture; or alternatively, the first and second heat exchangers may be,
detecting straight lines except table lines in the picture through an image processing technology;
calculating a horizontal pixel or a vertical pixel of the straight line;
calculating the pixel overlapping degree of the straight line and all the reference table grid lines according to the transverse pixels or the vertical pixels;
obtaining an accumulated value of the overlapping degree of each reference table grid line according to the pixel overlapping degree;
and when judging that the accumulated value is greater than a preset text overlapping threshold, removing the reference table grid line corresponding to the straight line to obtain the table layout of the picture.
8. The method of claim 7, wherein filtering the reference table grid lines corresponding to the reference table whose morphological features do not meet the preset morphological rule comprises:
determining corner points of the table through the intersection point forms of the horizontal reference table grid lines and the vertical reference table grid lines;
determining the number of unit tables in the reference table according to the corner points;
determining morphological characteristics of the table according to the number of the unit tables, wherein the morphological characteristics comprise the number of corner points and the number of intersection points;
And filtering out the reference table grid lines corresponding to the reference table which does not accord with the preset morphology rule according to the morphology features of the table.
9. A form layout analysis and extraction device is characterized by comprising a processing unit and a communication unit, wherein,
the processing unit is used for acquiring pictures containing form layouts through the communication unit; determining a plurality of single-connected chain sets in the picture, wherein the single-connected chain sets conform to a table grid line constraint condition, each single-connected chain set in the plurality of single-connected chain sets comprises at least one single-connected chain, the single-connected chains correspond to a transverse or vertical short line segment in the picture, and the table line constraint condition means that the directions of the single-connected chains are the same and are in the same straight line; generating reference table grid lines corresponding to each single communication chain set according to at least one single communication chain contained in each single communication chain set; and generating the table layout of the picture according to a plurality of reference table lines corresponding to the plurality of single connected chain sets, including: determining a reference table according to a plurality of reference table grid lines corresponding to the plurality of single communication chain sets; and filtering an illegal table according to an illegal table source and the reference table to obtain the table layout of the picture, wherein the illegal table is generated by the illegal table source, and the illegal table source comprises straight lines except for a table line in the picture which leads to erroneous judgment of the reference table line.
10. An electronic device comprising a processor, a memory, and one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the steps in the method of any of claims 1-8.
11. A computer-readable storage medium, characterized in that a computer program for electronic data exchange is stored, wherein the computer program causes a computer to perform the method according to any one of claims 1-8.
CN201910773607.6A 2019-08-21 2019-08-21 Form layout analysis and extraction method and related device Active CN110598575B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910773607.6A CN110598575B (en) 2019-08-21 2019-08-21 Form layout analysis and extraction method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910773607.6A CN110598575B (en) 2019-08-21 2019-08-21 Form layout analysis and extraction method and related device

Publications (2)

Publication Number Publication Date
CN110598575A CN110598575A (en) 2019-12-20
CN110598575B true CN110598575B (en) 2023-06-02

Family

ID=68854963

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910773607.6A Active CN110598575B (en) 2019-08-21 2019-08-21 Form layout analysis and extraction method and related device

Country Status (1)

Country Link
CN (1) CN110598575B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111611883B (en) * 2020-05-07 2023-08-15 北京智通云联科技有限公司 Table layout analysis method, system and equipment based on minimum cell clustering
CN113705576B (en) * 2021-11-01 2022-03-25 江西中业智能科技有限公司 Text recognition method and device, readable storage medium and equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103577817B (en) * 2012-07-24 2017-03-01 阿里巴巴集团控股有限公司 Form recognition method and apparatus
CN110147774B (en) * 2019-05-23 2021-06-15 阳光保险集团股份有限公司 Table format picture layout analysis method and computer storage medium

Also Published As

Publication number Publication date
CN110598575A (en) 2019-12-20

Similar Documents

Publication Publication Date Title
CN107093172B (en) Character detection method and system
WO2019237549A1 (en) Verification code recognition method and apparatus, computer device, and storage medium
CN111382704B (en) Vehicle line pressing violation judging method and device based on deep learning and storage medium
Shi et al. Text extraction from gray scale historical document images using adaptive local connectivity map
CN107784301A (en) Method and apparatus for identifying character area in image
WO2014018482A2 (en) Form recognition method and device
CN110598575B (en) Form layout analysis and extraction method and related device
CN103034848A (en) Identification method of form type
CN111737478B (en) Text detection method, electronic device and computer readable medium
CN112507782A (en) Text image recognition method and device
CN111259891B (en) Method, device, equipment and medium for identifying identity card in natural scene
CN105335741A (en) Smudged serial number classification method and system
CN110135407B (en) Sample labeling method and computer storage medium
CN111461126A (en) Space recognition method and device in text line, electronic equipment and storage medium
WO2018140001A1 (en) Print quality diagnosis
CN111814673A (en) Method, device and equipment for correcting text detection bounding box and storage medium
CN116091503B (en) Method, device, equipment and medium for discriminating panel foreign matter defects
CN112528740A (en) Pressing plate state identification method
CN113033562A (en) Image processing method, device, equipment and storage medium
CN109145879B (en) Method, equipment and storage medium for identifying printing font
CN111583156B (en) Document image shading removing method and system
CN115410191A (en) Text image recognition method, device, equipment and storage medium
CN111445433B (en) Method and device for detecting blank page and fuzzy page of electronic file
Mostafa An adaptive algorithm for the automatic segmentation of printed Arabic text
JP4244692B2 (en) Character recognition device and character recognition program

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