Table image correction method, device, electronic device and storage medium
By enhancing and detecting and identifying irregular table pictures, correcting their shapes, the problem of misidentification during OCR recognition of table pictures is solved and the accuracy of data statistics is improved.
Patent Information
- Application Number
- CN202210354601.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-06
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2042-04-06
Smart Images

Figure CN114694149B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a table image correction method, device, electronic equipment and storage medium. Background Art
[0002] In teaching scenarios, some teaching classes are often randomly evaluated, and the scores are usually written on a paper teaching evaluation form. Direct electronicization usually requires a dedicated person to enter the paper form.
[0003] The relevant solution is to call the table image OCR interface and directly use OCR text recognition technology on the photo to obtain the table image data. When scanning or screenshotting standard table images, the OCR text recognition accuracy is relatively ideal. Once the table image itself is not standardized, it is easy to cause misrecognition when using OCR text recognition on the table image, resulting in incorrect statistics of the table data. Summary of the invention
[0004] The present invention provides a table image correction method, device, electronic device and storage medium, which can effectively solve the problem of misrecognition when performing OCR text recognition on table images and improve the statistical accuracy of table data.
[0005] According to one aspect of the present invention, a table image correction method is provided, the method comprising:
[0006] Enhance the edge of the table in the original table image to obtain the target table image;
[0007] Performing edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image;
[0008] According to the target table edge recognition result, the original table image is corrected so that the table shape in the original table image is converted into a preset shape.
[0009] Optionally, the enhancing of the edge of the table in the original table image includes:
[0010] Perform the first convolution process on the original table image to enhance the contrast of the table edge;
[0011] Pooling the original table image after the first convolution process to obtain a candidate table image after eliminating some interference noise points;
[0012] A second convolution process is performed on the candidate table image to obtain the target table image after the table edge contrast enhancement is performed again.
[0013] Optionally, performing edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image includes:
[0014] Determine the gradient information of each pixel in the target table image; the gradient information includes gradient amplitude and gradient direction;
[0015] According to the gradient information of each pixel point, the target table edge point is identified from each pixel point in the target table image as the target table edge identification result.
[0016] Optionally, identifying the target table edge points from each pixel in the target table image according to the gradient information of each pixel includes:
[0017] According to the gradient information of each pixel point, non-maximum suppression is performed on the pixel points in the target table image to delete the pixel points that do not meet the gradient amplitude conditions in the same gradient direction;
[0018] Performing edge point detection on the pixel points after non-maximum suppression to determine candidate table edge points; the table edge points include confirmed table edge points and suspected table edge points;
[0019] The suspected table edge points in the candidate table edge points are screened according to connectivity to obtain the target table edge points after the candidate table edge points are screened.
[0020] Optionally, the correcting the original table image according to the target table edge recognition result includes:
[0021] Extracting the target table contour of the target table image according to the target table edge points in the target table edge recognition result;
[0022] The Douglas-Peucker algorithm is used to compress the target table outline into four points, and four corner points of the table in the target table image are obtained;
[0023] The original table image is corrected according to the four corner points of the table in the target table image.
[0024] Optionally, extracting the target table contour of the target table image according to the target table edge points in the target table edge recognition result includes:
[0025] Scan the target table edge points in the target table edge recognition result, and start contour extraction every time a table edge point is scanned, until all the table edge points are scanned to obtain multiple table contours;
[0026] The target table outline of the target table image is obtained by screening the multiple table outlines obtained by scanning all the table edge points according to the size of the table outline.
[0027] Optionally, the correcting the original table image according to four corner points of the table in the target table image includes:
[0028] According to the four corner points of the table in the target table image, an affine transformation is performed on the original table image to correct the original table image.
[0029] According to another aspect of the present invention, there is provided a table image correction device, comprising:
[0030] A target table image acquisition module is used to enhance the table edge in the original table image to obtain a target table image;
[0031] A target table edge recognition module is used to perform edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image;
[0032] The original table image correction module is used to correct the original table image according to the target table edge recognition result so that the table shape in the original table image is converted into a preset shape.
[0033] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0034] at least one processor; and
[0035] a memory communicatively connected to the at least one processor; wherein,
[0036] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the table image correction method described in any embodiment of the present invention.
[0037] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the table image correction method described in any embodiment of the present invention when executed.
[0038] The technical solution of the embodiment of the present invention is to obtain a target table image by enhancing the edge of the table in the original table image; to perform edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image; and to correct the original table image based on the target table edge recognition result so that the table shape in the original table image is converted into a preset shape. This technical solution can effectively solve the problem of misrecognition when performing OCR text recognition on table images, and improve the statistical accuracy of table data.
[0039] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0041] Figure 1 is a flow chart of a table image correction method provided according to the first embodiment of the present invention;
[0042] Figure 2 This is a flow chart of enhancing the edge of a table in an original table image provided according to the first embodiment of the present invention;
[0043] Figure 3 This is an effect diagram of enhancing the edge of a table in an original table image to obtain a target table image according to the first embodiment of the present invention;
[0044] Figure 4 is a relationship diagram between the gradient direction and the edge direction provided according to the first embodiment of the present invention.
[0045] Figure 5 It is a schematic diagram of the non-maximum suppression principle provided according to the first embodiment of the present invention.
[0046] Figure 6 is a flow chart of a table image correction method provided according to Embodiment 2 of the present invention;
[0047] Figure 7 This is a rendering of a table image correction method provided according to Embodiment 2 of the present invention.
[0048] Figure 8 is a structural schematic diagram of a table image correction device provided according to Embodiment 3 of the present invention;
[0049] Fig. 9 It is a structural schematic diagram of an electronic device for implementing a table image correction method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0051] It should be noted that the terms "first", "second", "target", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0052] Embodiment 1
[0053] Figure 1 This is a flow chart of a table image correction method provided according to the first embodiment of the present invention. This embodiment is applicable to the case of correcting irregular table images. The method can be executed by a table image correction device. The table image correction device can be implemented in the form of hardware and / or software. The table image correction device can be integrated into any electronic device with network communication function. Figure 1 As shown, the method may include:
[0054] S110, enhancing the edge of the table in the original table image to obtain a target table image.
[0055] The original table image may be an irregular table image that is prone to OCR text recognition errors due to the deformity of the table in the image. OCR text recognition technology may be an electronic device that checks the characters printed on paper and then translates the shapes into computer text using a character recognition method. The edge of the table may refer to a collection of pixels with a step change or a roof-like change in the grayscale value of the surrounding pixels. The target table image may be an image that highlights the edges of adjacent image areas of the original table image where the tones differ greatly.
[0056] In this embodiment, optionally, the process of enhancing the edge of the table in the original table image may be:
[0057] The original table image is subjected to a first convolution process to enhance the contrast of the table edge; wherein the convolution process may be to use a convolution kernel to perform a series of operations on each pixel in the image to calculate the image edge.
[0058] Pooling is performed on the original table image after the first convolution process to obtain a candidate table image after eliminating some interference noise points; wherein pooling can be to extract key information of a certain area in the area and reduce noise points in the digital image. Maximum pooling can be to select the maximum value of the image area as the value after pooling of the area. More local details are retained when extracting texture features.
[0059] A second convolution process is performed on the candidate table image to obtain the target table image after the table edge contrast enhancement is performed again. Figure 2 This is a flow chart of enhancing the edge of a table in an original table image according to the first embodiment of the present invention. Figure 3 This is an effect diagram of enhancing the edge of a table in an original table image to obtain a target table image provided by Embodiment 1 of the present invention.
[0060] In this embodiment, by performing pooling on the original table image after the first convolution process, the number of feature quantities output by the convolution layer can be reduced, thereby reducing model parameters and improving overfitting. By performing the second convolution process on the candidate table image, both table edge contrast enhancement and noise removal can be taken into account.
[0061] S120, performing edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image.
[0062] Among them, edge detection and recognition can be to find a set of pixels with drastic brightness changes in the image, which are manifested as contours. The target table edge recognition result can be to identify the edge points of the target table.
[0063] In this embodiment, optionally, edge detection and recognition are performed on the target table image to obtain a target table edge recognition result of the target table image, including:
[0064] Determine the gradient information of each pixel in the target table image; the gradient information includes the gradient amplitude and the gradient direction; wherein, the gradient direction is the direction in which the function f(x, y) changes fastest. When there is an edge in the image, there must be a larger gradient value. On the contrary, when there is a relatively smooth part in the image, the gray value changes less, and the corresponding gradient is also smaller. In image processing, the gradient modulus is referred to as gradient, and the image composed of image gradients is called a gradient image.
[0065] According to the gradient information of each pixel point, the target table edge point is identified from each pixel point in the target table image as the target table edge identification result. Figure 4 is a relationship diagram between the gradient direction and the edge direction provided according to the first embodiment of the present invention.
[0066] In the present embodiment, optionally, target table edge points are identified from each pixel in the target table image based on the gradient information of each pixel, including: based on the gradient information of each pixel, non-maximum suppression is performed on the pixel in the target table image to delete the pixel points that do not meet the gradient amplitude condition in the same gradient direction; edge point detection is performed on the pixel points after non-maximum suppression to determine candidate table edge points; the table edge points include confirmed table edge points and suspected table edge points; suspected table edge points in the candidate table edge points are screened according to connectivity to obtain the target table edge points after the candidate table edge points are screened.
[0067] Among them, non-maximum suppression can be to find the local maximum value and filter out the remaining values in the neighborhood. In this embodiment, non-maximum suppression can be to delete the pixel points that do not meet the gradient amplitude condition in the same gradient direction. Figure 5 1 is a schematic diagram of the non-maximum suppression principle provided according to the first embodiment of the present invention. Figure 5 As shown, for a pixel point A, the line segment d1d2 is the gradient direction. If point A is a local maximum point in a gradient direction, then the gradient of point A should be greater than the gradients of points d1 and d2. We already know the gradients of t1 and t2, so the gradient strength of d1 can be calculated by linear interpolation. Assuming that the gradient direction of line segment d1d2 is w, then: d1 = 1 / w*t1+(w-1) / w*t2. A similar method can be used to calculate the value of d2. If point A has a larger gradient than both d1 and d2, then point A is the edge point selected in this step, otherwise it is not.
[0068] A confirmed table edge point may be a point whose pixel is greater than the upper threshold value maxvalue. The connectivity of a suspected table edge point may be a point between the lower threshold value minvalue and the upper threshold value maxvalue. Connectivity may be an important concept for describing regions and boundaries. Two necessary conditions for the connectivity of two pixels are: the positions of the two pixels are adjacent, and whether the grayscale values of the two pixels meet a specific similarity criterion. For example, let S be a subset of pixels in an image, and there is a path between all pixels in s, then it can be said that the two pixels p and q are connected in S. For any pixel p in S, the set of pixels in S that are connected to the pixel is called the connected component of S. If S has only one connected component, the set S is called a connected set. In this embodiment, the suspected table edge points in the candidate table edge points are screened according to connectivity. If there are edge nodes connected around the candidate table edge points, it is considered to be an edge point, otherwise it is not an edge point.
[0069] In this embodiment, the candidate table edge points are determined by performing non-maximum suppression on the pixels in the target table image, which is convenient for calculation and understanding. The target table edge points are determined by screening the suspected table edge points among the candidate table edge points according to connectivity, which can avoid the situation where some edges of the table are disconnected due to light problems.
[0070] S130, correcting the original table image according to the target table edge recognition result so that the table shape in the original table image is converted into a preset shape.
[0071] In this embodiment, optionally, the original table image is corrected according to the target table edge recognition result, including: extracting the target table outline of the target table image according to the target table edge points in the target table edge recognition result; compressing the target table outline into four points using the Douglas-Peucker algorithm to obtain four corner points of the table in the target table image; and correcting the original table image according to the four corner points of the table in the target table image. The Douglas-Peucker algorithm can be an algorithm that approximates a curve as a series of points and reduces the number of points.
[0072] This solution obtains a target table image by enhancing the edge of the table in the original table image; performs edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image; and corrects the original table image based on the target table edge recognition result so that the table shape in the original table image is converted into a preset shape. This technical solution can effectively solve the problem of misrecognition when performing OCR text recognition on table images and improve the statistical accuracy of table data.
[0073] Embodiment 2
[0074] Figure 6 It is a flow chart of a table image correction method provided according to the second embodiment of the present invention, and this embodiment is optimized based on the above embodiment. The specific optimization is: according to the target table edge recognition result, the original table image is corrected, including: according to the target table edge points in the target table edge recognition result, the target table contour of the target table image is extracted; the Douglas-Peucker algorithm is used to compress the target table contour into four points to obtain the four corner points of the table in the target table image; according to the four corner points of the table in the target table image, the original table image is corrected so that the table shape in the original table image is converted into a preset shape.
[0075] like Figure 6 As shown, the method of this embodiment specifically includes the following steps:
[0076] S610, enhancing the edge of the table in the original table image to obtain a target table image.
[0077] S620, performing edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image.
[0078] S630, extracting a target table outline of the target table image according to the target table edge points in the target table edge recognition result.
[0079] In this embodiment, optionally, based on the target table edge points in the target table edge recognition result, the target table outline of the target table image is extracted, including: scanning the target table edge points in the target table edge recognition result, starting outline extraction each time a table edge point is scanned, until all table edge points are scanned to obtain multiple table outlines; screening the multiple table outlines obtained by scanning all table edge points according to the size of the table outline to obtain the target table outline of the target table image. Among them, scanning the target table edge points can be from left to right, from top to bottom, first scanning one row, and then moving to the starting position of the next row to continue scanning. Screening multiple table outlines can be to use the largest table outline as the target table outline of the target table image.
[0080] S640: Use the Douglas-Peucker algorithm to compress the target table outline into four points to obtain four corner points of the table in the target table image.
[0081] S650: Correct the original table image according to the four corner points of the table in the target table image so that the shape of the table in the original table image is converted into a preset shape.
[0082] In this embodiment, optionally, the original table image is corrected according to the four corner points of the table in the target table image, including: according to the four corner points of the table in the target table image, performing an affine transformation on the original table image to correct the original table image. Figure 7 This is a rendering of a table image correction method provided according to Embodiment 2 of the present invention.
[0083] In this embodiment, the four corner points of the table in the target table image can be the four points where the target table outline is finally compressed by the Douglas-Peucker algorithm. Among them, the affine transformation can be geometrically defined as an affine transformation between two vector spaces or an affine mapping using a linear function followed by a translation transformation. In the case of finite dimensions, each affine transformation can be given by a matrix A and a vector b, which can be written as A and an additional column b. An affine transformation corresponds to the multiplication of a matrix and a vector.
[0084] This solution extracts the target table outline of the target table image according to the target table edge points in the target table edge recognition result; uses the Douglas-Peucker algorithm to compress the target table outline into four points to obtain the four corner points of the table in the target table image; and corrects the original table image according to the four corner points of the table in the target table image so that the table shape in the original table image is converted into a preset shape. This technical solution can reduce computing resource overhead and improve the statistical accuracy of table data.
[0085] Embodiment 3
[0086] Figure 8 1 is a schematic diagram of the structure of a table image correction device provided according to the third embodiment of the present invention. The device can execute the table image correction method provided by any embodiment of the present invention and has the corresponding functional modules and beneficial effects of the execution method. Figure 8 As shown, the device comprises:
[0087] The target table image acquisition module 810 is used to enhance the table edge in the original table image to obtain the target table image;
[0088] A target table edge recognition module 820 is used to perform edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image;
[0089] The original table image correction module 830 is used to correct the original table image according to the target table edge recognition result so that the table shape in the original table image is converted into a preset shape.
[0090] Optionally, the target table image acquisition module 810 further includes:
[0091] The first convolution processing unit is used to perform the first convolution processing on the original table image to enhance the contrast of the table edge;
[0092] Pooling unit: used to perform pooling on the original table image after the first convolution process to obtain a candidate table image after eliminating some interference noise points;
[0093] The second convolution processing unit is used to perform a second convolution processing on the candidate table image to obtain the target table image after the table edge contrast enhancement is performed again.
[0094] Optionally, the target table edge recognition module 820 further includes:
[0095] A gradient information determination unit: used to determine the gradient information of each pixel in the target table image; the gradient information includes a gradient amplitude and a gradient direction;
[0096] Recognition result determination unit: used for identifying target table edge points from each pixel in the target table image according to the gradient information of each pixel, as the target table edge recognition result.
[0097] Optionally, the recognition result determination unit further includes:
[0098] Pixel point deletion subunit: used to perform non-maximum suppression on the pixels in the target table image according to the gradient information of each pixel point, and delete the pixels that do not meet the gradient amplitude condition in the same gradient direction;
[0099] A candidate table edge point determination subunit is used to perform edge point detection on the pixel points after non-maximum suppression to determine candidate table edge points; the table edge points include confirmed table edge points and suspected table edge points;
[0100] The target table edge point determination subunit is used to screen the suspected table edge points among the candidate table edge points according to connectivity, and obtain the target table edge points after screening the candidate table edge points.
[0101] Optionally, the original table image correction module 830 further includes:
[0102] A target table contour extraction unit: used for extracting the target table contour of the target table image according to the target table edge points in the target table edge recognition result;
[0103] A target table outline compression unit is used to compress the target table outline into four points using the Douglas-Peucker algorithm to obtain four corner points of the table in the target table image;
[0104] The original table image correction unit is used to correct the original table image according to the four corner points of the table in the target table image.
[0105] Optionally, the target table outline extraction unit further includes:
[0106] Target table edge point scanning subunit: used to scan the target table edge points in the target table edge recognition result, and start contour extraction every time a table edge point is scanned, until all table edge points are scanned to obtain multiple table contours;
[0107] The target table outline determination subunit is used to screen the multiple table outlines obtained by scanning all the table edge points according to the size of the table outline to obtain the target table outline of the target table image.
[0108] Optionally, the original table image correction unit is specifically used to:
[0109] According to the four corner points of the table in the target table image, an affine transformation is performed on the original table image to correct the original table image.
[0110] A table image correction device provided in an embodiment of the present invention can execute a table image correction method provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0111] Embodiment 4
[0112] Fig. 9 1 is a schematic diagram of the structure of an electronic device for implementing a table image correction method of an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0113] like Fig. 9As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0114] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0115] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 performs the various methods and processes described above, such as a table image correction method.
[0116] In some embodiments, the table image correction method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of a table image correction method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the table image correction method in any other appropriate manner (e.g., by means of firmware).
[0117] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0118] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0119] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0120] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0121] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0122] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0123] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0124] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A table image correction method, characterized in that: The method comprises: Enhance the edge of the table in the original table image to obtain the target table image; Performing edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image; According to the target table edge recognition result, the original table image is corrected so that the table shape in the original table image is converted into a preset shape; The step of performing edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image includes: Determine the gradient information of each pixel in the target table image; the gradient information includes gradient amplitude and gradient direction; Identify the target table edge points from the pixels in the target table image according to the gradient information of each pixel point, as the target table edge identification result; The step of identifying the edge points of the target table from the pixels in the target table image according to the gradient information of each pixel point includes: According to the gradient information of each pixel point, non-maximum suppression is performed on the pixel points in the target table image to delete the pixel points that do not meet the gradient amplitude conditions in the same gradient direction; Performing edge point detection on the pixel points after non-maximum suppression to determine candidate table edge points; the table edge points include confirmed table edge points and suspected table edge points; Screening suspected table edge points among the candidate table edge points according to connectivity, and obtaining target table edge points after screening the candidate table edge points; The step of screening the suspected table edge points in the candidate table edge points according to connectivity to obtain the target table edge points after screening the candidate table edge points includes: If the candidate table edge point is connected to edge nodes around it, then the candidate table edge point is the target table edge point; If there is no edge node connected to the candidate table edge point, the candidate table edge point is not a target table edge point.
2. The method according to claim 1, characterized in that Enhance the table edges in the original table image, including: Perform the first convolution process on the original table image to enhance the contrast of the table edge; The original table image processed by the first convolution process is pooled to obtain a candidate table image after eliminating some interference noise points; the candidate table image is subjected to a second convolution process to obtain the target table image after the table edge contrast is enhanced again.
3. The method according to claim 1, characterized in that Correcting the original table image according to the target table edge recognition result includes: Extracting the target table contour of the target table image according to the target table edge points in the target table edge recognition result; The Douglas-Peucker algorithm is used to compress the target table outline into four points, and four corner points of the table in the target table image are obtained; The original table image is corrected according to the four corner points of the table in the target table image.
4. The method according to claim 3, characterized in that Extracting the target table contour of the target table image according to the target table edge points in the target table edge recognition result includes: Scan the target table edge points in the target table edge recognition result, and start contour extraction every time a table edge point is scanned, until all the table edge points are scanned to obtain multiple table contours; The target table outline of the target table image is obtained by screening the multiple table outlines obtained by scanning all the table edge points according to the size of the table outline.
5. The method according to claim 3, characterized in that: Correcting the original table image according to four corner points of the table in the target table image includes: According to the four corner points of the table in the target table image, an affine transformation is performed on the original table image to correct the original table image.
6. A table image correction device, characterized in that: The device comprises: A target table image acquisition module is used to enhance the table edge in the original table image to obtain a target table image; A target table edge recognition module is used to perform edge detection and recognition on the target table image to obtain a target table edge recognition result of the target table image; An original table image correction module, used for correcting the original table image according to the target table edge recognition result so that the table shape in the original table image is converted into a preset shape; Wherein, the target table edge recognition module further includes: A gradient information determination unit: used to determine the gradient information of each pixel in the target table image; the gradient information includes a gradient amplitude and a gradient direction; Recognition result determination unit: used for identifying target table edge points from each pixel in the target table image according to the gradient information of each pixel, as the target table edge recognition result; Wherein, the recognition result determination unit further includes: Pixel point deletion subunit: used to perform non-maximum suppression on the pixels in the target table image according to the gradient information of each pixel point, and delete the pixels that do not meet the gradient amplitude condition in the same gradient direction; A candidate table edge point determination subunit is used to perform edge point detection on the pixel points after non-maximum suppression to determine candidate table edge points; the table edge points include confirmed table edge points and suspected table edge points; The target table edge point determination subunit is used to screen the suspected table edge points in the candidate table edge points according to connectivity, and obtain the target table edge points after screening the candidate table edge points; The target table edge point determination subunit is further configured to determine that if the candidate table edge point is connected to edge nodes around it, the candidate table edge point is the target table edge point; If there is no edge node connected to the candidate table edge point, the candidate table edge point is not a target table edge point.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the table image correction method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the table image correction method according to any one of claims 1 to 5 when executed.
Citation Information
Patent Citations
Image processing method, device and equipment and computer readable storage medium
CN111179166A
Table recognition method and device, computer equipment and storage medium
CN113792677A