CN116071774A - Table image cell rank information indexing method, computer device and storage medium - Google Patents
Table image cell rank information indexing method, computer device and storage medium Download PDFInfo
- Publication number
- CN116071774A CN116071774A CN202211603819.8A CN202211603819A CN116071774A CN 116071774 A CN116071774 A CN 116071774A CN 202211603819 A CN202211603819 A CN 202211603819A CN 116071774 A CN116071774 A CN 116071774A
- Authority
- CN
- China
- Prior art keywords
- cell
- line
- coordinates
- cells
- transverse line
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V30/00—Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
- G06V30/40—Document-oriented image-based pattern recognition
- G06V30/41—Analysis of document content
- G06V30/414—Extracting the geometrical structure, e.g. layout tree; Block segmentation, e.g. bounding boxes for graphics or text
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Computer Graphics (AREA)
- Geometry (AREA)
- Artificial Intelligence (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
Abstract
The invention provides a table image cell rank information indexing method, a computer device and a storage medium, wherein the method comprises the following steps: identifying all cells in the table image, and acquiring coordinates of four vertexes of each cell; respectively generating an upper transverse line coordinate set representing an upper transverse line of the cell, a lower transverse line coordinate set representing a lower transverse line of the cell, a left longitudinal line coordinate set representing a left longitudinal line of the cell and a right longitudinal line coordinate set representing a right longitudinal line of the cell according to coordinates of four vertexes of all the cells; determining a dynamic threshold value and a column dynamic threshold value of each cell; and determining a row start index, a row end index, a column start index and a column end index of each cell according to the upper abscissa set, the lower abscissa set, the left ordinate set, the right ordinate set, the dynamic threshold value and the column dynamic threshold value. The table image cell rank information indexing method can divide the specific ranks to which the cells belong, and covers the index information more comprehensively.
Description
Technical Field
The invention relates to the technical field of image processing, in particular to a table image cell rank information indexing method, a computer device applying the table image cell rank information indexing method and a computer readable storage medium applying the table image cell rank information indexing method.
Background
Forms are common objects in various documents, and the structured organization form of the forms is convenient for people to understand and extract information. The types of the tables can be divided into a wired table, a less-wired table and a wireless table according to whether frames exist or not. The form style is complex and various, such as background filling, illumination shadow, cell row and column combination and the like. In the big data age, a large number of electronic form image documents exist, and the form processing time can be reduced by applying a form recognition technology, so the form recognition is an important research topic in the field of document understanding. In the table, most tables have the case of merging cells, and for some tables, because a certain column is too narrow, and the content of a certain cell in the column is far longer than that of other cells in the column, the cell needs to be line-fed, and multiple rows of cells need to be used for displaying the content. In the existing table recognition algorithm, after detecting and recognizing the table, the table is marked by a simple index or further using a complex sequence label, and the combined cells cannot be reflected, and the table with multiple rows or columns of combined cells or the table without table grid lines is marked in disorder, so that a user or a subsequent program developer cannot directly acquire the table cell information, and the table use experience or the program development efficiency is affected, and therefore, a more optimized cell index calculation method is needed.
Disclosure of Invention
The first object of the present invention is to provide a method for indexing the row and column information of cells of a tabular image, which can divide the specific rows and columns of the cells and cover the more comprehensive index information.
A second object of the present invention is to provide a computer device capable of dividing the specific rows and columns of the unit cells, and covering the index information more comprehensively.
A third object of the present invention is to provide a computer readable storage medium, which can divide a specific row and column to which a cell belongs, and cover more comprehensive index information.
In order to achieve the first object, the method for indexing row and column information of cells in a tabular image provided by the invention comprises the following steps: identifying all cells in the table image, and acquiring coordinates of four vertexes of each cell; respectively generating an upper transverse line coordinate set representing an upper transverse line of the cell, a lower transverse line coordinate set representing a lower transverse line of the cell, a left longitudinal line coordinate set representing a left longitudinal line of the cell and a right longitudinal line coordinate set representing a right longitudinal line of the cell according to coordinates of four vertexes of all the cells; determining a dynamic threshold of each cell according to the length of the left or right vertical line of the cell, and determining a column dynamic threshold of each cell according to the length of the upper or lower horizontal line of the cell; the method comprises the steps of sequentially differencing an upper transverse coordinate of each cell with an upper transverse coordinate in an upper transverse coordinate set, taking an upper transverse line corresponding to which an obtained difference absolute value is smaller than a dynamic threshold value as a row starting index of the cell, sequentially differencing a lower transverse coordinate of each cell with a lower transverse coordinate in a lower transverse coordinate set, taking a lower transverse line corresponding to which the obtained difference absolute value is smaller than the dynamic threshold value as a row ending index of the cell, sequentially differencing a left longitudinal coordinate of each cell with a left longitudinal coordinate in a left longitudinal coordinate set, taking a left longitudinal line corresponding to which the obtained difference absolute value is smaller than the column dynamic threshold value as a column starting index of the cell, sequentially differencing a right longitudinal coordinate of each cell with a right longitudinal coordinate in a right longitudinal coordinate set, and taking a right longitudinal line corresponding to which the obtained difference absolute value is smaller than the column dynamic threshold value as a column ending index of the cell.
According to the table image cell rank information indexing method, after all cells in a table image are identified, dynamic thresholds are set according to the widths and heights of the cells, so that row and column index information of the cells is determined, the situation that the fixed thresholds are set to miss rank information can be avoided, specific ranks of the cells are well divided, the index information is more comprehensive, the calculated amount is small, the logic is simple, and the implementation is more convenient.
In a further aspect, the steps of generating an upper abscissa set representing an upper transversal line of a cell, a lower abscissa set representing a lower transversal line of a cell, a left ordinate set representing a left longitudinal line of a cell, and a right ordinate set representing a right longitudinal line of a cell according to coordinates of four vertices of all cells respectively include: performing cluster analysis on the abscissa of the left top vertex of all the cells to obtain left longitudinal line coordinates of each left longitudinal line in the table, and sorting the left longitudinal line coordinates in ascending order of the coordinate values to obtain a left longitudinal line coordinate set; performing cluster analysis on the abscissa of the top right vertex of all the cells to obtain the right longitudinal line coordinates of each right longitudinal line in the table, and sorting the right longitudinal line coordinates in ascending order of the coordinate values to obtain a right longitudinal line coordinate set; performing cluster analysis on the ordinate of the left upper vertex of all the cells to obtain upper transverse line coordinates of each upper transverse line in the table, and sorting the upper transverse line coordinates in ascending order of coordinate values to obtain an upper transverse line coordinate set; and performing cluster analysis on the ordinate of the left lower vertexes of all the cells to obtain lower transverse line coordinates of each lower transverse line in the table, and sorting the lower transverse line coordinates in ascending order of the coordinate values to obtain a lower transverse line coordinate set representing the lower transverse line of the cell.
Therefore, the number of the horizontal lines and the vertical lines in the table can be determined by carrying out cluster analysis on the coordinates and sorting the coordinates in ascending order of the coordinate values, so that the subsequent confirmation of the row and column indexes of the cells is facilitated.
In a further aspect, the step of determining the dynamic threshold of each cell based on the length of the left or right vertical line of the cell includes: if half of the length of the left or right vertical line of the cell is within the first preset range, taking half of the length of the left or right vertical line of the cell as a dynamic threshold; if half of the length of the left vertical line or the right vertical line of the cell is larger than the upper limit value of the first preset range, taking the upper limit value of the first preset range as a dynamic threshold value; and if the half length of the left vertical line or the right vertical line of the cell is smaller than the lower limit value of the first preset range, taking the lower limit value of the first preset range as a dynamic threshold value.
Therefore, the half length of the left vertical line or the right vertical line of the cell is judged through the first preset range, so that the dynamic threshold value is determined, the problem that the dynamic threshold value is too large or too small can be avoided, and the precision of the row index in the cell is improved.
In a further aspect, the step of determining the column dynamic threshold for each cell based on the length of the upper or lower cross line of the cell includes: if half of the length of the upper transverse line or the lower transverse line of the cell is in the second preset range, taking half of the length of the upper transverse line or the lower transverse line of the cell as a dynamic column threshold; if half of the length of the upper transverse line or the lower transverse line of the cell is larger than the upper limit value of the second preset range, taking the upper limit value of the second preset range as a column dynamic threshold value; and if the half length of the upper transverse line or the lower transverse line of the cell is smaller than the lower limit value of the second preset range, taking the lower limit value of the second preset range as the column dynamic threshold value.
Therefore, the half length of the upper transverse line or the lower transverse line of the cell is judged through the second preset range, so that the dynamic threshold value of the column is determined, the problem that the dynamic threshold value of the column is too large or too small can be avoided, and the precision of the column index in the cell is improved.
In a further aspect, the step of identifying all cells in the form image includes: identifying all table grid lines in the table image; and dividing each cell by using an image connected region analysis method.
Therefore, each cell in the form image is divided by the image connected region analysis method, so that the form recognition speed can be improved.
In a further aspect, after the step of identifying all the table grid lines in the table image, the method further includes: and performing de-duplication treatment on all the table grid lines.
Therefore, in order to avoid the situation that one line is recognized as a plurality of lines in the lines recognized by the image, the duplicate removal processing is needed to be performed on all the table lines, so that the recognition accuracy of the table is improved.
In a further aspect, the step of performing the deduplication processing on all table ruled lines includes: if the distance between any two transverse lines is smaller than the preset distance, combining the two transverse lines into one transverse line; if the distance between any two longitudinal lines is smaller than the preset distance, combining the two longitudinal lines into one longitudinal line.
It can be seen that whether the two lines overlap is determined by determining whether the distance between the two lines is less than a preset distance.
In a further aspect, before the step of identifying all cells in the table image, the method further includes: and carrying out angle recognition on the table image and carrying out image angle correction.
Therefore, when the table image is acquired, the problem of incorrect angle can exist, and the table image is subjected to angle identification and image angle correction, so that the identification of the subsequent table can be facilitated.
In order to achieve the second object of the present invention, the present invention provides a computer apparatus including a processor and a memory, the memory storing a computer program, the computer program implementing the steps of the above-described table image cell line information indexing method when executed by the processor.
In order to achieve the third object of the present invention, the present invention provides a computer readable storage medium having a computer program stored thereon, which when executed by a controller, implements the steps of the above-described table image cell line information indexing method.
Drawings
FIG. 1 is a flow chart of an embodiment of a tabular image cell rank information indexing method of the present invention.
The invention is further described below with reference to the drawings and examples.
Detailed Description
Table image cell rank information indexing method embodiment:
the invention relates to a table image cell rank information indexing method which is an application program applied to a computer device and is used for identifying cells in a table image and obtaining rank index information of the cells.
As shown in fig. 1, when the table image cell line information indexing method of the present invention is operated, step S1 is first executed to perform angle recognition on a table image and perform image angle correction. Because the input form image may have a picture deflection, for example, deflection of 90 degrees, 180 degrees, 270 degrees, etc., there may be a problem of misalignment of angles, so that coordinates of a subsequent form are not easy to obtain or error, and therefore, it is necessary to perform angle recognition and image angle correction on the input form image, which may be beneficial to recognition of the subsequent form. The techniques for angle recognition and rotation correction of images are well known to those skilled in the art and will not be described in detail herein.
After the image angle correction is performed, step S2 is performed to identify all cells in the table image, and the coordinates of four vertices of each cell are obtained. To create index information for cells in a form, it is necessary to identify cells in the form image first. In this embodiment, the step of identifying all cells in the form image includes: identifying all table grid lines in the table image; and dividing each cell by using an image connected region analysis method. When all the table grid lines in the table image are identified, the table image is identified through a preset deep learning model, so that the table grid lines in the table image are identified, and the preset deep learning model adopts a well-known deep learning model, which is a technology well known to those skilled in the art and is not repeated herein. After all the table grid lines in the table image are identified, the table image is marked by using an image connected region analysis method and using image methods such as expansion and corrosion to obtain all the connected regions, the head coordinates and the tail coordinates of four line segments in the minimum rectangular frame matched with each connected region are obtained according to the coordinates of pixel points in each connected region, the coordinates of four vertexes of each connected region corresponding to the unit cells are further obtained, namely the coordinates of four vertexes of each unit cell are obtained, and each unit cell is divided. When the coordinates of the four vertices of each cell are determined, the coordinate values of the abscissa are gradually increased along the right direction of the table image and the coordinate values of the ordinate are gradually increased along the lower direction of the table image by taking the top left vertex of the table image as the origin. The method for analyzing the image connected region is known to those skilled in the art, and the method is not described herein.
Among the recognized lines, short lines and lines with a small pitch exist, and thus the recognition of the cell is disturbed, and therefore, the line screening is required. In order to avoid that one line is identified as a plurality of lines in the lines identified by the image, in this embodiment, after the step of identifying all the table lines in the table image, the method further includes: and performing de-duplication treatment on all the table grid lines. And performing de-duplication treatment on all the table grid lines, thereby improving the recognition accuracy of the table. The step of performing the deduplication processing on all the table grid lines comprises the following steps: if the distance between any two transverse lines is smaller than the preset distance, combining the two transverse lines into one transverse line; if the distance between any two longitudinal lines is smaller than the preset distance, combining the two longitudinal lines into one longitudinal line. The preset distance is preset or manually input according to experimental data. In addition, in order to avoid that the identified lines have shorter lines, in this embodiment, after the step of identifying all the table lines in the table image, the method further includes: and deleting lines smaller than the preset length. The preset length can be preset according to experimental data. The distance between the lines and the length of the lines can be obtained according to the coordinate points of the lines, which are known techniques to those skilled in the art, and are not described herein.
After the coordinates of the four vertices of each cell are obtained, step S3 is performed, where an upper transversal coordinate set representing an upper transversal of the cell, a lower transversal coordinate set representing a lower transversal of the cell, a left longitudinal coordinate set representing a left longitudinal of the cell, and a right longitudinal coordinate set representing a right longitudinal of the cell are generated according to the coordinates of the four vertices of all the cells, respectively. Wherein, the upper abscissa in the upper abscissa set is sorted by the coordinate value size ascending, the lower abscissa in the lower abscissa set is sorted by the coordinate value size ascending, the left ordinate in the left ordinate set is sorted by the coordinate value size ascending, and the right ordinate in the right ordinate set is sorted by the coordinate value size ascending. After the coordinates of each cell are obtained, the starting and ending rows and columns of each cell need to be determined, so that the ordering condition of the line segments in the horizontal line set and the vertical line set of the cells needs to be combined so as to determine the row and column indexes of the cells.
In this embodiment, the steps of generating an upper abscissa set representing an upper transverse line of a cell, a lower transverse line coordinate set representing a lower transverse line of the cell, a left ordinate set representing a left longitudinal line of the cell, and a right ordinate set representing a right longitudinal line of the cell according to coordinates of four vertices of all cells respectively include: performing cluster analysis on the abscissa of the left top vertex of all the cells to obtain left longitudinal line coordinates of each left longitudinal line in the table, and sorting the left longitudinal line coordinates in ascending order of the coordinate values to obtain a left longitudinal line coordinate set; performing cluster analysis on the abscissa of the top right vertex of all the cells to obtain the right longitudinal line coordinates of each right longitudinal line in the table, and sorting the right longitudinal line coordinates in ascending order of the coordinate values to obtain a right longitudinal line coordinate set; performing cluster analysis on the ordinate of the left upper vertex of all the cells to obtain upper transverse line coordinates of each upper transverse line in the table, and sorting the upper transverse line coordinates in ascending order of coordinate values to obtain an upper transverse line coordinate set; and performing cluster analysis on the ordinate of the left lower vertexes of all the cells to obtain lower transverse line coordinates of each lower transverse line in the table, and sorting the lower transverse line coordinates in ascending order of the coordinate values to obtain a lower transverse line coordinate set. The abscissa of the upper left vertex of a cell represents the left vertical line of the cell, the abscissa of the upper right vertex of the cell represents the right vertical line of the cell, the ordinate of the upper left vertex of the cell represents the upper horizontal line of the cell, and the ordinate of the lower left vertex of the cell represents the lower horizontal line of the cell.
For the table, the lower transverse line of the current cell and the upper transverse line of the next cell connected with the current cell belong to the same transverse line, the right longitudinal line of the current cell and the left longitudinal line of the next cell connected with the current cell belong to the same longitudinal line, but when the cells are identified by adopting a communication area method, the coordinate values identified by the same line in different cells are unequal and still exist after line duplication removal, in addition, the upper transverse lines of all cells in the same row of cells are the same transverse line, the lower transverse lines of all cells are the same transverse line, the left longitudinal lines of all cells in the same row of cells are the same transverse line, and the right longitudinal lines of all cells are the same transverse line, so that further classification and screening are needed to determine the number of final left longitudinal lines, the number of right longitudinal lines, the number of upper transverse lines and the number of lower transverse lines in the table.
The number of final left longitudes, the number of right longitudes, the number of upper transverse lines and the number of lower transverse lines in the table and the coordinates representing the left longitudes, the right longitudes, the upper transverse lines and the lower transverse lines in the table can be determined by cluster analysis, for example, in a certain table, the left longitudes are taken as an example, the abscissas of the left top points of all cells comprise the following coordinate values (10, 11, 12, 30, 33, 40, 42), the '10, 11, 12' is classified into one category, the '30, 33' is classified into one category, the '40, 42' is classified into the second left longitudes, and the third left longitudes are classified into one category, so that the table is known to have three left longitudes, each left longitudes takes the average value of all the coordinates of the classification as a coordinate value, the three left longitudes are arranged in the order of the coordinate values from small to large, and thus a left longitudes collection (11, 31.5, 41) is obtained, and a right longitudes collection and a lower abscissa collection can be obtained by the same reason.
In order to ensure unification of coordinates of the same line in the upper abscissa set, the lower abscissa set, the left ordinate set and the right ordinate set, after the upper abscissa set, the lower abscissa set, the left ordinate set and the right ordinate set are obtained, average value acquisition can be performed on coordinate values of an upper abscissa of a next row of cells where a lower abscissa of a current cell is connected with the current cell, average value acquisition can be performed on coordinate values of a left ordinate of a next column of cells where a right ordinate of the current cell is connected with the current cell, and thus correction can be performed on the upper abscissa set, the lower abscissa set, the left ordinate set and the right ordinate set. For example, the second coordinate value of the upper abscissa set and the first coordinate value of the lower abscissa set represent the same abscissa, the third coordinate value of the upper abscissa set and the second coordinate value of the lower abscissa set represent the same abscissa, and so on, so that the average value of the second coordinate value of the upper abscissa set and the first coordinate value of the lower abscissa set is obtained, and the obtained average value corresponds to the second coordinate value of the upper abscissa set and the first coordinate value of the lower abscissa set, so that the coordinates of the same abscissa in the upper abscissa set and the lower abscissa set are unified.
After the upper abscissa set, the lower abscissa set, the left ordinate set and the right ordinate set are obtained, step S4 is performed, the dynamic threshold of each cell is determined according to the length of the left or right ordinate of the cell, and the column dynamic threshold of each cell is determined according to the length of the upper or lower abscissa of the cell. To determine the starting and ending rows and columns of each cell, a dynamic threshold is set for determination. The size of the cell in different pictures is different, so that the dynamic threshold of the cell is determined by the length of the left vertical line or the right vertical line, the column dynamic threshold of the cell is determined by the length of the upper horizontal line or the lower horizontal line, the method can adapt to a table with multiple middle sizes, does not limit the pixels of an input table image, and can avoid mismatch with the size of the cell caused by setting a fixed threshold, thereby missing row and column information.
In this embodiment, the step of determining the dynamic threshold value of each cell according to the length of the left or right vertical line of the cell includes: if half of the length of the left or right vertical line of the cell is within the first preset range, taking half of the length of the left or right vertical line of the cell as a dynamic threshold; if half of the length of the left vertical line or the right vertical line of the cell is larger than the upper limit value of the first preset range, taking the upper limit value of the first preset range as a dynamic threshold value; and if the half length of the left vertical line or the right vertical line of the cell is smaller than the lower limit value of the first preset range, taking the lower limit value of the first preset range as a dynamic threshold value. The upper limit value of the first preset range is the distance between two adjacent longitudinal lines in the table, the lower limit value of the first preset range is preset according to experimental data, and preferably, the lower limit value of the first preset range can be set as the preset distance in the line duplication removing step. For example, four vertex coordinates of a certain cell are (x 1, y 1), (x 2, y 1), (x 2, y 2), (x 1, y 2) in order from the top left vertex to the top left vertex, the length of the left vertical line or half of the left vertical line is 0.5 (y 2-y 1), the first preset range is 5 to 20, if 0.5 (y 2-y 1) is within the preset range, 0.5 (y 2-y 1) is used as the dynamic threshold, if 0.5 (y 2-y 1) is less than 5, the dynamic threshold is 5, and if 0.5 (y 2-y 1) is greater than 20, the dynamic threshold is 20. And judging half of the length of the left vertical line or the right vertical line of the cell through the first preset range, so that the dynamic threshold value of the row is determined, the problem that the dynamic threshold value is too large or too small can be avoided, and the precision of the row index in the cell is improved. If the dynamic threshold is too large, if the table height is too small, the subtraction is calculated with multiple coverage cells, and if the dynamic threshold is too small, there may be no suitable cells.
In this embodiment, the step of determining the column dynamic threshold of each cell according to the length of the upper or lower cross line of the cell includes: if half of the length of the upper transverse line or the lower transverse line of the cell is in the second preset range, taking half of the length of the upper transverse line or the lower transverse line of the cell as a dynamic column threshold; if half of the length of the upper transverse line or the lower transverse line of the cell is larger than the upper limit value of the second preset range, taking the upper limit value of the second preset range as a column dynamic threshold value; and if the half length of the upper transverse line or the lower transverse line of the cell is smaller than the lower limit value of the second preset range, taking the lower limit value of the second preset range as the column dynamic threshold value. The upper limit value of the second preset range is the distance between two adjacent transverse lines in the table, the lower limit value of the second preset range is preset according to experimental data, and preferably, the lower limit value of the second preset range can be set as the preset distance in the line duplication removing step. For example, the coordinates of four vertices of a cell in the clockwise direction starting from the top left vertex are: (x 1, y 1), (x 2, y 2), (x 1, y 2), the length of the upper or lower transverse line half is taken as 0.5 (x 2-x 1), the second preset range is 5 to 30, if 0.5 (x 2-x 1) is within the second preset range, 0.5 (x 2-x 1) is taken as the column dynamic threshold, if 0.5 (x 2-x 1) is less than 5, the column dynamic threshold is 5, and if 0.5 (x 2-x 1) is greater than 30, the column dynamic threshold is 30. And judging the half length of the upper transverse line or the lower transverse line of the cell through the second preset range, so that the dynamic threshold value of the column is determined, the problem that the dynamic threshold value of the column is too large or too small can be avoided, and the precision of the column index in the cell is improved.
After the dynamic threshold value and the dynamic threshold value of the row are obtained, step S5 is executed, wherein the upper transverse coordinates of each cell are sequentially differed from the upper transverse coordinates in the upper transverse coordinate set, the upper transverse coordinate with the absolute value smaller than the dynamic threshold value of the row of each cell is used as the starting index of the cell, the lower transverse coordinates of each cell are sequentially differed from the lower transverse coordinates in the lower transverse coordinate set, the lower transverse coordinate with the absolute value smaller than the dynamic threshold value of the row of each cell is used as the ending index of the cell, the left longitudinal coordinate of each cell is sequentially differed from the left longitudinal coordinate in the left longitudinal coordinate set, the left longitudinal coordinate with the absolute value smaller than the dynamic threshold value of the row is used as the starting index of the cell, the right longitudinal coordinate of each cell is sequentially differed from the right longitudinal coordinate in the right longitudinal coordinate set, and the right longitudinal coordinate with the absolute value smaller than the dynamic threshold value of the difference is used as the ending index of the cell. After the dynamic threshold value and the dynamic column threshold value are obtained, each cell is traversed, the upper transverse coordinates are sequentially differentiated from the upper transverse coordinates in the upper transverse coordinate set to obtain a difference absolute value, the upper transverse coordinates corresponding to the difference absolute value smaller than the dynamic threshold value are used as row starting indexes of the cell, the lower transverse coordinates are sequentially differentiated from the lower transverse coordinates in the lower transverse coordinate set, the lower transverse coordinates corresponding to the difference absolute value smaller than the dynamic threshold value are used as row ending indexes of the cell, the left longitudinal coordinates are sequentially differentiated from the left longitudinal coordinates in the left longitudinal coordinate set, the left longitudinal lines corresponding to the difference absolute value smaller than the dynamic column threshold value are used as column starting indexes of the cell, the right longitudinal coordinates corresponding to the right longitudinal coordinate set are sequentially differentiated from the right longitudinal coordinates, and the right longitudinal lines corresponding to the difference absolute value smaller than the dynamic column threshold value are used as column ending indexes of the cell. For example, in a certain table, taking a behavior example, the upper abscissa set is [42,105,168,231], the lower abscissa set is [105,168,231,288], the preset range corresponding to the behavior threshold is 5 to 63, and the coordinates of four vertices of the cell to be determined as the row and column index are: (x1=166, y1=42), (x2=282, y2=169), (x1=166, y2=169), when the dynamic threshold is calculated as 0.5 (y 2-y 1) =60, the dynamic threshold is smaller than 63, therefore, the dynamic threshold value 60, y1 is subtracted from the upper transversal coordinates in the upper transversal coordinate set in sequence, the absolute value of the search difference is smaller than the upper transversal coordinates in the corresponding upper transversal coordinate set of the dynamic threshold value, the absolute value of the difference of the 1 st bit in the y1 and upper transversal coordinate set is 0, and is smaller than the dynamic threshold value 60, therefore, the line starting index is "1"; and subtracting the lower transverse line coordinates in the lower transverse line coordinate set from y1 in sequence, searching the lower transverse line coordinates in the corresponding lower transverse line coordinate set with the absolute value of the difference value smaller than the dynamic threshold value, wherein the absolute value of the difference value of the y2 and the 2 nd bit in the lower transverse line coordinate set is 2 and smaller than the dynamic threshold value 60, so that the line termination index is 2, and the line index information [1,2] of the cell is obtained, and the cell represents the cell combining the first line and the second line. The column index information is obtained in the same manner and will not be described in detail herein.
After the row index information and the column index information of all the cells are obtained, the cell row and column index information in the table image can be output so as to be used for subsequent application.
According to the table image cell rank information indexing method, after all cells in the table image are identified, dynamic thresholds are set according to the widths and heights of the cells, so that row and column index information of the cells is determined, the situation that the fixed thresholds are set to miss rank information can be avoided, specific ranks of the cells are well divided, the coverage information is more comprehensive, the calculation amount is small, the logic is simple, and the implementation is more convenient.
Computer apparatus embodiment:
the computer device of the present embodiment includes a controller, and the steps in the above-described embodiment of the table image cell row and column information indexing method are implemented when the controller executes a computer program.
For example, a computer program may be split into one or more modules, one or more modules stored in a memory and executed by a controller to perform the present invention. One or more modules may be a series of computer program instruction segments capable of performing particular functions to describe the execution of a computer program in a computer device.
Computer devices may include, but are not limited to, controllers, memories. Those skilled in the art will appreciate that a computer apparatus may include more or fewer components, or may combine certain components, or different components, e.g., a computer apparatus may also include input and output devices, network access devices, buses, etc.
For example, the controller may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose controllers, digital signal controllers (DigitalSignalProcessor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. The general controller may be a microcontroller or the controller may be any conventional controller or the like. The controller is the control center of the computer device and connects the various parts of the entire computer device using various interfaces and lines.
The memory may be used to store computer programs and/or modules, and the controller implements various functions of the computer device by running or executing the computer programs and/or modules stored in the memory, and invoking data stored in the memory. For example, the memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function (e.g., a sound receiving function, a sound converting to text function, etc.), and the like; the storage data area may store data (e.g., audio data, text data, etc.) created according to the use of the handset, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart memory Card (SmartMediaCard, SMC), secure digital (SecureDigital, SD) Card, flash Card (Flash Card), at least one disk storage device, flash memory device, or other volatile solid state storage device.
Computer-readable storage medium embodiments:
the modules integrated with the computer apparatus of the above embodiments may be stored in a computer-readable storage medium if implemented in the form of software functional units and sold or used as a stand-alone product. With this understanding, implementing all or part of the flow of the table image cell line information indexing method embodiment described above may also be accomplished by a computer program that instructs related hardware, and the computer program may be stored in a computer readable storage medium, which when executed by a controller, may implement the steps of the table image cell line information indexing method embodiment described above. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, executable files or in some intermediate form, etc. The storage medium may include: any entity or device capable of carrying computer program code, a recording medium, a USB flash disk, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a Read-only memory (ROM), a random access memory (RAM, randomAccessMemory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the computer readable medium can be appropriately increased or decreased according to the requirements of the jurisdiction's jurisdiction and the patent practice, for example, in some jurisdictions, the computer readable medium does not include electrical carrier signals and telecommunication signals according to the jurisdiction and the patent practice.
It should be noted that the foregoing is only a preferred embodiment of the present invention, but the design concept of the present invention is not limited thereto, and any insubstantial modifications made to the present invention by using the concept fall within the scope of the present invention.
Claims (10)
1. A method for indexing row and column information of cells of a tabular image, comprising:
identifying all cells in the table image, and acquiring coordinates of four vertexes of each cell;
respectively generating an upper transverse line coordinate set representing an upper transverse line of the cell, a lower transverse line coordinate set representing a lower transverse line of the cell, a left longitudinal line coordinate set representing a left longitudinal line of the cell and a right longitudinal line coordinate set representing a right longitudinal line of the cell according to coordinates of four vertexes of all the cells;
determining a dynamic threshold of each cell according to the length of the left vertical line or the right vertical line of the cell, and determining a column dynamic threshold of each cell according to the length of the upper horizontal line or the lower horizontal line of the cell;
and taking the upper transverse coordinates of each cell and the upper transverse coordinates in the upper transverse coordinate set in turn as row starting indexes of the cell, taking the upper transverse line with the absolute value smaller than the dynamic threshold value as row starting indexes of the cell, taking the lower transverse coordinates of each cell and the lower transverse coordinates in the lower transverse coordinate set in turn as row ending indexes of the cell, taking the lower transverse line with the absolute value smaller than the dynamic threshold value as row ending indexes of the cell, taking the left longitudinal coordinates of each cell and the left longitudinal coordinates in the left longitudinal coordinate set in turn as row starting indexes of the cell, taking the left longitudinal line with the absolute value smaller than the dynamic threshold value as row starting indexes of the cell, taking the right longitudinal coordinates of each cell and the right longitudinal coordinates in the right longitudinal coordinate set in turn as row ending indexes of the cell.
2. The table image cell line information indexing method according to claim 1, wherein:
the step of respectively generating an upper transverse line coordinate set representing an upper transverse line of the cell, a lower transverse line coordinate set representing a lower transverse line of the cell, a left longitudinal line coordinate set representing a left longitudinal line of the cell and a right longitudinal line coordinate set representing a right longitudinal line of the cell according to the coordinates of four vertexes of all the cells comprises the following steps:
performing cluster analysis on the abscissa of the left upper vertex of all the cells to obtain left ordinate coordinates of each left ordinate in the table, and sorting the left ordinate coordinates in ascending order according to the coordinate value to obtain the left ordinate coordinate set; performing cluster analysis on the abscissa of the top right vertex of all the cells to obtain the right ordinate of each right ordinate in the table, and sorting the right ordinate in ascending order according to the coordinate value to obtain the right ordinate set; performing cluster analysis on the ordinate of the left upper vertex of all the cells to obtain upper transverse line coordinates of each upper transverse line in the table, and sorting the upper transverse line coordinates in ascending order of the coordinate values to obtain an upper transverse line coordinate set; and performing cluster analysis on the ordinate of the lower left vertexes of all the cells to obtain lower transverse line coordinates of each lower transverse line in the table, and sorting the lower transverse line coordinates in ascending order of the coordinate values to obtain the lower transverse line coordinate set.
3. The table image cell line information indexing method according to claim 1, wherein:
the step of determining the dynamic threshold value of each cell according to the length of the left or right vertical line of the cell comprises:
if half of the length of the left or right vertical line of the cell is within a first preset range, taking half of the length of the left or right vertical line of the cell as the action threshold;
if half of the length of the left vertical line or the right vertical line of the cell is larger than the upper limit value of the first preset range, taking the upper limit value of the first preset range as the dynamic threshold value;
and if the half length of the left vertical line or the right vertical line of the cell is smaller than the lower limit value of the first preset range, taking the lower limit value of the first preset range as the dynamic threshold value.
4. A tabular image cell rank information indexing method according to claim 3, wherein:
the step of determining the column dynamic threshold of each cell according to the length of the upper or lower transverse line of the cell comprises:
if half of the length of the upper transverse line or the lower transverse line of the cell is in a second preset range, taking half of the length of the upper transverse line or the lower transverse line of the cell as the dynamic threshold value of the row;
if half of the length of the upper transverse line or the lower transverse line of the cell is larger than the upper limit value of the second preset range, taking the upper limit value of the second preset range as the column dynamic threshold value;
and if the half length of the upper transverse line or the lower transverse line of the cell is smaller than the lower limit value of the second preset range, taking the lower limit value of the second preset range as the column dynamic threshold value.
5. The table image cell line information indexing method according to any one of claims 1 to 4, wherein:
the step of identifying all cells in the form image comprises:
identifying all table grid lines in the table image;
and dividing each cell by using an image connected region analysis method.
6. The method for indexing row and column information of table image cells according to claim 5, wherein:
after the step of identifying all the table grid lines in the table image, the method further comprises the following steps:
and performing de-duplication processing on all the table lines.
7. The method for indexing row and column information of cells of a tabular image according to claim 6, wherein:
the step of performing deduplication processing on all the table lines comprises the following steps:
if the distance between any two transverse lines is smaller than the preset distance, combining the two transverse lines into one transverse line;
if the distance between any two longitudinal lines is smaller than the preset distance, combining the two longitudinal lines into one longitudinal line.
8. The table image cell line information indexing method according to any one of claims 1 to 4, wherein:
before the step of identifying all cells in the form image, further comprising:
and carrying out angle recognition on the table image and carrying out image angle correction.
9. A computer apparatus comprising a processor and a memory, characterized in that: the memory stores a computer program which, when executed by the processor, implements the steps of the tabular image cell line information indexing method as claimed in any one of claims 1 to 8.
10. A computer-readable storage medium having stored thereon a computer program, characterized by: the computer program when executed by a controller performs the steps of the tabular image cell row and column information indexing method as claimed in any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211603819.8A CN116071774A (en) | 2022-12-14 | 2022-12-14 | Table image cell rank information indexing method, computer device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211603819.8A CN116071774A (en) | 2022-12-14 | 2022-12-14 | Table image cell rank information indexing method, computer device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116071774A true CN116071774A (en) | 2023-05-05 |
Family
ID=86174010
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211603819.8A Pending CN116071774A (en) | 2022-12-14 | 2022-12-14 | Table image cell rank information indexing method, computer device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116071774A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116911268A (en) * | 2023-09-11 | 2023-10-20 | 中移(苏州)软件技术有限公司 | Table information processing method, apparatus, processing device and readable storage medium |
CN117523591A (en) * | 2023-11-20 | 2024-02-06 | 深圳市六六六国际旅行社有限公司 | Table structure identification method, equipment and storage medium based on frame clustering |
-
2022
- 2022-12-14 CN CN202211603819.8A patent/CN116071774A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116911268A (en) * | 2023-09-11 | 2023-10-20 | 中移(苏州)软件技术有限公司 | Table information processing method, apparatus, processing device and readable storage medium |
CN116911268B (en) * | 2023-09-11 | 2024-01-26 | 中移(苏州)软件技术有限公司 | Table information processing method, apparatus, processing device and readable storage medium |
CN117523591A (en) * | 2023-11-20 | 2024-02-06 | 深圳市六六六国际旅行社有限公司 | Table structure identification method, equipment and storage medium based on frame clustering |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN116071774A (en) | Table image cell rank information indexing method, computer device and storage medium | |
CN110647885B (en) | Test paper splitting method, device, equipment and medium based on picture identification | |
CN112183511A (en) | Method, system, storage medium and equipment for deriving table from image | |
WO1991018368A1 (en) | A polygon-based method for automatic extraction of selected text in a digitized document | |
CN110503682B (en) | Rectangular control identification method and device, terminal and storage medium | |
CN111144282B (en) | Form recognition method and apparatus, and computer-readable storage medium | |
CN110619333A (en) | Text line segmentation method, text line segmentation device and electronic equipment | |
CN114004204B (en) | Table structure reconstruction and text extraction method and system based on computer vision | |
CN109583438B (en) | The recognition methods of the text of electronic image and image processing apparatus | |
CN107766854B (en) | Method for realizing rapid page number identification based on template matching | |
CN110738030A (en) | Table reconstruction method and device, electronic equipment and storage medium | |
CN114005126A (en) | Table reconstruction method and device, computer equipment and readable storage medium | |
CN113449702B (en) | Target detection method and device for remote sensing image, storage medium and electronic equipment | |
CN111161281A (en) | Face region identification method and device and storage medium | |
CN114782970A (en) | Table extraction method, system and readable medium | |
CN114187602A (en) | Method, system, equipment and storage medium for identifying content of house property certification material | |
CN112036294B (en) | Method and device for automatically identifying paper form structure | |
CN111814795B (en) | Character segmentation method, device and computer readable storage medium | |
CN108536769B (en) | Image analysis method, search method and device, computer device and storage medium | |
CN114332866B (en) | Literature curve separation and coordinate information extraction method based on image processing | |
CN115457581A (en) | Table extraction method and device and computer equipment | |
CN114064961A (en) | Method and device for archiving scanned part | |
CN115393884A (en) | Extraction processing method, device and system for chart thematic information | |
CN114140620A (en) | Object straight line contour detection method | |
CN112347865A (en) | Bill correction method based on key point detection |
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 |