Structure reduction method and apparatus for structure diagram
By obtaining the connector mask image and node position information of the structure graph, and using depth-first search and connected component analysis algorithms to determine the tree structure relationship of the nodes, the problem of the structure graph being uneditable is solved, and efficient automatic restoration is achieved.
Patent Information
- Application Number
- CN202111277690.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2041-10-29
AI Technical Summary
In existing technologies, when structural diagrams are stored and transmitted in image format, editing is not supported, resulting in low restoration efficiency and high labor costs.
By obtaining the connector mask image and node position information of the structure graph, the tree structure relationship of the nodes is determined using depth-first search and connected component analysis algorithms, and the descriptive information of the tree structure relationship is output.
It enables automatic reconstruction of structural diagrams, reducing labor costs and improving reconstruction efficiency without the need for manual intervention.
Smart Images

Figure CN114090803B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of computer, in particular to a structure restoration method and device of a structure diagram. BACKGROUND
[0002] In the prior art, structure diagrams such as structure diagrams and flowcharts often appear in the daily work and study of users, and are usually in the form of images for file transmission and reading. However, when the structure diagram is stored and transmitted in the form of an image, there is a big defect that it can only support reading but cannot support editing.
[0003] Therefore, there is an urgent need for a method capable of restoring a structure image. SUMMARY
[0004] Embodiments of the present application provide a structure restoration method and device of a structure diagram to solve the technical problems of high labor cost and low restoration efficiency of restoring a structure diagram in the prior art.
[0005] In a first aspect, the embodiments of the present application provide a structure restoration method of a structure diagram, which includes: obtaining a mask image of a connection line in a structure diagram and position information of a node in the structure diagram; determining a tree structure relationship of the node in the structure diagram based on the obtained mask image and position information; and outputting description information of the tree structure relationship.
[0006] In a second aspect, the embodiments of the present application provide a structure restoration device of a structure diagram, which includes: an obtaining unit configured to obtain a mask image of a connection line in a structure diagram and position information of a node in the structure diagram; a determining unit configured to determine a tree structure relationship of the node in the structure diagram based on the obtained mask image and position information; and an output unit configured to output description information of the tree structure relationship.
[0007] In a third aspect, the embodiments of the present application provide a device for restoring a structure diagram, which includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and when the programs are executed by one or more processors, the method described in the first aspect is implemented.
[0008] In a fourth aspect, the embodiments of the present application provide a computer readable medium having a computer program stored thereon, and when the program is executed by a processor, the method described in the first aspect is implemented.
[0009] The structural reduction method and device of the structural diagram provided by the embodiments of the present application can obtain the mask image of the connection line in the structural diagram and the position information of the node in the structural diagram, and then determine the tree structure relationship of the node in the structural diagram based on the obtained mask image and position information, so as to output the description information of the tree structure relationship. The embodiments can realize the automatic reduction of the structure of the structural diagram by analyzing the mask image of the connection line of the structural diagram and the position information of the node of the structural diagram, and the process does not need human intervention, thereby improving the reduction efficiency of the structure of the structural diagram. BRIEF DESCRIPTION OF DRAWINGS
[0010] Other features, objects, and advantages of the present application will become more apparent from the following detailed description of non-limiting embodiments thereof as read in conjunction with the accompanying drawings:
[0011] Figure 1 is a flow chart of an embodiment of the structural reduction method of the structural diagram according to the present application;
[0012] Figure 2 is a schematic diagram of the structural diagram according to the structural reduction method of the structural diagram according to the present application;
[0013] Figure 3 is a schematic diagram of the mask image according to the structural reduction method of the structural diagram according to the present application;
[0014] Figure 4 is a schematic diagram of the node search process according to the structural reduction method of the structural diagram according to the present application;
[0015] Figure 5 is a schematic diagram of the structural relationship diagram according to the structural reduction method of the structural diagram according to the present application;
[0016] Figure 6 is a structural schematic diagram of the structural reduction device of the structural diagram according to the present application;
[0017] Figure 7 is a structural schematic diagram of the device for reducing the structure of the structural diagram according to the present application;
[0018] Figure 8 is a structural schematic diagram of the server in some embodiments according to the present application. DETAILED DESCRIPTION
[0019] The present application will be further described below in conjunction with the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related application, and not to limit the application. In addition, it should be noted that, for the convenience of description, only the parts related to the application are shown in the drawings.
[0020] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other in the case of no conflict. The present application will be described in detail below with reference to the drawings and in combination with the embodiments.
[0021] Reference is made to Figure 1 which shows a flow 100 of one embodiment of the structure reduction method of the structure diagram according to the present application. The structure reduction method of the structure diagram described above can run on various electronic devices, including but not limited to: servers, smart phones, tablet computers, e-book readers, laptop computers, vehicle-mounted computers, desktop computers, set-top boxes, smart televisions, wearable devices, and the like.
[0022] The structure reduction method of the structure diagram in the present embodiment can include the following steps:
[0023] Step 101, obtaining a mask image of the connection line in the structure diagram and position information of the nodes in the structure diagram.
[0024] In the present embodiment, the execution subject (such as the electronic device described above) of the structure reduction method of the structure diagram can obtain the structure diagram to be processed in advance. The structure diagram is a kind of graph that can reflect the hierarchical structure, which takes the calling relationship of modules as the clue, represents the calling relationship with the connection line, and notes the direction and content of parameter passing. The structure diagram can include but is not limited to architectural structure diagram, organizational structure diagram, mind map, etc. The structure diagram can usually be represented in the form of an image.
[0025] The structure diagram can include one or more of the following contents: nodes, connection points between nodes, text information corresponding to nodes, text information corresponding to connection lines, pattern elements, etc. It should be noted that the presentation form of the node is not limited to point-like, but can also be presented in area-like (such as rectangular, circular, etc.), which is not limited here. As an example, Figure 2 a schematic diagram of a structure diagram is shown, which is a mind map. As Figure 2 shown, the structure diagram can include several nodes, several connection lines between nodes, text descriptions of each node and connection, and pattern content, etc.
[0026] In the present embodiment, the execution subject described above can obtain a mask image of the connection line in the structure diagram and position information of the nodes in the structure diagram. The mask image is a mask. The mask image corresponds to each pixel point in the structure diagram one by one, and the mask image includes the mask of each pixel point in the structure diagram, which can be used as a classification label of the pixel. For example, the mask at the connection line can be set to 1, and the mask at the remaining positions can be set to 0. It should be noted that since the connection line is used to connect the nodes, the connection line coincides with the nodes at both ends, so the mask at the node is the same as the mask at the connection line, such as both being 1. As an example, Figure 3 a schematic diagram of a structure diagram is shown, which is a mind map. AsFigure 2 The mask image of the connection line of the structural diagram in FIG. 8. In the mask image, the rectangular region is the root node, and the root node is the rectangular node. The position information can be represented by the coordinates of the node.
[0027] In the process of obtaining the mask image, as an example, the structural diagram can be first segmented by image segmentation technology to determine the region composed of the nodes and the connection lines of the nodes. Then, the pixels in the region can be marked as 1, and the pixels in the remaining region can be marked as 0 to obtain the mask image. In the mask image, the mask of the pixels corresponding to the nodes and the connection lines is 1, and the mask of the remaining pixels is 0. It should be noted that the mask can also be set to other numerical values, not limited to 1 and 0.
[0028] In the process of obtaining the position information of the node, as an example, the target detection algorithm can be used to detect the node as the detection target to obtain the position information of the node. Specifically, a machine learning method (such as a supervised learning method) can be used to pre-train a node detection model for detecting the nodes in the structural diagram. The structural diagram to be processed can be input into the model to identify the nodes and their positions in the structural diagram.
[0029] It can be understood that the embodiments of the present application can also use other technical means or algorithms to generate the mask image and obtain the position information of the node, which are not limited to the above description, and will not be repeated here.
[0030] In step 102, the tree structure relationship of the nodes in the structural diagram is determined based on the obtained mask image and position information.
[0031] In the embodiment, the above execution subject can determine the tree structure relationship of the nodes in the structural diagram based on the obtained mask image and the position information of the nodes. Based on the mask image, the connection between the nodes can be determined. For example, if there is a certain connection path (i.e., a path with a mask of 1) between two nodes, and the connection path does not contain other nodes, then there is a parent-child relationship between the two nodes. Starting from the root node, the relationship between each node and other nodes can be determined based on the mask image and the position of the nodes, so as to obtain the tree structure relationship of the nodes in the structural diagram.
[0032] In some optional implementations of the embodiment, the above execution subject can determine the structure relationship between each node and other nodes based on the obtained mask image and position information, starting from the root node of the structural diagram, to obtain the tree structure relationship of the nodes in the structural diagram. Here, based on the obtained mask image and position information, the structure relationship between each node and other nodes can be determined in various ways.
[0033] As an example, a Depth First Search (DFS) algorithm and a Connected Component Analysis algorithm can be employed. The DFS belongs to a kind of graph algorithms. It can be implemented using a stack. The main method is as follows: firstly, a vertex v (e.g. the root node) is accessed; then, the graph is traversed in depth from the unvisited adjacent points of v until all vertices connected with v are visited; if there are still unvisited vertices in the graph, the depth first search is restarted from an unvisited vertex until all vertices are visited.
[0034] As another example, a Breadth First Search (BFS) algorithm and a Connected Component Analysis algorithm can also be employed. The BFS belongs to a kind of graph algorithms and is a kind of blind search method. The purpose is to expand and check all nodes in the graph systematically to find the result. The BFS is implemented using a queue. The main method is as follows: the root node is placed at the end of the queue; each time, an element at the head of the queue is taken out, all next-level elements of the element are placed at the end of the queue, and the element is recorded as the predecessor of the next-level elements; the program is ended when the element to be found is found; if the whole tree is traversed without finding the element, the program is ended.
[0035] The following will take the determination of the structural relationship between each node and other nodes using the DFS algorithm and the Connected Component Analysis algorithm as an example for detailed description. Specifically, a stack can be set in advance, and the root node is firstly stacked. Then, the following steps can be executed in a loop: a point at the top of the stack is taken as a search point (which can be denoted as p), and the search point p is taken out. If the search point p is located in any node (which can be denoted as j) of the structural graph, and the search point p and the node j where it is located have different identities (which can be condition 1), the search point p can be determined as a child node of the node j where it is located. If the search point p is not located in any node of the structural graph, or there is a node in the structural graph having the same identity as the search point p (which can be condition 2), a search boundary is determined based on the position of the search point p; a point located in the search boundary and having a mask value of a target value (e.g. 1) is taken as a target point (which can be denoted as q), and if the target point q is connected with the search point p, the target point q is stacked, and the identity of the search point p is taken as the identity of the target point q, i.e. q.id = p.id, where p.id is the identity of the search point p, and q.id is the identity of the target point q.
[0036] In some examples, the nodes in the structure graph can include both rectangular nodes and point nodes.
[0037] In some examples, when determining the search boundary based on the location of the search point, a search circle can be defined with the search point as the center and a preset value as the radius. This search circle is the search boundary. This method is typically applied to point nodes. Alternatively, a search box can be defined with the search point as the center, a first preset value as the height, and a second preset value as the width. This search box is the search boundary. This method is typically applied to rectangular nodes.
[0038] In practice, see Figure 4 The diagram illustrates the node search process. First, the root node (which can be A) is pushed onto the stack. Then, the point at the top of the stack (currently the root node A) is used as the search point. Since this search point and the root node are the same point and have the same identifier, condition 1 is not satisfied. We can then proceed to determine if condition 2 is satisfied. Because there exists a node in the structure diagram with the same identifier as the search point (i.e., the root node A), condition 2 is satisfied. At this point, the search boundary can be determined based on the position of the search point (i.e., the root node A). Figure 4 The rectangular dashed box 401 in the search boundary. Points with a mask value of 1 on this search boundary include the target point B. Since the target point B is connected to the search point (i.e., the root node A), the target point B can be pushed onto the stack, and the identifier of the search point (i.e., the root node A) can be used as the identifier of the target point B.
[0039] Next, the point at the top of the stack (point B in this case) can be used as the search point. Since search point B is not located at any node, condition 1 is not satisfied, and we can continue to determine whether condition 2 is satisfied. Since there is a node in the structure graph with the same identifier as search point B (i.e., root node A), condition 2 is satisfied. At this point, the search boundary can be determined based on the position of the search point (i.e., root node A). Figure 4 (Circular dashed box 402). The target point C is among the points with a mask value of 1 on the search boundary. Since the target point C is connected to the search point B, the target point C can be pushed onto the stack, and the identifier of the search point B (i.e., the identifier of the root node A) can be used as the identifier of the target point C.
[0040] Next, the point at the top of the stack (point C in this case) can be used as the search point. Since search point C is not located at any node, condition 1 is not satisfied, and we can continue to determine whether condition 2 is satisfied. Since there is a node in the structure graph with the same identifier as search point C (i.e., root node A), condition 2 is satisfied. At this point, the search boundary can be determined based on the position of the search point (i.e., root node A) (e.g., ...). Figure 4 (Circular dashed box 403). The target point D is among the points with a mask value of 1 on the search boundary. Since the target point D is connected to the search point C, the target point D can be pushed onto the stack, and the identifier of the search point C (i.e., the identifier of the root node A) can be used as the identifier of the target point D.
[0041] The above steps are executed in a loop. When a search point M satisfies condition 1, the search point M can be taken as a child node of a last searched node (the root node can be taken as the first searched node). At this time, the next search point can be extracted from the stack, and the above steps are executed in a loop. Finally, the structural relationship between each node and other nodes can be obtained, so that the tree structure relationship of the structural diagram is determined.
[0042] By the techniques of depth-first search and connected component analysis, an accurate tree structure relationship can be obtained, and the structural diagram structure is automatically restored. This process does not require human intervention, reduces labor costs, and improves the efficiency of restoring the structure of the structural diagram compared with the manual restoration of the structure of the structural diagram.
[0043] In step 103, description information of the tree structure relationship is output.
[0044] In this embodiment, after the tree structure relationship is determined, the execution subject can output description information of the tree structure relationship. The description information can include, but is not limited to, image form, code form, etc., which is not limited here.
[0045] In some optional implementations of this embodiment, the execution subject can render a structural relationship diagram based on the tree structure relationship, and take the structural relationship diagram as the description information of the structural relationship. The structural relationship diagram includes nodes in the structural diagram, connection lines in the structural diagram, and indication information for indicating the direction of the nodes. As an example, please refer to Figure 5 . The arrow can represent the direction of the child node.
[0046] In some optional implementations of this embodiment, the execution subject can obtain text information of the nodes in the structural diagram, and then generate a structured description file of the structural diagram, such as a JSON (JavaScript Object Notation, JS object notation) file, based on the text information of the nodes, the position information of the nodes, and the tree structure relationship. In this way, the user can modify the content in the JSON file to reconstruct the structural diagram.
[0047] The method provided in the above embodiments of the application can obtain a mask image of a connection line in a structural diagram and position information of nodes in the structural diagram, and then determine a tree structure relationship of the nodes in the structural diagram based on the obtained mask image and position information, so as to output description information of the tree structure relationship. This implementation can automatically restore the structure of the structural diagram by analyzing the mask image of the connection line of the structural diagram and the position information of the nodes of the structural diagram, which does not require human intervention and improves the efficiency of restoring the structure of the structural diagram.
[0048] Further referenceFigure 6 As an implementation of the method shown in the above figures, the present application provides an embodiment of a structure reduction device of a structure diagram, which corresponds to the method embodiment shown in Figure 1 The device can be applied in various electronic devices.
[0049] As Figure 6 shown, the structure reduction device 600 of the structure diagram in the embodiment includes: an acquisition unit 601 configured to acquire a mask image of a connection line in a structure diagram and position information of nodes in the structure diagram; a determination unit 602 configured to determine a tree structure relationship of the nodes in the structure diagram based on the acquired mask image and position information; and an output unit 603 configured to output description information of the tree structure relationship.
[0050] In some optional implementation manners of the embodiment, the output unit 603 is further configured to render a structure relationship diagram based on the tree structure relationship, the structure relationship diagram including the nodes in the structure diagram, the connection lines in the structure diagram, and indication information for indicating a direction of a node.
[0051] In some optional implementation manners of the embodiment, the output unit 603 is further configured to acquire text information of the nodes in the structure diagram; and generate a structured description file of the structure diagram based on the text information of the nodes, the position information, and the tree structure relationship.
[0052] In some optional implementation manners of the embodiment, the determination unit 602 is further configured to determine a structure relationship of each node with other nodes based on the acquired mask image and position information from a root node of the structure diagram, to obtain the tree structure relationship of the nodes in the structure diagram.
[0053] In some optional implementation manners of the embodiment, the determination unit 602 is further configured to stack the root node, and cyclically execute the following steps: taking a node at a top of the stack as a search point, and taking out the search point; if the search point is located in any node of the structure diagram, and the search point and the located node have different identities, determining the search point as a child node of the located node; if the search point is not located in the nodes of the structure diagram, or there is a node in the structure diagram having the same identity as the search point, determining a search boundary based on a position of the search point; taking a node located at the search boundary and having a target value as a target point, and if the target point is connected with the search point, stacking the target point, and taking an identity of the search point as an identity of the target point.
[0054] In some optional implementations of the present embodiment, the determination unit 602 is further configured to: determine a search circle with the search point as the center and a preset value as the radius; or determine a search box with the search point as the center, a first preset value as the height, and a second preset value as the width.
[0055] In some optional implementations of the present embodiment, the nodes in the structural diagram include rectangular nodes and point nodes.
[0056] The apparatus provided by the above embodiments of the present application can obtain the mask image of the connection lines in the structural diagram and the position information of the nodes in the structural diagram, and then determine the tree structure relationship of the nodes in the structural diagram based on the obtained mask image and position information, so as to output the description information of the tree structure relationship. This embodiment can realize automatic restoration of the structure of the structural diagram by analyzing the mask image of the connection lines of the structural diagram and the position information of the nodes of the structural diagram, and the process does not need human intervention, thereby improving the restoration efficiency of the structure of the structural diagram.
[0057] Figure 7 Fig. 7 is a block diagram of an apparatus 700 for restoring a structure of a structural diagram according to an example embodiment. The apparatus 700 can be a smart terminal or a server. For example, the apparatus 700 can be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, and the like.
[0058] Referring to Figure 7 The apparatus 700 can include one or more of the following components: a processing component 702, a memory 704, a power supply component 706, a multimedia component 708, an audio component 710, an input / output (I / O) interface 712, a sensor component 714, and a communication component 716.
[0059] The processing component 702 generally controls the overall operations of the apparatus 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 can include one or more processors 720 to execute instructions to complete all or part of steps of the methods described above. In addition, the processing component 702 can include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 can include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
[0060] The memory 704 is configured to store various types of data to support the operation of the device 700. Examples of these data include instructions for any application or method operating on the device 700, contact data, phonebook data, messages, pictures, videos, and the like. The memory 704 can be implemented by any type of volatile or nonvolatile storage devices or a combination thereof such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0061] The power supply component 706 supplies electrical power for the various components of the device 700. The power supply component 706 can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing electrical power for the device 700.
[0062] The multimedia component 708 includes a screen providing an output interface between the device 700 and a user. In some embodiments, the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, swiping, and gestures on the touch panel. The touch sensor can not only sense a boundary of a touching or swiping action, but also detect duration and pressure related to the touching or swiping action. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. The front and / or rear camera can receive external multimedia data when the device 700 is in an operation mode such as a photographing mode or a video mode. Each of the front and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.
[0063] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC) configured to receive external audio signals when the device 700 is in an operation mode such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 704 or transmitted via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.
[0064] The I / O interface 712 provides an interface between the processing component 702 and peripheral interface modules such as a keyboard, a click wheel, buttons, and the like. The buttons can include, but are not limited to, a home button, a volume button, a start button, and a lock button.
[0065] The sensor component 714 includes one or more sensors for providing status assessments for various aspects of the device 700. For example, the sensor component 714 can detect an open / closed position of the device 700, relative positioning of components, such as a display and a keypad of the device 700, a change in position of the device 700 or a component of the device 700, presence or absence of user contact with the device 700, changes in orientation of the device 700 or acceleration / deceleration, and temperature changes of the device 700. The sensor component 714 can include proximity sensor(s) configured to detect presence of an object in proximity thereto without any physical contact. The sensor component 714 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 714 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0066] The communication component 716 is configured to facilitate wired or wireless communication between the device 700 and another device. The device 700 can access a wireless network based on a corresponding communication standard, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 also includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra-WideBand (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0067] In an exemplary embodiment, the device 700 can be implemented using one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, or other electronic units to perform the methods described above.
[0068] In an exemplary embodiment, a non-transitory computer readable storage medium, such as the memory 704 including instructions, is also provided, which can be executed by the processor 720 of the device 700 to perform the methods described above. For example, the non-transitory computer readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disc, and an optical data storage device, etc.
[0069] Figure 8Figure 8 is a schematic diagram of a server in some embodiments of the application. The server 800 can vary greatly in configuration and performance, and can include one or more central processing units (CPU) 822 (e.g., one or more processors) and memory 832, one or more storage media 830 (e.g., one or more mass storage devices) storing applications 842 or data 844. The memory 832 and the storage media 830 can be of the temporary or persistent storage variety. The programs stored in the storage media 830 can include one or more modules (not shown), each of which can include a series of instructions for operating on the server. Further, the CPU 822 can be configured to communicate with the storage media 830 to execute the series of instructions in the storage media 830 on the server 800.
[0070] The server 800 can also include one or more power supplies 826, one or more wired or wireless network interfaces 850, one or more input / output interfaces 858, one or more keyboards 856, and / or one or more operating systems 841, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0071] A non-transitory computer-readable storage medium having instructions stored therein that, when executed by a processor of a device (smart terminal or server), cause the device to perform a structural restoration method of a structural diagram, the method comprising: obtaining a mask image of a connection line in the structural diagram and position information of a node in the structural diagram; determining a tree structure relationship of the node in the structural diagram based on the obtained mask image and position information; and outputting description information of the tree structure relationship.
[0072] Optionally, the outputting the tree structure relationship information comprises: rendering a structural relationship diagram based on the tree structure relationship, the structural relationship diagram including the node in the structural diagram, the connection line in the structural diagram, and indication information for indicating a direction of the node.
[0073] Optionally, the outputting the description information of the tree structure relationship comprises: obtaining text information of the node in the structural diagram; and generating a structured description file of the structural diagram based on the text information of the node, the position information, and the tree structure relationship.
[0074] Optionally, the tree structure relationship of the nodes in the structure graph is determined based on the acquired mask image and position information, comprising: determining the structure relationship of each node with other nodes based on the acquired mask image and position information from the root node of the structure graph, to obtain the tree structure relationship of the nodes in the structure graph.
[0075] Optionally, the tree structure relationship of the nodes in the structure graph is determined based on the acquired mask image and position information from the root node of the structure graph, comprising: the root node is stacked, and the following node searching step is executed in a loop: taking the node at the top of the stack as a search point, and taking out the search point; if the search point is located in any node of the structure graph, and the search point and the located node have different identities, the search point is determined as a child node of the located node; if the search point is not located in each node of the structure graph, or there is a node in the structure graph having the same identity as the search point, a search boundary is determined based on the position of the search point; a point located in the search boundary and having a target value of the mask value is taken as a target point, and if the target point is connected with the search point, the target point is stacked, and the identity of the search point is taken as the identity of the target point.
[0076] Optionally, the search boundary is determined based on the position of the search point, comprising: determining a search circle with the search point as the center and a preset value as the radius; or determining a search frame with the search point as the center, a first preset value as the height, and a second preset value as the width.
[0077] Optionally, the nodes in the structure graph comprise rectangular nodes and point nodes.
[0078] Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the specification and examples be considered as exemplary only, with the true scope and spirit of the application being indicated by the following claims.
[0079] Furthermore, it should be noted that: the embodiments of the application further provide a computer program product or computer program, which can include computer instructions, and the computer instructions can be stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor can execute the computer instructions, so that the computer device executes the foregoing method. Figure 1The description of the structural reduction method of the structural diagram in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the computer program product or computer program embodiments involved in the present application, please refer to the description of the method embodiments of the present application.
[0080] It should be understood that the present application is not limited to the precise construction that has been described above and illustrated in the accompanying drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present application is only limited by the appended claims.
[0081] The above is only the preferred embodiment of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
[0082] The structural reduction method and device of the structural diagram provided by the present application are described in detail above, and the principles and implementation modes of the present application are described by applying specific examples. The above embodiment is only used to help understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will also have changes. In summary, the content of the specification should not be understood as a limitation of the present application.
Claims
1. A structural reduction method of a structural diagram, characterized by, The method comprises: Obtaining a mask image of a connection line in a structure diagram and position information of a node in the structure diagram; the mask image is obtained by marking pixels in a region formed by a node and a node connection line and the rest of the region respectively; the region formed by the node and the node connection line is obtained by image segmentation on the structure diagram; the structure diagram includes one or more of the following contents: a node, a connection point between nodes, text information corresponding to a node, text information corresponding to a connection line, and a pattern element; the node has a point or area form; From a root node of the structure diagram, based on the obtained mask image and position information, the structural relationship between each node and other nodes is determined to obtain a tree structure relationship of the nodes in the structure diagram, including: the root node is stacked, and the following node search steps are executed in a loop: taking a point at the top of the stack as a search point, and taking out the search point; when the search point is located in any node of the structure diagram, the search point and the node where the search point is located have different identifiers, and the search point is determined as a child node of the node where the search point is located; when the search point is not located in each node of the structure diagram, or there is a node in the structure diagram with the same identifier as the search point, a search boundary is determined based on the position of the search point, including: taking the search point as the center and a preset value as the radius to determine a search circle; or taking the search point as the center, a first preset value as the height, and a second preset value as the width to determine a search box; taking a point located in the search boundary and having a target value as a target point, when the target point is connected to the search point, the target point is stacked, and the identifier of the search point is taken as the identifier of the target point; the position information is obtained based on node detection of the structure diagram by a target detection algorithm; Outputting description information of the tree structure relationship.
2. The method of claim 1, wherein, The output of the tree structure relationship information comprises: Rendering a structure relationship diagram based on the tree structure relationship, the structure relationship diagram including nodes in the structure diagram, connection lines in the structure diagram, and indication information for indicating the direction of the nodes.
3. The method of claim 1, wherein, The output of the description information of the tree structure relationship comprises: Obtaining text information of the nodes in the structure diagram; Based on the text information, position information, and tree structure relationship of the nodes, generating a structured description file of the structure diagram.
4. The method according to one of claims 1 to 3, characterized in that, The nodes in the structure diagram include rectangular nodes and point nodes.
5. A structural reduction apparatus of a structural diagram, characterized by comprising: The device comprises: An obtaining unit is configured to obtain a mask image of a connection line in a structure diagram and position information of a node in the structure diagram; the mask image is obtained by marking pixels in a region formed by a node and a node connection line and the rest of the region respectively; the region formed by the node and the node connection line is obtained by image segmentation on the structure diagram; the structure diagram includes one or more of the following contents: a node, a connection point between nodes, text information corresponding to a node, text information corresponding to a connection line, and a pattern element; the node has a point or area form; The determining unit is configured to determine a structural relationship between each node and other nodes based on the obtained mask image and position information from a root node of the structural diagram, to obtain a tree-shaped structural relationship of the nodes in the structural diagram, including: stacking the root node, and performing a node searching step in a loop as follows: taking a node at a top of the stack as a searching node, and taking out the searching node; when the searching node is located in any node of the structural diagram, and the searching node and the node in which the searching node is located have different identities, determining the searching node as a child node of the node in which the searching node is located; when the searching node is not located in the nodes of the structural diagram, or there is a node in the structural diagram having the same identity as the searching node, determining a searching boundary based on a position of the searching node, including: determining a searching circle with the searching node as a center and a preset value as a radius; or determining a searching box with the searching node as a center, a first preset value as a height, and a second preset value as a width; taking a node located in the searching boundary and having a mask value as a target value as a target node, when the target node is connected with the searching node, stacking the target node, and taking an identity of the searching node as an identity of the target node; the position information is obtained based on a target detection algorithm for node detection of the structural diagram; The output unit is configured to output description information of the tree-shaped structural relationship.
6. The apparatus of claim 5, wherein, The output unit is further configured to: render a structural relationship diagram based on the tree-shaped structural relationship, the structural relationship diagram including nodes in the structural diagram, connection lines in the structural diagram, and indication information for indicating a direction of a node; and / or obtain text information of the nodes in the structural diagram; generate a structured description file of the structural diagram based on the text information, the position information, and the tree-shaped structural relationship of the nodes.
7. An apparatus for reducing a structure graph structure, characterized by, A computer program product includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are implemented by one or more processors to implement the steps of the method of any one of claims 1-4.
8. A computer readable medium having stored thereon a computer program, characterized in that, The program is implemented by the processor to implement the method of any one of claims 1-4.
9. A computer program product, characterised in that, The computer program product includes computer instructions stored in a computer readable storage medium and adapted to be read and executed by a processor to cause a computer device having the processor to implement the method of any one of claims 1-4.
Citation Information
Patent Citations
Mind map recognition method and device, storage medium and computer equipment
CN108304763A
Mind map image recognition and analysis reconstruction method and device
CN113449734A