Image processing method and device and electronic equipment

By pre-categorizing, text information extraction and structured reduction processing of structured images, the problem of time-consuming and insufficient accuracy of manual processing in the existing technology is solved, and efficient structured image processing and text information mapping are achieved.

CN118657985APending Publication Date: 2024-09-17ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410698048.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

When the existing technology standardizes external image data, obtaining structured information from a large number of pictures manually is time-consuming and inaccurate, and there is a lack of efficient methods to process structured images.

Method used

An image processing method is provided, which includes pre-classifying the structured image to be processed, determining its category, extracting text information and its location information, performing structured reduction processing, and filling the text information into the corresponding data distribution structure. The method includes a pre-classification module, a text information extraction module, a structured reduction module and a text mapping module, and is implemented through preset target detection models and text clustering models and other technologies.

Benefits of technology

It improves the efficiency and accuracy of image processing, ensures accurate matching between text information and data distribution structure, and realizes end-to-end structured image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657985A
    Figure CN118657985A
Patent Text Reader

Abstract

One or more embodiments of the invention disclose an image processing method and apparatus, and an electronic device. The method comprises the following steps: firstly, pre-classifying a structured image to be processed, determining the category of the structured image, secondly, performing text information extraction processing on the structured image according to the category of the structured image, and obtaining text information in the structured image and information of the position of the text information; then, based on the information of the position where the text information in the structured image is located, structured reduction processing is conducted on the structured data in the structured image, and a data distribution structure of the structured data in the structured image is obtained; and finally, based on the text information in the structured image, the information of the position of the text information in the structured image and the position information of the data distribution structure of the structured data in the structured image, determining a data distribution structure corresponding to the text information, and filling the text information into the data distribution structure corresponding to the text information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This document relates to the field of image processing technology, and in particular to an image processing method, device and electronic device. Background Art

[0002] With the development of Internet technology, data privacy and security are increasingly valued by users. Among them, risky businesses initiated by criminals are a common way to threaten data privacy and security. Such businesses obtain personal sensitive information, corporate trade secrets, user data, and financial information through various channels, seriously affecting personal privacy and security as well as corporate privacy data.

[0003] The data involved in risky businesses are carried in various forms, including database files, log files, spreadsheets, image files or audio files. In order to improve the data privacy security of individuals and enterprises, it is necessary to establish a traceability protection mechanism for potential data security incidents. Specifically, in the traceability stage, the internal and external data of the enterprise can be modeled and compared, such as: internal data modeling, external data standardization, and high-performance comparison. Among them, the external data standardization method includes standardizing external image data. When standardizing external image data, it is time-consuming and labor-intensive to obtain structured information from a large number of images manually, and the accuracy is not enough. Therefore, it is necessary to provide a more efficient method for processing structured images. Summary of the invention

[0004] On the one hand, one or more embodiments of the present specification provide an image processing method, including: pre-classifying a structured image to be processed to determine a category of the structured image, wherein the structured image is an image including structured data; performing text information extraction processing on the structured image according to the category of the structured image to obtain text information in the structured image and information on a location where the text information is located; performing structured restoration processing on the structured data in the structured image based on the information on the location where the text information is located in the structured image to obtain a data distribution structure of the structured data in the structured image; determining a data distribution structure corresponding to the text information based on the text information in the structured image, information on the location where the text information is located in the structured image, and position information of the data distribution structure of the structured data in the structured image, and filling the text information into the data distribution structure corresponding to the text information.

[0005] On another aspect, one or more embodiments of the present specification provide an image processing device, comprising: an image pre-classification module, which pre-classifies a structured image to be processed and determines the category of the structured image, wherein the structured image is an image including structured data; a text information extraction module, which performs text information extraction processing on the structured image according to the category of the structured image, and obtains text information in the structured image and information about the location of the text information; an image structured restoration module, which performs structured restoration processing on the structured data in the structured image based on information about the location of the text information in the structured image, and obtains a data distribution structure of the structured data in the structured image; and a text mapping module, which determines a data distribution structure corresponding to the text information based on the text information in the structured image, information about the location of the text information in the structured image, and position information of the data distribution structure of the structured data in the structured image, and fills the text information into the data distribution structure corresponding to the text information.

[0006] On another aspect, one or more embodiments of the present specification provide an electronic device, comprising: a processor; and a memory arranged to store computer-executable instructions, wherein when the executable instructions are executed, the processor can: pre-classify a structured image to be processed and determine a category of the structured image, wherein the structured image is an image including structured data; perform text information extraction processing on the structured image according to the category of the structured image to obtain text information in the structured image and information on a location where the text information is located; perform structured restoration processing on the structured data in the structured image based on the information on the location where the text information is located in the structured image to obtain a data distribution structure of the structured data in the structured image; determine a data distribution structure corresponding to the text information based on the text information in the structured image, information on the location where the text information is located in the structured image, and position information of the data distribution structure of the structured data in the structured image, and fill the text information into the data distribution structure corresponding to the text information.

[0007] On another aspect, one or more embodiments of the present specification provide a storage medium for storing a computer program, which can be executed by a processor to implement the following process: pre-classifying a structured image to be processed to determine a category of the structured image, wherein the structured image is an image including structured data; performing text information extraction processing on the structured image according to the category of the structured image to obtain text information in the structured image and information on a location where the text information is located; performing structured restoration processing on the structured data in the structured image based on the information on the location where the text information is located in the structured image to obtain a data distribution structure of the structured data in the structured image; determining a data distribution structure corresponding to the text information based on the text information in the structured image, information on the location where the text information is located in the structured image, and position information of the data distribution structure of the structured data in the structured image, and filling the text information into the data distribution structure corresponding to the text information. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] In order to more clearly illustrate one or more embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0009] Figure 1 is a schematic flow chart of an image processing method according to an embodiment of the present specification;

[0010] Figure 2 is a schematic diagram of the implementation principle of an image processing method according to an embodiment of this specification;

[0011] Figure 3 is a schematic block diagram of an image processing device according to another embodiment of the present specification;

[0012] Figure 4 It is a schematic block diagram of an electronic device according to an embodiment of the present specification. DETAILED DESCRIPTION

[0013] One or more embodiments of the present specification provide an image processing method, device, and electronic device.

[0014] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the following will be combined with the drawings in one or more embodiments of this specification to clearly and completely describe the technical solutions in one or more embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this document.

[0015] like Figure 1 As shown, an embodiment of this specification provides an image processing method, and the execution subject of the method can be a terminal device or a server, wherein the terminal device can be a certain terminal device such as a mobile phone, a tablet computer, or a computer device such as a laptop or a desktop computer, or an IoT device (specifically such as a smart watch, a car device, etc.). The server can be an independent server, or a server cluster composed of multiple servers, etc. The server can be a background server in the financial field or the online shopping field, or a background server of an application, etc. In this embodiment, the server is used as an example for detailed description. For the execution process of the terminal device, please refer to the following related content, which will not be repeated here. The method can specifically include the following steps:

[0016] In step S102, the structured image to be processed is pre-classified to determine the category of the structured image, where the structured image is an image including structured data.

