Graph contour determination method and device, electronic equipment and storage medium
By automatically dividing the grid in the CAD file and determining the outer contour of the graphic object based on line distribution information, the problem of low efficiency and accuracy of manual masking is solved, and more efficient and accurate graphic contour determination is achieved.
Patent Information
- Application Number
- CN202311345069.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-17
- Publication Date
- 2025-04-18
AI Technical Summary
In computer-aided design (CAD) files, the efficiency and accuracy of manually adding masks is low, and the calculation of existing geometric contour search methods is high, resulting in the efficiency of contour search and the problem of not fully closed contours.
By obtaining the two-dimensional line information of the graphic object in the target graphic file, determining the enclosing box of the graphic object and dividing it into multiple grids, and automatically determining the outer contour of the graphic object based on the grid distribution information occupied by the lines.
The determination efficiency and accuracy of the graphical contour is improved, and the closure of the outer contour is ensured. Compared with manual methods and traditional geometric contour search methods, it has higher efficiency and higher accuracy.
Smart Images

Figure CN119850659A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for determining a graphic outline. Background Art
[0002] In the fields of engineering design, construction and manufacturing, graphic files are often used, and a large number of graphic objects are used in graphic files. Since graphic objects have to be displayed in order, it is necessary that the graphic objects in the graphic files can cover each other.
[0003] In Computer Aided Design (CAD) files, mutual occlusion between graphics can usually be achieved by adding masks to the graphics, and the outer contour of the mask is usually added manually by the draftsman, resulting in low efficiency and accuracy. Therefore, how to improve the accuracy and efficiency of determining the outer contour of the mask has always been a concern in the industry. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a method, device, electronic device, and storage medium for determining a graphic outline, which can improve the efficiency of determining a graphic outline while improving the accuracy of determining a graphic outline.
[0005] The present disclosure provides a method for determining a graphic outline, including:
[0006] Acquire a target graphic file, wherein the target graphic file includes a graphic object, and the graphic object is used to reflect two-dimensional line information of the target object;
[0007] Determine a bounding box of the graphic object, and divide the bounding box into a plurality of grids in a crisscross manner; the bounding box is a closed boundary box formed around the graphic object;
[0008] A plurality of lines included in the graphic object are determined based on the two-dimensional line information, and an outer contour of the graphic object is determined based on distribution information of grids occupied by each of the plurality of lines.
[0009] In the disclosed embodiment, the outer contour of the graphic can be automatically determined by the above method, which can improve the efficiency of contour determination compared to the manual contour determination method. In addition, in the disclosed embodiment, the contour is determined based on the distribution information of the divided grids and the grids occupied by the lines of the graphic object, so that the determined outer contour can be a closed contour, thereby improving the accuracy of contour determination.
[0010] In a possible implementation manner, determining the outer contour of the graphic object based on distribution information of a grid occupied by each of the multiple lines includes:
[0011] For each line, determining at least one first grid occupied by the line;
[0012] For each first grid, determining whether the first grid meets a preset condition, and if the first grid meets the preset condition, determining the first grid as a second grid;
[0013] The outer contour of the graphic object is determined based on the distribution information of each second grid.
[0014] In the disclosed embodiment, since the outer contour of the graphic object is determined based on the distribution information of the second grid that meets the preset conditions, the accuracy of determining the outer contour can be further improved.
[0015] In a possible implementation, determining at least one first grid occupied by the line includes:
[0016] A grid intersecting the line is determined as the first grid.
[0017] In the disclosed embodiment, the grid intersecting with the line is determined as the first grid, so that all grids associated with the line can be determined, avoiding omissions, which is beneficial to improving the accuracy of determining the first grid.
[0018] In a possible implementation, the preset condition includes that at least one boundary grid among boundary grids adjacent to the first grid is not the first grid; wherein the boundary grid is a grid that shares an edge with the first grid.
[0019] In the disclosed embodiment, the second grid is determined based on the first grid, and the second grid is a grid in which at least one of the adjacent boundary grids of the first grid is not the first grid. In this way, the screening accuracy of the second grid can be improved, which is conducive to improving the accuracy of determining the outer contour through the second grid.
[0020] In a possible implementation manner, determining the outer contour of the graphic object based on the distribution information of each second grid includes:
[0021] For each second grid, determining whether the second grid is an isolated grid, wherein the isolated grid is a second grid whose adjacent grid does not contain the first grid;
[0022] In the case where the second grid is not the isolated grid, determining the second grid as a target grid, and determining the outer contour of the graphic object based on distribution information of each target grid;
[0023] If the second grid is the isolated grid, the second grid is deleted.
[0024] In the embodiment of the present disclosure, if there is an isolated grid in the second grid, the second grid that is the isolated grid needs to be deleted, and the second grid that is not the isolated grid is used as the target grid, and the outer contour of the graphic object is determined based on the target grid. In this way, the determination accuracy of the target grid can be improved, which is conducive to more accurate determination of the outer contour of the graphic object based on the target grid.
[0025] In a possible implementation manner, determining the outer contour of the graphic object based on the distribution information of each target grid includes:
[0026] Traversing each target grid in a depth-first search manner to obtain a target contour set, wherein the target contour set includes at least one target contour;
[0027] The target contour with the largest area in the target contour set is determined as the outer contour of the graphic object.
[0028] In the disclosed embodiment, each target grid is first traversed in a depth-first search manner to obtain a target contour set, thereby improving the search efficiency of the target grid; then, the target contour with the largest area in the target contour set is determined as the outer contour of the graphic object, thereby improving the accuracy of searching the outer contour.
[0029] In a possible implementation, the enclosing frame is rectangular.
[0030] In the disclosed embodiment, the enclosing frame is rectangular, which is conducive to grid division in the enclosing frame.
[0031] In a possible implementation, the size of the grid is negatively correlated with the accuracy of the outer contour.
[0032] In the disclosed embodiment, since the size of the grid is negatively correlated with the outer contour accuracy of the graphic object, in the actual process, the size of the grid can be determined according to the actual accuracy requirements, thereby improving the applicability of the method.
[0033] The present disclosure provides a device for determining a graphic outline, including:
[0034] File acquisition module: used to acquire a target graphic file, wherein the target graphic file includes a graphic object, and the graphic object is used to reflect the two-dimensional line information of the target object;
[0035] A grid division module: used for determining a bounding box of the graphic object, and dividing the bounding box into a plurality of grids in a crisscross manner; the bounding box is a closed boundary box formed around the graphic object;
[0036] Contour determination module: used to determine multiple lines included in the graphic object based on the two-dimensional line information, and determine the outer contour of the graphic object based on the distribution information of the grids occupied by each of the multiple lines.
[0037] In a possible implementation manner, the contour determination module is specifically used to:
[0038] For each line, determining at least one first grid occupied by the line;
[0039] For each first grid, determining whether the first grid meets a preset condition, and if the first grid meets the preset condition, determining the first grid as a second grid;
[0040] The outer contour of the graphic object is determined based on the distribution information of each second grid.
[0041] In a possible implementation manner, the contour determination module is specifically used to:
[0042] A grid intersecting the line is determined as the first grid.
[0043] In a possible implementation, the preset condition includes that at least one boundary grid among boundary grids adjacent to the first grid is not the first grid; wherein the boundary grid is a grid that shares an edge with the first grid.
[0044] In a possible implementation manner, the contour determination module is specifically used to:
[0045] For each second grid, determining whether the second grid is an isolated grid, wherein the isolated grid is a second grid whose adjacent grid does not contain the first grid;
[0046] In the case where the second grid is not the isolated grid, determining the second grid as a target grid, and determining the outer contour of the graphic object based on distribution information of each target grid;
[0047] If the second grid is the isolated grid, the second grid is deleted.
[0048] In a possible implementation manner, the contour determination module is specifically used to:
[0049] Traversing each target grid in a depth-first search manner to obtain a target contour set, wherein the target contour set includes at least one target contour;
[0050] The target contour with the largest area in the target contour set is determined as the outer contour of the graphic object.
[0051] In a possible implementation, the size of the grid is negatively correlated with the accuracy of the outer contour.
[0052] In a possible implementation, the size of the grid is negatively correlated with the accuracy of the outer contour.
[0053] An embodiment of the present disclosure also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the method for determining the graphic contour described in any one of the above possible implementations are performed.
[0054] The embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for determining a graphic outline described in any possible implementation manner described above are executed.
[0055] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required to be cited in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0057] Figure 1 A flow chart of a method for determining a graphic outline provided by an embodiment of the present disclosure is shown;
[0058] Figure 2 A schematic diagram of a graphic object, a graphic object bounding box, and a grid provided by an embodiment of the present disclosure is shown;
[0059] Figure 3A flow chart of a method for determining an outer contour of a graphic provided by an embodiment of the present disclosure is shown;
[0060] Figure 4 A schematic diagram of a first grid provided by an embodiment of the present disclosure is shown;
[0061] Figure 5 A schematic diagram of a boundary grid and adjacent grids provided by an embodiment of the present disclosure is shown;
[0062] Figure 6 A schematic diagram of a second grid and an isolated grid provided by an embodiment of the present disclosure is shown;
[0063] Figure 7 A schematic diagram of a target grid provided by an embodiment of the present disclosure is shown;
[0064] Figure 8 A schematic diagram showing a target outline and an outer outline of a graphic object provided by an embodiment of the present disclosure is shown;
[0065] Fig. 9 A schematic diagram showing the structure of a device for determining a graphic outline provided by an embodiment of the present disclosure is shown;
[0066] Fig.10 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0067] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0068] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0069] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0070] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0071] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0072] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0073] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0074] In the fields of engineering design, construction and manufacturing, graphic files are often used, and a large number of graphic objects are used in graphic files. Since graphic objects have to be displayed in order, it is necessary that the graphic objects in the graphic files can cover each other.
[0075] It has been found that in Computer Aided Design (CAD) files, it is usually possible to achieve mutual occlusion between graphics by adding masks to the graphics. In the related art, there are usually two methods to determine the outer contour of the mask. One method is for the draftsman to manually add the outer contour of the mask, but this method has low efficiency and accuracy; the other method is to use a geometric figure contour search method to determine the outer contour of the mask. This method first finds the intersection of the lines in the figure, and extracts the outer contour of the graphic file by finding the connected path between these intersections. Although this method improves the efficiency of determining the outer contour of the mask compared to the manual addition method, due to the large amount of calculation of this method, the efficiency of contour search is still low. In addition, in some cases (such as high data accuracy requirements), the extracted contour may not be completely closed, resulting in low contour determination accuracy.
[0076] Based on the above research, a method for determining a graphic contour provided in an embodiment of the present disclosure first obtains a target graphic file, wherein the target graphic file includes a graphic object, and the graphic object is used to reflect two-dimensional line information of the target object; then, a bounding box of the graphic object is determined, and the bounding box is divided into a plurality of grids in a criss-cross manner; the bounding box refers to a closed boundary box formed around the graphic object; finally, based on the two-dimensional line information, a plurality of lines included in the graphic object are determined, and based on the distribution information of the grids occupied by each of the plurality of lines, the outer contour of the graphic object is determined.
[0077] In this way, the outer contour of the graphic can be automatically determined by the above method, which can improve the efficiency of contour determination compared to the manual method of determining the contour. In addition, in the embodiment of the present disclosure, when determining the contour, it is determined based on the distribution information of the divided grids and the grids occupied by each line of the graphic object, so that the determined outer contour can be a closed contour, thereby improving the accuracy of contour determination.
[0078] To facilitate understanding of this embodiment, the execution subject of the method for determining the graphic outline provided by the embodiment of the present disclosure is first introduced in detail. The execution subject of the method for determining the graphic outline provided by the embodiment of the present disclosure is an electronic device. The electronic device can be a terminal device or a server. Among them, the terminal device can also be a mobile device, a user terminal, a terminal, a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data and artificial intelligence platforms.
[0079] In other implementations, the method for determining the graphic outline may also be implemented by a processor calling computer-readable instructions stored in a memory.
[0080] The following is a detailed description of the method for determining the graphic outline provided in the embodiment of the present application in conjunction with the accompanying drawings. Figure 1 FIG. 1 is a flowchart of a method for determining a graphic outline provided by an embodiment of the present disclosure, wherein the method includes the following S101 to S103:
[0081] S101, obtaining a target graphic file, wherein the target graphic file includes a graphic object, and the graphic object is used to reflect two-dimensional line information of a target object.
[0082] Exemplarily, the target graphic file includes a CAD file, a vector graphics file, and a camera raw image file, etc. The graphic object refers to a graphic element or a graphic object in the target graphic file, and the graphic object includes at least one target object. When the graphic object includes multiple target objects, there needs to be an intersection between the multiple target objects.
[0083] The target object may include but is not limited to people, objects, animals, virtual objects, etc. The two-dimensional line information of the target object refers to the composition of the two-dimensional lines describing the target object and the characteristics and attributes of the two-dimensional lines. The characteristics and attributes of the two-dimensional lines may include the shape, length and direction of line segments and curves. The two-dimensional line information may also include the angle and curvature of the line, the thickness and color of the line, and the endpoints and intersections of the line.
[0084] S102, determining a bounding box of the graphic object, and dividing the bounding box into a plurality of grids in a crisscross manner; the bounding box is a closed boundary box formed around the graphic object.
[0085] Here, the bounding box of the graphic object is a closed boundary box formed around the graphic object, for example, see Figure 2 As shown, the enclosing box B of the graphic object A is a closed boundary box surrounding the graphic object A. In the embodiment of the present disclosure, the enclosing box B is rectangular, wherein the rectangular shape of the enclosing box B may be a square or a rectangle. In other embodiments, the shape of the enclosing box B may be a circle or other irregular shapes. In addition, in the embodiment of the present disclosure, the size of the enclosing box is not limited, for example, it may be the circumscribed rectangle of the graphic object A or a rectangle larger than the circumscribed rectangle of the graphic object A, and no specific limitation is made here.
[0086] After the bounding box is determined, the bounding box B can be divided into a plurality of grids C in a crisscross manner, wherein the crisscross manner means that when the bounding box B is divided into a plurality of grids C, the grid lines are alternately arranged along the longitudinal direction and the transverse direction to form a staggered grid structure. The transverse direction and the longitudinal direction may be in a vertical relationship or may not be in a vertical relationship.
[0087] Specifically, when the bounding box B is divided into a plurality of grids C, the grids C can be stored in a two-dimensional array, in which each grid C has a corresponding index, and subsequent information (such as the grid position) for the grid C can be recorded in the two-dimensional array for easy search. Here, the size of the grid C is negatively correlated with the accuracy of the outer contour, that is, the size of the grid can be determined according to the accuracy requirements, and the size of the grid C determines the number of samples and the resolution of the graphic object A. When the size of the grid C increases, the accuracy of the outer contour decreases; when the size of the grid C decreases, the accuracy of the outer contour increases.
[0088] S103, determining a plurality of lines included in the graphic object based on the two-dimensional line information, and determining an outer contour of the graphic object based on distribution information of grids occupied by each of the plurality of lines.
[0089] Specifically, the multiple lines included in the graphic object can be determined based on the two-dimensional line information of the target object, and each line information is parsed and processed respectively, and then the multiple lines are stored in a line array, and then each line can be taken out from the line array in turn, and the distribution information of the grid occupied by the line can be determined based on the starting point and end point of each line. The distribution information of the grid refers to the number and position of the grids occupied by each line. If the grid is occupied by a line, the grid can be marked, for example, the grid data of the occupied grid can be set to flag=1. Finally, the outer contour of the graphic object can be determined through the distribution information of the grids occupied by each line. The outer contour is the boundary line of the graphic object, and the outer contour describes the basic shape of the graphic object.
[0090] In the disclosed embodiment, the outer contour of the graphic can be automatically determined by the above method, which can improve the efficiency of contour determination compared to the manual contour determination method. In addition, in the disclosed embodiment, the contour is determined based on the distribution information of the divided grids and the grids occupied by the lines of the graphic object, so that the determined outer contour can be a closed contour, thereby improving the accuracy of contour determination.
[0091] See also Figure 3As shown, for the above step S103, when determining the outer contour of the graphic object based on the distribution information of the grids occupied by each of the multiple lines, the following steps S1031 to S1033 may be included:
[0092] S1031, for each line, determining at least one first grid occupied by the line;
[0093] For example, see Figure 4 FIG. 1 is a schematic diagram of a first grid according to an embodiment of the present disclosure. For each line, a grid intersecting with the line may be determined as the first grid. For example, Figure 4 The grid in the shaded part is the first grid occupied by each line of the graphic object A. In the embodiment of the present disclosure, the intersection of a line and a grid means that there is an intersection between the line and the grid. As long as there is an intersection between the line and the boundary of the grid, it can be determined that the line and the grid intersect. In other embodiments, the intersection of a line and a grid may mean that the proportion of the grid divided by the line is greater than a preset proportion.
[0094] S1032, for each first grid, determining whether the first grid meets a preset condition, and if the first grid meets the preset condition, determining the first grid as a second grid;
[0095] For each first grid determined in step S1031, determine whether the first grid meets a preset condition, where the preset condition refers to at least one boundary grid adjacent to the first grid that is not the first grid; wherein the boundary grid refers to a grid that shares an edge with the first grid. For example, see Figure 5 As shown, the boundary grids of grid 501 are grids 1, 2, 3, and 4, and the boundary grids 1, 2, 3, and 4 respectively share different edges with the grid 501. When the first grid meets the preset condition, the first grid is determined as the second grid. Figure 6 As shown, Figure 6 All the shaded grids in are second grids. In addition, the boundary grids of the first grid F are all first grids, which do not meet the preset conditions. Therefore, the first grid F is not a second grid.
[0096] S1033: Determine the outer contour of the graphic object based on the distribution information of each second grid.
[0097] Exemplarily, when each second grid is determined, the outer contour of the graphic object may be determined based on the distribution information of the each second grid.
[0098] In some embodiments, when determining the outer contour of the graphic object based on the distribution information of each second grid, the following (a) to (c) may be included:
[0099] (a) for each second grid, determining whether the second grid is an isolated grid, wherein the isolated grid is a second grid whose adjacent grid does not contain the first grid;
[0100] (b) in the case where the second grid is not the isolated grid, determining the second grid as a target grid, and determining the outer contour of the graphic object based on distribution information of each target grid;
[0101] (c) When the second grid is the isolated grid, the second grid is deleted.
[0102] For details, please refer again to Figure 5 The adjacent meshes of mesh 501 include boundary meshes 1, 2, 3, 4 and vertex meshes 12, 23, 34, 14. The definition of the boundary mesh has been provided in detail in the aforementioned step S1032 and will not be repeated here; the vertex mesh refers to the mesh that shares the same vertex with the mesh 501.
[0103] For example, please refer again to Figure 6 , the second grid G meets the isolated grid judgment condition, therefore, the second grid G is an isolated grid. In the case where the second grid G is an isolated grid, the second grid G needs to be deleted to improve the accuracy of contour determination. In the case where the second grid is not an isolated grid, the second grid is determined as the target grid, see Figure 7 As shown in the figure, the shaded grid represents the target grid obtained after deleting the isolated grid G. After the target grid is determined, the outer contour of the graphic object can be determined based on the distribution information of each target grid.
[0104] Specifically, when determining the outer contour of the graphic object based on the distribution information of each target grid, the target grids can be traversed in a depth-first search manner to obtain a target contour set, which includes at least one target contour; then the target contour with the largest area in the target contour set is determined as the outer contour of the graphic object.
[0105] Here, the depth-first search method is an algorithm used in the computer field to traverse or search a graph or tree. It explores each node of the graph or tree in a depth-first manner, gradually moving forward until it reaches the deepest node, and then returns and continues to explore unvisited nodes.
[0106] In this embodiment, the target contour of the graphic object is determined by traversing each target grid in a depth-first search mode. Specifically, the search is performed starting from an initial target grid in a depth-first search mode. The initial target grid can reach other adjacent grids. During the search process, the searched target grids are recorded, and all target grids that have not been traversed are searched in sequence. When the initial target grid is found again during the search process, the search track is recorded as the target contour; when the initial target grid is not found again during the search process, the initial target grid is replaced for another search.
[0107] After obtaining the target contour set, the independent area of each target contour can be calculated according to the found target contour set. The independent area refers to the target contour area that has no intersection or inclusion relationship with other target contours, and the target contour with the largest independent area is determined as the outer contour of the graphic object. Figure 8 As shown, the target contour set of the graphic object A includes 801 and 802, and the target contour 801 with the largest area in the target contour set is determined as the outer contour of the graphic object A. The outer contour may include multiple independent target contours.
[0108] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0109] Based on the same inventive concept, the embodiment of the present disclosure also provides a device for determining a graphic contour corresponding to the method for determining a graphic contour. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the method for determining a graphic contour in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0110] Reference Fig. 9 FIG. 1 is a schematic diagram of a device 900 for determining a graphic outline provided by an embodiment of the present disclosure, wherein the device comprises:
[0111] File acquisition module 901: used to acquire a target graphic file, wherein the target graphic file includes a graphic object, and the graphic object is used to reflect the two-dimensional line information of the target object;
[0112] Grid division module 902: used to determine the bounding box of the graphic object, and divide the bounding box into a plurality of grids in a crisscross manner; the bounding box is a closed boundary box formed around the graphic object;
[0113] Contour determination module 903: used to determine a plurality of lines included in the graphic object based on the two-dimensional line information, and determine the outer contour of the graphic object based on distribution information of grids occupied by each of the plurality of lines.
[0114] In a possible implementation manner, the contour determination module 903 is specifically configured to:
[0115] For each line, determining at least one first grid occupied by the line;
[0116] For each first grid, determining whether the first grid meets a preset condition, and if the first grid meets the preset condition, determining the first grid as a second grid;
[0117] The outer contour of the graphic object is determined based on the distribution information of each second grid.
[0118] In a possible implementation manner, the contour determination module 903 is specifically configured to:
[0119] A grid intersecting the line is determined as the first grid.
[0120] In a possible implementation, the preset condition includes that at least one boundary grid among boundary grids adjacent to the first grid is not the first grid; wherein the boundary grid refers to a grid that shares an edge with the first grid.
[0121] In a possible implementation manner, the contour determination module 903 is specifically configured to:
[0122] For each second grid, determining whether the second grid is an isolated grid, wherein the isolated grid is a second grid whose adjacent grid does not contain the first grid;
[0123] In the case where the second grid is not the isolated grid, determining the second grid as a target grid, and determining the outer contour of the graphic object based on distribution information of each target grid;
[0124] If the second grid is the isolated grid, the second grid is deleted.
[0125] In a possible implementation manner, the contour determination module 903 is specifically configured to:
[0126] Traversing each target grid in a depth-first search manner to obtain a target contour set, wherein the target contour set includes at least one target contour;
[0127] The target contour with the largest area in the target contour set is determined as the outer contour of the graphic object.
[0128] In a possible implementation, the size of the grid is negatively correlated with the accuracy of the outer contour.
[0129] In a possible implementation, the size of the grid is negatively correlated with the accuracy of the outer contour.
[0130] Based on the same technical concept, the embodiment of the present disclosure also provides an electronic device. Fig.10 1 is a schematic diagram of the structure of an electronic device 1000 provided in an embodiment of the present disclosure, including a processor 1001, a memory 1002, and a bus 1003. The memory 1002 is used to store execution instructions, including a memory 10021 and an external memory 10022; the memory 10021 is also called an internal memory, which is used to temporarily store the operation data in the processor 1001 and the data exchanged with the external memory 10022 such as a hard disk. The processor 1001 exchanges data with the external memory 10022 through the memory 10021.
[0131] In the embodiment of the present application, the memory 1002 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 1001. That is, when the electronic device 1000 is running, the processor 1001 communicates with the memory 1002 through the bus 1003, so that the processor 1001 executes the application code stored in the memory 1002, and then executes the method described in any of the above embodiments.
[0132] Among them, the memory 1002 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0133] Processor 1001 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0134] It is understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 1000. In other embodiments of the present application, the electronic device 1000 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0135] The present disclosure also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of the method for determining the contour of the graphic in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0136] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the method for determining the graphic contour in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0137] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0138] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0141] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk.
[0142] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for determining a graphic outline, characterized in that: include: Acquire a target graphic file, wherein the target graphic file includes a graphic object, and the graphic object is used to reflect two-dimensional line information of the target object; Determine a bounding box of the graphic object, and divide the bounding box into a plurality of grids in a crisscross manner; the bounding box is a closed boundary box formed around the graphic object; A plurality of lines included in the graphic object are determined based on the two-dimensional line information, and an outer contour of the graphic object is determined based on distribution information of grids occupied by each of the plurality of lines.
2. The method according to claim 1, characterized in that The determining the outer contour of the graphic object based on the distribution information of the grids occupied by each of the plurality of lines comprises: For each line, determining at least one first grid occupied by the line; For each first grid, determining whether the first grid meets a preset condition, and if the first grid meets the preset condition, determining the first grid as a second grid; The outer contour of the graphic object is determined based on the distribution information of each second grid.
3. The method according to claim 2, characterized in that The determining of at least one first grid occupied by the line comprises: A grid intersecting the line is determined as the first grid.
4. The method according to claim 2, characterized in that: The preset condition includes that at least one boundary mesh among boundary meshes adjacent to the first mesh is not the first mesh; wherein the boundary mesh is a mesh that shares an edge with the first mesh.
5. The method according to any one of claims 2 to 4, characterized in that: The determining the outer contour of the graphic object based on the distribution information of each second grid comprises: For each second grid, determining whether the second grid is an isolated grid, wherein the isolated grid is a second grid whose adjacent grid does not contain the first grid; In the case where the second grid is not the isolated grid, determining the second grid as a target grid, and determining the outer contour of the graphic object based on distribution information of each target grid; If the second grid is the isolated grid, the second grid is deleted.
6. The method according to claim 5, characterized in that The determining the outer contour of the graphic object based on the distribution information of each target grid includes: Traversing each target grid in a depth-first search manner to obtain a target contour set, wherein the target contour set includes at least one target contour; The target contour with the largest area in the target contour set is determined as the outer contour of the graphic object.
7. The method according to any one of claims 1 to 4, characterized in that: The enclosing frame is rectangular.
8. The method according to any one of claims 1 to 4, characterized in that: The size of the grid is negatively correlated to the accuracy of the outer contour.
9. A device for determining a graphic outline, characterized in that: include: A file acquisition module, used to acquire a target graphic file, wherein the target graphic file includes a graphic object, and the graphic object is used to reflect the two-dimensional line information of the target object; A grid division module, used to determine the bounding box of the graphic object and divide the bounding box into a plurality of grids in a crisscross manner; the bounding box is a closed boundary box formed around the graphic object; The contour determination module is used to determine a plurality of lines included in the graphic object based on the two-dimensional line information, and determine the outer contour of the graphic object based on the distribution information of the grids occupied by each of the plurality of lines.
10. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable requests executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable request is executed by the processor, the steps of the method for determining the graphic outline as described in any one of claims 1 to 8 are performed.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the method for determining a graphic contour as claimed in any one of claims 1 to 8.