[0017] The structured data in the embodiments of this specification may be log information, browsing history information, user payment transaction data, etc. stored in the form of tables, sequences, etc. The organization form of structured data may be a relational structure (e.g., table), a graphical structure, a tree structure, etc. A structured image is an image containing structured data, such as an image containing tabular data, an image containing chat information, an image containing transaction flow information, etc. In a structured image, structured data is presented in the form of an image containing specific marks, symbols, or layouts, and these structured data can be directly parsed and processed by a computer.

[0018] The storage method (or storage format) of structured data can be Base64 (a method of encoding binary data using text), URL (Uniform Resource Locator) format, or local image storage path, etc. The method of the embodiments of this specification is compatible with structured data of multiple storage methods and has strong data compatibility.

[0019] After obtaining the structured image to be processed, the structured image is first pre-classified. In implementation, the standard for pre-classifying the structured image can be determined according to user needs, for example, the structured image can be pre-classified according to the visual attributes of the image (such as color, texture, shape, size, etc.), or according to the image features of the image (such as image structure, pixels, contrast or clarity, etc.), or according to the semantic information of the image.

[0020] The structured images can be pre-classified manually or by using a pre-trained classification model, such as the DETR (DEtection Transformer, an end-to-end target detection network based on Transformer) model, the YOLO (You Only Look Once, a target detection algorithm) model, and the Faster R-CNN (a target detection network based on deep learning) model.

[0021] In step S104, text information extraction processing is performed on the structured image according to the category of the structured image to obtain text information in the structured image and information about the location of the text information.

[0022] In implementation, the method of extracting text information from a structured image may be to first detect text information based on edge detection or connected region methods, then match and identify the text information in the structured image with a predefined template based on a template matching method, and finally obtain the information about the text information and its location. A convolutional neural network model may also be used to extract text information, for example, various OCR (Optical Character Recognition) models or CTPN models (Connectionist Text Proposal Network) are used to obtain information about the text information and its location.

[0023] In addition, the categories of structured images can be combined to perform text information extraction processing on structured images of different categories in a more targeted manner.

[0024] In step S106, based on the information about the position of the text information in the structured image, a structured restoration process is performed on the structured data in the structured image to obtain a data distribution structure of the structured data in the structured image.

[0025] Among them, the information on the location of the text information in the structured image can be the location information of the text box corresponding to the text information, or it can be the coordinate information of the text information, or it can be other location information that can identify the text information (such as: the location information of the area where the text information is highlighted).

[0026] Performing structured restoration processing on structured data in structured images can be understood as identifying and restoring the data distribution structure of structured data in structured images. For example, performing structured restoration processing on table images can obtain the distribution structure of table data (or table structure). Performing structured restoration processing on chat screenshot images can obtain the data distribution structure corresponding to the receiver and sender in the chat message. The result obtained by structured restoration processing is usually a data distribution structure in the form of a string in CSV (Comma-Separated Values) format. For example, the CSV string obtained after performing structured restoration processing on table images can be recognized by a computer program as an Excel table text. The CSV string obtained after performing structured restoration processing on chat screenshot images can be recognized by a computer program as multiple lines of chat text corresponding to the chat message.

[0027] In implementation, different structural restoration processing methods can be used for different structured image categories. For example, for images containing table data, the table structure can be determined by determining the horizontal and vertical lines of the table. For images containing transaction flow information, the data distribution structure of the image can be determined by determining the positions of text boxes of different transaction type names.

[0028] In step S108, based on the text information in the structured image, the information about the location of the text information in the structured image, and the location information of the data distribution structure of the structured data in the structured image, the data distribution structure corresponding to the text information is determined, and the text information is filled into the data distribution structure corresponding to the text information.

[0029] In implementation, the data distribution structure corresponding to the text information can be determined based on the matching degree between the information of the location of the text information in the structured image and the location information of the data distribution structure of the structured data in the structured image, and then the text information can be filled into the data distribution structure corresponding to the text information. The above matching degree can be different according to different structured image categories. For example, for images containing tabular data, it can be based on the coincidence between the information of the location of the text information in the structured image and the location information of the data distribution structure of the structured data in the structured image. For images containing transaction flow information, it can be based on the matching degree between the groupings based on different transaction type names between the information of the location of the text information in the structured image and the location information of the data distribution structure of the structured data in the structured image. For images containing chat information, it can be based on the matching degree between the groupings based on a single chat information between the information of the location of the text information in the structured image and the location information of the data distribution structure of the structured data in the structured image.

[0030] The embodiment of this specification provides an image processing method, firstly, a structured image to be processed is pre-classified to determine the category of the structured image, then the structured image is subjected to text information extraction processing to obtain the text information in the structured image and the information of the location of the text information, then based on the information of the location of the text information in the structured image, the structured data in the structured image is subjected to structured restoration processing to obtain the data distribution structure of the structured data in the structured image, and finally, based on the text information in the structured image, the information of the location of the text information in the structured image and the location information of the data distribution structure of the structured data in the structured image, the data distribution structure corresponding to the text information is determined, and the text information is filled into the data distribution structure corresponding to the text information. In this way, by pre-classifying the structured image, the text can be structured and logically distinguished, thereby ensuring the accuracy of the structured restoration processing and the accuracy of the matching between the text information and the data distribution structure. By performing structured restoration processing on the structured data in the structured image and obtaining the data distribution structure of the structured data in the structured image, a position that better matches the text information can be obtained. By determining the data distribution structure corresponding to the text information and filling the text information into the data distribution structure corresponding to the text information, text mapping is achieved. The method of the embodiment of this specification can achieve end-to-end structured image processing from text information extraction to structured restoration processing and then to text mapping, which is conducive to improving the efficiency and accuracy of image processing.

[0031] In the embodiment of the present specification, the processing of the above step S102 can be varied. An optional processing method is provided below. For details, please refer to the processing of the following steps S1022-S1024.

[0032] In step S1022, the structured image is preprocessed.

[0033] In one embodiment, the structured image may be preprocessed by adjusting the size of the structured image based on the aspect ratio of the structured image. Specifically, the aspect ratio of the structured image is first calculated, and if the calculated aspect ratio exceeds a preset aspect ratio threshold, the image aspect ratio is reduced so that the size of the structured image meets the preset requirement.

[0034] By preprocessing the structured image, the structured images of different storage formats can be adjusted, thereby improving the accuracy of structured image pre-classification, as well as improving the efficiency of text information extraction and structured restoration processing of structured data. Taking a chat image containing chat information as an example, for a long chat image, if the image aspect ratio is too large, it may lead to poor image clarity (for example: when using an OCR model to recognize text information in a structured image, the aspect ratio value exceeds the preset aspect ratio threshold, which may cause OCR to be unable to recognize or the recognition result is not accurate enough), thereby affecting the accuracy of text information extraction.

[0035] In step S1024, a preset target detection model is used to pre-classify the preprocessed structured image based on pixel information to determine the category of the structured image.

[0036] The preset target detection model can be a DETR model, a YOLO model, a Faster R-CNN model, etc. Among them, the transformer-based end-to-end DETR model associates object queries with feature maps to predict the bounding box and category of the target object, which can further effectively improve the accuracy of structured image pre-classification.

[0037] In the embodiment of the present specification, the processing of the above step S104 can be varied according to the type of the structured image. If the structured image is an image containing table data, the processing of step S104 can refer to the processing of the following steps S1040-S1042:

[0038] In step S1040, based on the row and column distribution information of the table data contained in the structured image, a preset object detection model is used to perform layout analysis processing on the structured image to determine the number of tables in the structured image.

[0039] The row and column distribution information of the table data includes the number of rows of the table data, row data distribution, number of columns, column data distribution, etc. The preset target detection model can adopt the DETR model, YOLO model, Faster R-CNN model, etc., and the DETR model is preferred.

[0040] After determining through pre-classification that the current structured image is an image containing tabular data, according to step S1040, the current structured image is further detected from top to bottom end-to-end using a preset target detection model, and the current structured image is analyzed and processed based on the row and column distribution information to determine the number of tables.

[0041] In step S1042, based on a preset text information extraction model, the text information in each table in the structured image and the information of the location of the text information are obtained.

[0042] The text information of the image containing the table data may be the table text data, and the information obtained at the location where the text information is located may be a table text box corresponding to the table text data.

[0043] In implementation, the preset text information extraction model can adopt an OCR model, such as a neural network model, a hidden Markov model, a conditional random field model, a maximum entropy model, etc., which is not limited in the embodiments of this specification. The more advanced the OCR model is, the more robust the background color of the image will be when the text information extraction process is performed based on the OCR model, and the structured data in the structured image is subsequently restored to a structured state, which is conducive to improving the processing effect of the structured image.

[0044] Through the above steps S1040-S1042, the structured image is subjected to layout analysis processing and text information extraction processing in turn to obtain the text information of the structured image and the information on the location of the text information. For images containing table data (such as table screenshots), layout analysis processing can be performed to determine whether the image contains tables and the number of tables contained, so as to perform table structure recognition based on the layout analysis results. For images containing table data, text information extraction processing can be performed to obtain text information in the image, and the information on the location of the text information can be determined in combination with the results of the layout analysis.

[0045] In the embodiment of the present specification, after the above step S1040, the above step S104 may further include the following step S1044:

[0046] In step S1044, if there are multiple tables in the structured image, the structured image is cropped into multiple sub-table images, each of which contains one or more tables.

[0047] After the image containing table data is analyzed and processed by the preset target detection model, the structured image may contain one table or multiple tables. If the structured image contains one table, step S1042 is executed to obtain the text information in the table of the structured image and the information of the location of the text information based on the preset text information extraction model. If the structured image contains multiple tables, the structured image is further processed after cropping (i.e., the structured image is cropped into multiple sub-table images, each of which contains one or more tables) to obtain multiple sub-table images, each of which is regarded as an independent structured image containing one table or a structured image containing multiple tables, and based on the preset text information extraction model, the text information in the table of the structured image and the information of the location of the text information are obtained. For the sub-structured image containing multiple tables (i.e., the sub-table image), it can be further cropped to obtain a structured image containing one table, and then the text information in the table of the structured image and the information of the location of the text information are obtained.

[0048] In the embodiment of the present specification, if each sub-table image contains a table, then after the above step S1044, the above step S104 may further include the following steps S1046-S1048:

[0049] In step S1046 , the ratio between the table area of ​​any sub-table image and the table area of ​​the structured image is calculated.

[0050] In step S1048, if the calculated ratio is less than a preset area ratio threshold, it is determined that any sub-table image is an image containing an instant messaging conversation record.

[0051] In practical applications, since images containing instant messaging conversation records (such as chat screenshots) may contain text boxes with smaller areas and more regular arrangements, the above text boxes may be mistakenly identified as sub-table images after the structured image is cropped. The embodiment of this specification makes a judgment based on the ratio between the table area area of ​​each sub-table image and the table area area of ​​the structured image. If the ratio corresponding to the image with a smaller area to be confirmed is less than a preset area ratio threshold, the image with a smaller area to be confirmed is determined to be an image containing instant messaging conversation records, otherwise, it is determined to be a sub-table image. This structured image processing method based on area ratio can further correct the structured image after pre-classification processing, thereby improving the accuracy of structured image processing.

[0052] If the structured image is an image containing a conversation record of an instant messaging, the processing of step S104 may refer to the processing of step S10410:

[0053] In step S10410, text information extraction processing is performed on the image containing the instant messaging conversation record to obtain multiple instant messaging text boxes in the image containing the instant messaging conversation record and text data corresponding to each instant messaging text box.

[0054] Taking the case where the image of the instant messaging information is a chat image as an example, it is necessary to obtain multiple chat text boxes in the chat image and chat text data corresponding to each chat text box.

[0055] In implementation, one instant messaging text box corresponds to one instant messaging message.

[0056] In addition, if the category of the structured image obtained according to the pre-classification result is an image other than an image containing table data and an image containing instant messaging conversation records, the text information in the structured image can be obtained by sequential splicing based on the information of the location of the text information in the structured image (such as the coordinates of the four points of the text box in the structured image). Taking two text boxes as an example, the text information in the structured image can be obtained by sequential splicing based on the horizontal coordinates X1 and X2 of the two text boxes of other images.

[0057] In the embodiment of the present specification, the processing of the above step S106 can be varied according to the type of the structured image. If the structured image is an image containing table data, the processing of step S106 can refer to the processing of the following steps S10602 - S10610 .

[0058] In step S10602, based on the information about the location of the text information in the structured image, a preset text clustering model is used to obtain horizontal clustering information and vertical clustering information corresponding to the first preset reference point of each table in the structured image.

[0059] The text information of an image containing tabular data may be tabular text data, the information obtained at the location where the text information is located may be a tabular text box corresponding to the tabular text data, the data distribution structure of the structured data may be a tabular structure, and the horizontal clustering information corresponds to the horizontal clustering grouping results, and the vertical clustering information corresponds to the vertical clustering grouping results.

[0060] The first preset reference point can be set according to the specific application scenario. Each table corresponds to a first preset reference point. In subsequent steps, corresponding processing is performed based on the first preset reference point. For example, the X and Y coordinates of the upper left corner of the table can be set as the first preset reference point.

[0061] The preset text clustering model can adopt the KNN (K-Nearest Neighbor) clustering model or the DBSCAN (Density-Based Clustering of Application with Noise) clustering model. Among them, the horizontal clustering information and vertical clustering information obtained based on the DBSCAN clustering model are more accurate, which is conducive to improving the accuracy of the structured restoration results.

[0062] The processing of step S10602 can be understood as preprocessing of the table text box. The table structure in the image containing the table data is usually regular in the horizontal direction, but different in the vertical direction due to the different lengths of the table text data, which leads to uneven distribution of cells in the table text box. By preprocessing the table text box and obtaining the horizontal clustering information and the vertical clustering information, the vertical deflection data can be effectively excluded, which is conducive to obtaining more accurate table lines (i.e., the vertical lines and horizontal lines of the table).

[0063] In addition, the preprocessing of the table text box can also include filtering outliers in the table text box, that is: after using the preset text clustering model to obtain the horizontal clustering information and vertical clustering information corresponding to the first preset reference point of each table in the structured image, the obtained horizontal clustering information and vertical clustering information can be further filtered out of outliers, thereby removing interference from text information such as graffiti and mosaics in the table text data, which is conducive to further obtaining more accurate table lines and improving the accuracy of structured image processing.

[0064] In step S10604, based on the horizontal clustering information corresponding to the first preset reference point of each table and the vertical coordinate of the first preset reference point, a table structure horizontal line coordinate list of each table in the structured image is determined, and the horizontal line coordinate list corresponds to the horizontal line of each table in the table image.

[0065] In implementation, taking Table M as an example, after obtaining the horizontal clustering grouping result of Table M, it can be determined whether to add the vertical coordinate to the corresponding table structure horizontal line coordinate list based on whether the vertical coordinate of the first preset reference point (such as: the Y coordinate value of the upper left corner of Table M) jumps. Since the vertical coordinates of the tables of the same horizontal clustering grouping are the same, if the vertical coordinate of the first preset reference point jumps, it is determined that the current vertical coordinate is different from other vertical coordinates in the same horizontal clustering grouping, and it is necessary to add the vertical coordinate to the corresponding table structure horizontal line coordinate list, so as to add a new horizontal line accordingly. If the vertical coordinate of the first preset reference point does not jump, it is determined that the current vertical coordinate is the same as other vertical coordinates in the same horizontal clustering grouping, the corresponding table structure horizontal line coordinate list remains unchanged, and no new horizontal line is added.

[0066] In step S10606, based on the longitudinal clustering information corresponding to the first preset reference point of each table and the horizontal coordinate of the first preset reference point, a table structure vertical line coordinate list of each table in the structured image is determined, and the vertical line coordinate list corresponds to the longitudinal line of each table in the structured image.

[0067] In implementation, continuing to take Table M as an example, after obtaining the vertical line clustering grouping result of Table M, it can be determined whether to add the horizontal coordinate to the corresponding table structure vertical line coordinate list based on whether the horizontal coordinate of the first preset reference point (such as: the X coordinate value of the upper left corner of Table M) jumps. Since the horizontal coordinates of the tables of the same vertical clustering grouping are the same, if the horizontal coordinate of the first preset reference point jumps, it is determined that the current horizontal coordinate is different from other horizontal coordinates in the same vertical clustering grouping, and it is necessary to add the horizontal coordinate to the corresponding table structure vertical line coordinate list, so as to add a new vertical line accordingly. Otherwise, if the horizontal coordinate of the first preset reference point does not jump, it is determined that the current horizontal coordinate is the same as other horizontal coordinates in the same vertical clustering grouping, and it is not necessary to add the horizontal coordinate to the corresponding table structure vertical line coordinate list. The corresponding table structure vertical line coordinate list remains unchanged, and no new vertical line is added.

[0068] In step S10608, based on the relationship between the longitudinal line and the position of the text information, the longitudinal line is calibrated to obtain the calibrated longitudinal line.

[0069] In implementation, the method for calibrating the longitudinal line may be: determining whether the longitudinal line crosses the position where the text information is located (i.e., determining whether the longitudinal line crosses the table text box), the position where the longitudinal line crosses the position where the text information is located (i.e., the position where the longitudinal line crosses the table text box), and the number of positions where the text information is crossed (i.e., the number of positions where the longitudinal line crosses the table text box); if the longitudinal line does not cross the table text box, the longitudinal line is retained; if the longitudinal line crosses the table text box and the crossing position is close to the edge of the table text box, the longitudinal line is retained; if the longitudinal line crosses the table text box, the crossing position is close to the middle of the table text box, and the number of positions where the longitudinal line crosses the table text box is less than a preset number, it may be an error caused by text information extraction, and the longitudinal line is retained; if the longitudinal line crosses the table text box, the crossing position is close to the middle of the table text box, and the crossing number exceeds the preset number, the longitudinal line is determined to be content in the text information (for example: the column numbers in the table corresponding to the longitudinal line are all 1, which may be identified as a longitudinal line), and the longitudinal line is abandoned. The calibration method can effectively avoid the situation where the longitudinal lines obtained by longitudinal clustering are inaccurate due to uneven text lengths, which is beneficial to improving the accuracy of the data distribution structure obtained by structured restoration processing.

[0070] In step S10610, the table structure of each table in the structured image is determined according to the horizontal lines and the calibrated vertical lines of each table in the structured image.

[0071] Through the above steps S10602-S10610, the table text box is pre-processed and horizontal clustering and vertical clustering are performed, so that redundant lines can be removed and the table structure corresponding to the table text box can be obtained, which is conducive to improving the accuracy of structured restoration.

[0072] In the embodiment of this specification, after the above step S10604, the above step S106 may further include the following step S10612:

[0073] In step S10612, based on the height of the position where the text information is located in the structured image, clustering processing is performed on the table structure horizontal line coordinate list of each table in the structured image to obtain an updated table structure horizontal line coordinate list.

[0074] In implementation, for images containing table data, clustering can be performed again according to the height of the table text box (ie, the difference in the vertical coordinates of the table text box).

[0075] Since the information on the location of text information obtained by performing text information extraction on structured images may have certain errors, for images containing tabular data, the vertical coordinates of the text boxes in the same row of the table may not be completely equal. By clustering the table structure horizontal line coordinate list of each table in the structured image again, redundant coordinate values ​​can be effectively removed to obtain a more accurate table structure horizontal line coordinate list, thereby improving the accuracy of the structured restoration processing.

[0076] Accordingly, in the embodiment of this specification, after the above step S10606, the above step S106 may further include the following step S10614:

[0077] In step S10614, based on the height of the position where the text information is located in the structured image, clustering processing is performed on the table structure vertical line coordinate list of each table in the structured image to obtain an updated table structure vertical line coordinate list.

[0078] The principle of this step is the same as that of the above step S10612 and will not be repeated here.

[0079] In the embodiment of the present specification, the processing of the above step S106 can be varied according to the type of the structured image. If the structured image is an image containing an instant messaging conversation record, the processing of step S106 can refer to the processing of the following steps S10616-S10620.

[0080] In step S10616, based on the information of the location of the text information in the structured image and a second preset reference point in the location of the text information in the structured image, a preset text clustering model is used to perform a first clustering process on the information of the location of the text information in the structured image to obtain an instant messaging text box corresponding to each instant messaging message in the structured image, and the instant messaging text box corresponding to each instant messaging message is a group of instant messaging text boxes.

[0081] Among them, the data distribution structure of the structured data in the image containing the conversation record of the instant messaging is an instant messaging text box (such as a chat text box). The second preset reference point can be set according to the specific application scenario, and each instant messaging text box corresponds to a second preset reference point. For example, the point determined by the horizontal coordinate X and the vertical coordinate Y in the upper left corner of the instant messaging text box can be set as the second preset reference point.

[0082] In implementation, the preset text clustering model can adopt the DBSCAN model, and the DBSACN model can be used to perform vertical clustering processing based on the vertical coordinate of the upper left corner of the instant messaging information box, and the instant messaging information boxes with the same vertical coordinate value are clustered into a group (for example, an instant messaging message may contain only one line of text information or multiple continuous lines of text information, then the one line of text information is clustered into a group of instant messaging text boxes, and the multiple continuous lines of text information are clustered into a group of instant messaging text boxes). By obtaining the instant messaging text boxes through clustering processing, the relevant information of the sender and the receiver in the instant messaging scenario can be efficiently and accurately restored, thereby providing a basis for the structured matching business and consistency verification business of data leakage information in risky transaction activities.

[0083] In step S10618, a second clustering process is performed on the information of the position of the instant messaging text box corresponding to each instant messaging message obtained by the first clustering process according to the background colors of the instant messaging text boxes between adjacent groups, to obtain an instant messaging text box cluster classified based on the background color, and an updated group of instant messaging text boxes corresponding to each instant messaging message is determined based on the instant messaging text box cluster containing a type of background color.

[0084] In implementation, after obtaining the information of the position of the instant messaging text box corresponding to each instant messaging message through the first clustering process, multiple groups of different instant messaging text boxes can be obtained, and then a second clustering process can be performed according to the background colors of the instant messaging text boxes between adjacent groups to obtain instant messaging text box clusters containing only one type of background color and instant messaging text box clusters containing two or more types of background colors, and the instant messaging text box clusters containing only one type of background color are merged to obtain the same instant messaging text box (i.e., obtain an updated group of instant messaging text boxes). Since the background color of the same instant messaging message of the same receiver (or sender) is the same, by performing a second clustering process based on the background color of the instant messaging text box, the instant messaging text box misgrouping caused by blank lines, line breaks, etc. in the same instant messaging message sent by the receiver (or sender) can be merged (i.e., text structured splicing process), thereby ensuring that the same instant messaging message of the same receiver (or sender) corresponds to one instant messaging message text box, which is conducive to improving the accuracy of image structure restoration.

[0085] In step S10620, the updated group of instant messaging text boxes are numbered to determine the group number of the instant messaging text boxes.

[0086] Through the above steps S10616-S10620, the embodiment of this specification comprehensively considers the position information and background color information of the instant messaging text box, and makes full use of the information of the structured image itself to post-process the text grouping, thereby avoiding the situation where the same instant messaging information text box is incorrectly split, which is conducive to further improving the accuracy of the structured restoration processing.

[0087] In the embodiment of the present specification, the processing of the above step S108 can be varied according to the type of the structured image. If the structured image is an image containing table data, the processing of step S108 can refer to the processing of the following steps S10802 - S10804 .

[0088] In step S10802, based on the information of the position of the text information in the structured image and the position information of the table structure corresponding to the structured image, an intersection-over-union algorithm is used to determine the position matching result between the position of the text information in the structured image and the table structure, and the table corresponding to the position of the text information in the structured image is determined based on the position matching result.

[0089] The intersection-in-union algorithm is a method used in target detection. It is the overlap rate of the generated candidate box (the location of the table structure corresponding to the structured image) and the original labeled box (the location of the text information in the structured image), that is, the ratio of the intersection and union between the candidate box and the original labeled box. The ideal intersection-in-union ratio is 1, that is, the candidate box completely overlaps the original labeled box.

[0090] In implementation, the row mapping of the table text box and the column mapping of the table text box can be performed separately. Specifically, first, according to the table structure of each table obtained in step S106 (the data distribution structure of the structured data in the structured image), the horizontal lines and vertical lines of each table can be determined, and the horizontal and vertical coordinates of each cell in the table structure are determined based on the horizontal lines and vertical lines; secondly, the maximum value of the first intersection and union ratio of the upper and lower edge vertical coordinates of each table text box and the upper and lower edge vertical coordinates of the cell in the table structure is calculated, so as to determine the row of the table structure cell corresponding to the table text box; then the maximum value of the second intersection and union ratio of the left and right edge horizontal coordinates of each table text box and the left rear edge horizontal coordinate of the cell in the table structure is calculated, so as to determine the column of the table structure cell corresponding to the table text box; finally, based on the determined row and column of the table structure cell, the table structure corresponding to the table text box is determined.

[0091] By using the intersection-and-union algorithm to determine the position matching results, it is possible to effectively deal with interference operations such as human graffiti and local mosaics, improve the fault tolerance of text mapping, and help retain the original structured information to the greatest extent, thereby improving the accuracy of structured data processing and facilitating subsequent data tracing and data verification services.

[0092] In step S10804, the text information corresponding to the position where the text information in the structured image is located is filled into the table corresponding to the position where the text information in the structured image is located.

[0093] After determining the table structure corresponding to the position where the text information in the structured image is located, the text information corresponding to the table text box is filled into the table, thereby completing the text mapping.

[0094] In the embodiment of the present specification, if the structured image is an image containing tabular data, the processing of the above step S108 can further verify the structure of the data distribution structure corresponding to the text information filled in the text information, and the processing of the above step S108 can also include the processing of the following steps S10806-S10808.

[0095] In step S10806, if the matching result between the position of the text information in the structured image and the position of the table structure is that the maximum intersection-over-union ratio of the position of the text information in the structured image corresponds to multiple cells in the table structure, then the text information corresponding to the position of the text information in the structured image is determined to be the merged data of multiple cells, and the text information is split accordingly according to the matching ratio and position information of each cell to obtain the text information corresponding to each cell in the table.

[0096] For table text boxes that contain cell merging, text mapping is completed by splitting text information, which can further improve the accuracy of text mapping.

[0097] In step S10808, if the matching result of the position of the text information in the structured image and the position of the table structure is that the maximum intersection-over-union ratio of the positions of the text information in multiple structured images corresponds to the same cell in the table structure, then the text information corresponding to the position of the text information in the structured image is determined to be the split data of the same cell, and the text information corresponding to the positions of the text information in multiple structured images is merged and filled into the same cell.

[0098] For table text boxes containing split cells, text mapping can be completed by merging text information to further improve the accuracy of text mapping.

[0099] In the embodiment of the present specification, the processing of the above step S108 can be varied according to the type of the structured image. If the structured image is an image containing table data, the processing of step S108 can refer to the processing of the following steps S10810-S10814.

[0100] In step S10810, according to the obtained text merge request, a merge tag is added to the corresponding data distribution structure, and the merge tag includes the group number of the data distribution structure.

[0101] In implementation, the information in the merge tag of the data distribution structure may include the group number of the data distribution structure and prompt information on whether to merge.

[0102] In step S10812, if the target instant messaging text box does not include a merge tag, the text information in the structured image is filled into the target instant messaging text box corresponding to the structured image based on the information of the position of the text information in the structured image.

[0103] After adding the merge tag to the corresponding data distribution structure, a target instant messaging text box including the merge tag and a target instant messaging text box not including the merge tag are obtained.

[0104] In implementation, if the target instant messaging text box does not contain a merge tag, it means that the current instant messaging text box has only one line of instant messaging information or multiple consecutive lines of instant messaging information, and there is no misgrouping caused by blank lines, line breaks, etc., and there is no background color deviation, so the text mapping process within the group can be directly performed.

[0105] In step S10814, if the target instant messaging text box includes a merge tag, based on the information about the location of the text information in the structured image, the text information of the structured image corresponding to the instant messaging text box with the corresponding group number in the merge tag is merged.

[0106] If the target instant messaging text box contains a merge tag, it means that the current instant messaging text box may be an updated instant messaging text box obtained by clustering instant messaging text boxes that only contain one type of background color (corresponding to step S10618), and inter-group text merging processing is required, and text information merging processing is required according to the corresponding group number to ensure that the obtained text information is the same message from the same sender (or receiver).

[0107] The schematic diagram of the implementation principle of the image processing method in the embodiment of this specification can be found in Figure 2 As shown by Figure 2 It can be seen that taking structured images including two categories of images, namely, images containing tabular data and images containing instant messaging conversation records, as an example, after obtaining the structured image to be processed (input data), the structured image is first pre-classified and subjected to layout analysis (layout analysis is performed on the image containing tabular data), and then the image is structurally restored. The structural restoration process may include two aspects: on the one hand, the text information in the structured image is extracted; on the other hand, according to the results of the pre-classification, the data distribution structure of the image containing tabular data and the image containing instant messaging conversation records are structurally restored respectively; finally, based on the results of the structural restoration process, the text information is filled into the data distribution structure corresponding to the text information, thereby realizing text structural mapping.

[0108] In summary, specific embodiments of the present subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recorded in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing can be advantageous.

[0109] The above is an image processing method provided by one or more embodiments of this specification. Based on the same idea, one or more embodiments of this specification also provide an image processing device, such as Figure 3 shown.

[0110] The image processing device includes: an image pre-classification module 210, a text information extraction module 220, an image structure restoration module 230 and a text mapping module 240, wherein:

[0111] An image pre-classification module 210 pre-classifies the structured image to be processed and determines the category of the structured image, where the structured image is an image including structured data;

[0112] The text information extraction module 220 performs text information extraction processing on the structured image according to the category of the structured image, and obtains the text information in the structured image and the information of the location of the text information;

[0113] The image structured restoration module 230 performs structured restoration processing on the structured data in the structured image based on the information of the location of the text information in the structured image, and obtains the data distribution structure of the structured data in the structured image;

[0114] The text mapping module 240 determines the data distribution structure corresponding to the text information based on the text information in the structured image, the information of the location of the text information in the structured image and the location information of the data distribution structure of the structured data in the structured image, and fills the text information into the data distribution structure corresponding to the text information.

[0115] In the embodiment of this specification, the image pre-classification module 210 includes:

[0116] An image preprocessing unit, which preprocesses the structured image;

[0117] The image category determination unit uses a preset target detection model to pre-classify the preprocessed structured image based on pixel information to determine the category of the structured image.

[0118] In the embodiment of this specification, if the structured image is an image containing table data, the text information extraction module 220 includes:

[0119] A layout analysis processing unit, based on the row and column distribution information of the table data contained in the structured image, uses a preset target detection model to perform layout analysis processing on the structured image to determine the number of tables in the structured image;

[0120] The first text information extraction unit obtains the text information in each table in the structured image and the information of the position where the text information is located based on a preset text information extraction model.

[0121] In the embodiment of this specification, if the structured image is an image containing table data, the text information extraction module 220 further includes:

[0122] The cropping unit crops the structured image into a plurality of sub-table images if there are multiple tables in the structured image, each of which contains one or more tables.

[0123] In the embodiment of the present specification, if the structured image is an image containing table data, and each sub-table image contains a table, the text information extraction module 220 further includes:

[0124] an area ratio calculation unit, which calculates the ratio between the table area of ​​any sub-table image and the table area of ​​the structured image;

[0125] The judging unit determines that any sub-table image is an image containing a conversation record of an instant messaging if the calculated ratio is less than a preset area ratio threshold.

[0126] In the embodiment of this specification, if the structured image is an image containing table data, and the data distribution structure of the structured data is a table structure, the image structure restoration module 230 includes:

[0127] A first text clustering unit, based on information about the location of text information in the structured image, uses a preset text clustering model to obtain horizontal clustering information and vertical clustering information corresponding to a first preset reference point of each table in the structured image;

[0128] a horizontal line determination unit, which determines a table structure horizontal line coordinate list of each table in the structured image based on the horizontal clustering information corresponding to the first preset reference point of each table and the vertical coordinate of the first preset reference point, wherein the horizontal line coordinate list corresponds to the horizontal line of each table in the table image;

[0129] a longitudinal line determination unit, which determines a table structure longitudinal line coordinate list of each table in the structured image based on longitudinal clustering information corresponding to a first preset reference point of each table and a horizontal coordinate of the first preset reference point, wherein the longitudinal line coordinate list corresponds to a longitudinal line of each table in the structured image;

[0130] A calibration unit, calibrating the longitudinal line based on the relationship between the longitudinal line and the position of the text information, and obtaining the calibrated longitudinal line;

[0131] The table structure determination unit determines the table structure of each table in the structured image according to the horizontal lines and the calibrated vertical lines of each table in the structured image.

[0132] In the embodiment of this specification, if the structured image is an image containing table data, and the data distribution structure of the structured data is a table structure, the image structure restoration module 230 further includes:

[0133] a horizontal line updating unit, which determines the table structure horizontal line coordinate list of each table in the structured image based on the horizontal clustering information corresponding to the first preset reference point of each table and the vertical coordinate of the first preset reference point, and then performs clustering processing on the table structure horizontal line coordinate list of each table in the structured image based on the height of the position where the text information is located in the structured image, to obtain an updated table structure horizontal line coordinate list;

[0134] The vertical line updating unit determines the table structure vertical line coordinate list of each table in the structured image based on the vertical clustering information corresponding to the first preset reference point of each table and the horizontal coordinate of the first preset reference point. Then, based on the height of the position where the text information is located in the structured image, the table structure vertical line coordinate list of each table in the structured image is clustered to obtain an updated table structure vertical line coordinate list.

[0135] In the embodiment of the present specification, if the structured image is an image containing an instant messaging conversation record, and the data distribution structure of the structured data is an instant messaging text box, the image structure restoration module 230 includes:

[0136] The second clustering unit performs a first clustering process on the information of the position where the text information in the structured image is located by using a preset text clustering model based on the information of the position where the text information in the structured image is located and a second preset reference point in the position where the text information in the structured image is located, and obtains an instant messaging text box corresponding to each instant messaging message in the structured image, and the instant messaging text box corresponding to each instant messaging message is a group of instant messaging text boxes;

[0137] A merging processing unit performs a second clustering process on the information of the position of the instant messaging text box corresponding to each instant messaging message obtained by the first clustering process according to the background colors of the instant messaging text boxes between adjacent groups, to obtain an instant messaging text box cluster classified based on the background color, and determines an updated group of instant messaging text boxes corresponding to each instant messaging message based on the instant messaging text box cluster containing a type of background color;

[0138] The instant messaging text box numbering unit numbers a group of updated instant messaging text boxes to determine the group number of the instant messaging text boxes.

[0139] In the embodiment of this specification, if the structured image is an image containing table data, and the data distribution structure of the structured data is a table structure, the text mapping module 240 includes:

[0140] a position matching unit, which uses an intersection-and-union algorithm to determine a position matching result between the position of the text information in the structured image and the table structure based on the information of the position of the text information in the structured image and the position information of the table structure corresponding to the structured image, and determines a table corresponding to the position of the text information in the structured image according to the position matching result;

[0141] The first text information filling unit fills the text information corresponding to the position where the text information in the structured image is located into a table corresponding to the position where the text information in the structured image is located.

[0142] In the embodiment of this specification, if the structured image is an image containing table data, and the data distribution structure of the structured data is a table structure, the text mapping module 240 further includes:

[0143] A text information splitting unit, if the matching result between the position of the text information in the structured image and the position of the table structure is that the maximum intersection-and-union ratio of the position of the text information in the structured image corresponds to multiple cells in the table structure, then the text information corresponding to the position of the text information in the structured image is determined to be the merged data of the multiple cells, and the text information is split accordingly according to the matching ratio and position information of each cell to obtain the text information corresponding to each cell in the table;

[0144] A text information merging unit, if the position of the text information in the structured image matches the position of the table structure and the result is that the maximum intersection-and-union ratio of the positions of the text information in multiple structured images corresponds to the same cell in the table structure, then the text information corresponding to the position of the text information in the structured image is determined to be the split data of the same cell, and the text information corresponding to the positions of the text information in the multiple structured images is merged and filled into the same cell.

[0145] In the embodiment of the present specification, if the structured image is an image containing an instant messaging conversation record, and the data distribution structure of the structured data is an instant messaging text box, the text mapping module 240 includes:

[0146] A merge tag adding unit, which adds a merge tag to the corresponding data distribution structure according to the acquired text merge request, wherein the merge tag includes a group number of the data distribution structure;

[0147] A second text information filling unit, if the target instant messaging text box does not contain a merge tag, fills the text information in the structured image into the target instant messaging text box corresponding to the structured image based on information about the location of the text information in the structured image;

[0148] The third text information filling unit merges the text information of the structured image corresponding to the instant messaging text box with the corresponding group number in the merge tag based on the information of the position of the text information in the structured image if the target instant messaging text box includes a merge tag.

[0149] Those skilled in the art should understand that the above-mentioned image processing device can be used to implement the image processing method described above, and the detailed description thereof should be similar to the description of the method part above, and will not be further described here to avoid tediousness.

[0150] Based on the same idea, one or more embodiments of this specification also provide an electronic device, such as Figure 4 As shown. The electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors 301 and memory 302, and the memory 302 may store one or more storage applications or data. Among them, the memory 302 can be a temporary storage or a permanent storage. The application stored in the memory 302 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device. Furthermore, the processor 301 can be configured to communicate with the memory 302 to execute a series of computer executable instructions in the memory 302 on the electronic device. The electronic device may also include one or more power supplies 303, one or more wired or wireless network interfaces 304, one or more input and output interfaces 305, and one or more keyboards 306.

[0151] Specifically in this embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the electronic device, and the one or more programs are configured to be executed by one or more processors, including the following computer executable instructions:

[0152] Pre-classifying the structured image to be processed to determine the category of the structured image, where the structured image is an image including structured data;

[0153] According to the category of the structured image, text information extraction processing is performed on the structured image to obtain the text information in the structured image and the information of the location where the text information is located;

[0154] Based on the information about the location of the text information in the structured image, structured data in the structured image is subjected to structured restoration processing to obtain a data distribution structure of the structured data in the structured image;

[0155] Based on the text information in the structured image, the information about the location of the text information in the structured image and the location information of the data distribution structure of the structured data in the structured image, the data distribution structure corresponding to the text information is determined, and the text information is filled into the data distribution structure corresponding to the text information.

[0156] One or more embodiments of this specification provide a storage medium, the storage medium is used to store computer executable instructions, and the executable instructions implement the following process when executed by a processor:

[0157] Pre-classifying the structured image to be processed to determine the category of the structured image, where the structured image is an image including structured data;

[0158] According to the category of the structured image, text information extraction processing is performed on the structured image to obtain the text information in the structured image and the information of the location where the text information is located;

[0159] Based on the information about the location of the text information in the structured image, structured data in the structured image is subjected to structured restoration processing to obtain a data distribution structure of the structured data in the structured image;

[0160] Based on the text information in the structured image, the information about the location of the text information in the structured image and the location information of the data distribution structure of the structured data in the structured image, the data distribution structure corresponding to the text information is determined, and the text information is filled into the data distribution structure corresponding to the text information.

[0161] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0162] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0163] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0164] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0165] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing one or more embodiments of this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0166] It should be understood by those skilled in the art that one or more embodiments of the present specification may be provided as a method, system, or computer program product. Therefore, one or more embodiments of the present specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, one or more embodiments of the present specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0167] One or more embodiments of the present specification are described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0168] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0169] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0170] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0171] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0172] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0173] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0174] One or more embodiments of the present specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0175] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0176] The above description is only one or more embodiments of this specification and is not intended to limit this application. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification should be included in the scope of the claims of one or more embodiments of this specification.

Claims

1. A method for processing an image, comprising: Pre-classifying a structured image to be processed to determine a category of the structured image, wherein the structured image is an image including structured data; According to the category of the structured image, performing text information extraction processing on the structured image to obtain text information in the structured image and information about the location of the text information; Based on the information about the position of the text information in the structured image, performing structured restoration processing on the structured data in the structured image to obtain a data distribution structure of the structured data in the structured image; Based on the text information in the structured image, information about the location of the text information in the structured image, and location information of the data distribution structure of the structured data in the structured image, determine the data distribution structure corresponding to the text information, and fill the text information into the data distribution structure corresponding to the text information.

2. According to the method of claim 1, the pre-classifying the structured image to be processed and determining the category of the structured image comprises: Preprocessing the structured image; A preset target detection model is used to pre-classify the preprocessed structured image based on pixel information to determine the category of the structured image.

3. According to the method of claim 1, the structured image is an image containing table data, and the step of performing text information extraction processing on the structured image according to the category of the structured image to obtain the text information in the structured image and the information of the location of the text information comprises: Based on the row and column distribution information of the table data contained in the structured image, a preset target detection model is used to perform layout analysis processing on the structured image to determine the number of tables in the structured image; Based on a preset text information extraction model, the text information in each table in the structured image and information about the location of the text information are obtained.

4. The method according to claim 3, based on the row and column distribution information of the table data contained in the structured image, using a preset object detection model to perform layout analysis processing on the structured image, and after determining the number of tables in the structured image, the method further comprises: If there are multiple tables in the structured image, the structured image is cropped into multiple sub-table images, each of which contains one or more tables.

5. The method according to claim 4, wherein each sub-table image contains a table, further comprising: Calculating the ratio between the table area of ​​any one of the sub-table images and the table area of ​​the structured image; If the calculated ratio is smaller than a preset area ratio threshold, it is determined that any one of the sub-table images is an image containing a conversation record of an instant messaging.

6. The method according to claim 1, wherein the structured image is an image containing table data, the data distribution structure of the structured data is a table structure, and the step of performing structured restoration processing on the structured data in the structured image based on the information of the position of the text information in the structured image to obtain the data distribution structure of the structured data in the structured image comprises: Based on the information about the location of the text information in the structured image, using a preset text clustering model to obtain horizontal clustering information and vertical clustering information corresponding to a first preset reference point of each table in the structured image; Determine a table structure horizontal line coordinate list of each table in the structured image based on the horizontal clustering information corresponding to the first preset reference point of each table and the vertical coordinate of the first preset reference point, wherein the horizontal line coordinate list corresponds to the horizontal line of each table in the table image; Determine a table structure vertical line coordinate list of each table in the structured image based on the vertical clustering information corresponding to the first preset reference point of each table and the horizontal coordinate of the first preset reference point, wherein the vertical line coordinate list corresponds to the vertical line of each table in the structured image; Based on the relationship between the longitudinal line and the position of the text information, calibrate the longitudinal line to obtain a calibrated longitudinal line; The table structure of each table in the structured image is determined according to the transverse lines and the calibrated longitudinal lines of each table in the structured image.

7. The method according to claim 6, after determining the table structure horizontal line coordinate list of each table in the structured image based on the horizontal clustering information corresponding to the first preset reference point of each table and the vertical coordinate of the first preset reference point, the method further comprises: Based on the height of the position where the text information is located in the structured image, clustering processing is performed on the table structure horizontal line coordinate list of each table in the structured image to obtain an updated table structure horizontal line coordinate list; After determining a table structure vertical line coordinate list of each table in the structured image based on the vertical clustering information corresponding to the first preset reference point of each table and the horizontal coordinate of the first preset reference point, the method further includes: Based on the height of the position where the text information is located in the structured image, clustering processing is performed on the table structure vertical line coordinate list of each table in the structured image to obtain an updated table structure vertical line coordinate list.

8. The method according to claim 1, wherein the structured image is an image containing an instant messaging conversation record, the data distribution structure of the structured data is an instant messaging text box, and the step of performing structured restoration processing on the structured data in the structured image based on information about the location of the text information in the structured image to obtain the data distribution structure of the structured data in the structured image comprises: Based on the information of the position where the text information in the structured image is located and a second preset reference point in the position where the text information in the structured image is located, a preset text clustering model is used to perform a first clustering process on the information of the position where the text information in the structured image is located, and an instant messaging text box corresponding to each instant messaging message in the structured image is obtained, and the instant messaging text box corresponding to each instant messaging message is a group of instant messaging text boxes; According to the background colors of the instant messaging text boxes between adjacent groups, a second clustering process is performed on the information of the position of the instant messaging text box corresponding to each instant messaging message obtained by the first clustering process to obtain an instant messaging text box cluster classified based on the background color, and an updated group of instant messaging text boxes corresponding to each instant messaging message is determined based on the instant messaging text box clusters containing a type of background color; The updated group of instant messaging text boxes are numbered to determine the group number of the instant messaging text boxes.

9. The method according to claim 1, wherein the structured image is an image containing table data, the data distribution structure of the structured data is a table structure, and the determining the data distribution structure corresponding to the text information based on the text information in the structured image, the information of the position of the text information in the structured image, and the position information of the data distribution structure of the structured data in the structured image, and filling the text information into the data distribution structure corresponding to the text information comprises: Based on the information of the position of the text information in the structured image and the position information of the table structure corresponding to the structured image, an intersection-over-union algorithm is used to determine a position matching result between the position of the text information in the structured image and the table structure, and a table corresponding to the position of the text information in the structured image is determined according to the position matching result; The text information corresponding to the position where the text information in the structured image is located is filled into a table corresponding to the position where the text information in the structured image is located.

10. The method according to claim 9, further comprising: If the matching result between the position of the text information in the structured image and the position of the table structure is that the maximum intersection-and-union ratio of the position of the text information in the structured image corresponds to multiple cells in the table structure, then determining that the text information corresponding to the position of the text information in the structured image is merged data of multiple cells, and performing corresponding splitting processing on the text information according to the matching ratio and position information of each cell to obtain the text information corresponding to each cell in the table; If the matching result of the position of the text information in the structured image and the position of the table structure is that the maximum intersection-and-union ratio of the positions of the text information in multiple structured images corresponds to the same cell in the table structure, then it is determined that the text information corresponding to the position of the text information in the structured image is the split data of the same cell, and the text information corresponding to the positions of the text information in multiple structured images are merged and filled into the same cell.

11. The method according to claim 1, wherein the structured image is an image containing an instant messaging conversation record, the data distribution structure of the structured data is an instant messaging text box, and the determining the data distribution structure corresponding to the text information based on the text information in the structured image, the information of the location of the text information in the structured image, and the location information of the data distribution structure of the structured data in the structured image, and filling the text information into the data distribution structure corresponding to the text information, comprises: According to the acquired text merge request, adding a merge tag to the corresponding data distribution structure, wherein the merge tag includes a group number of the data distribution structure; If the target instant messaging text box does not include a merge tag, based on information about the location of the text information in the structured image, filling the text information in the structured image into the target instant messaging text box corresponding to the structured image; If the target instant messaging text box includes a merge tag, based on the information about the location of the text information in the structured image, the text information of the structured image corresponding to the instant messaging text box with the corresponding group number in the merge tag is merged.

12. An image processing device, comprising: An image pre-classification module pre-classifies a structured image to be processed and determines a category of the structured image, wherein the structured image is an image including structured data; A text information extraction module, which performs text information extraction processing on the structured image according to the category of the structured image, and obtains the text information in the structured image and the information of the location of the text information; An image structured restoration module, based on information about the location of the text information in the structured image, performs structured restoration processing on the structured data in the structured image to obtain a data distribution structure of the structured data in the structured image; A text mapping module determines a data distribution structure corresponding to the text information based on the text information in the structured image, information about the location of the text information in the structured image, and position information of the data distribution structure of the structured data in the structured image, and fills the text information into the data distribution structure corresponding to the text information.

13. An electronic device, comprising: processor; as well as a memory arranged to store computer executable instructions which, when executed, cause the processor to: Pre-classifying a structured image to be processed to determine a category of the structured image, wherein the structured image is an image including structured data; According to the category of the structured image, performing text information extraction processing on the structured image to obtain text information in the structured image and information about the location of the text information; Based on the information about the position of the text information in the structured image, performing structured restoration processing on the structured data in the structured image to obtain a data distribution structure of the structured data in the structured image; Based on the text information in the structured image, information about the location of the text information in the structured image, and location information of the data distribution structure of the structured data in the structured image, determine the data distribution structure corresponding to the text information, and fill the text information into the data distribution structure corresponding to the text information.