Line graph generation method and device based on three-dimensional grid model
By clustering, optimizing and rendering the feature lines of the three-dimensional grid model, efficient and consistent line maps are generated, which solves the problems of inefficiency and limited accuracy of traditional methods, and is suitable for automated line map generation in various fields.
Patent Information
- Application Number
- CN202411130729.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-17
AI Technical Summary
The traditional three-dimensional grid model line graph generation method is inefficient and difficult to ensure consistency, with high time and economic costs, and other methods have limited accuracy, making it difficult to meet the growing demand for automated line graph generation.
By clustering triangles in the three-dimensional mesh model, structural feature lines and texture feature lines are extracted, and optimization processing and orthoprojection are performed, and two-dimensional line diagrams are generated in combination with rendering processing to realize automated processes and improved algorithms.
It improves the efficiency and consistency of line map generation, has a wide range of applications, and is suitable for the protection of ancient buildings, digitalization of cultural relics, three-dimensional printing and graphic design, and meets the needs of automated line map generation.
Smart Images

Figure CN119152144A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of three-dimensional model processing, and in particular to a method and device for generating a line graph based on a three-dimensional grid model. Background Art
[0002] In the related art, the traditional method of generating line drawings of three-dimensional mesh models mainly relies on manual drawing by professional draftsmen, who use pencils, ink and other tools to draw line drawings of ancient buildings or cultural relics on drawings. This method relies on the professional skills and experience of draftsmen, and can finely depict the details and features of ancient buildings or cultural relics. With the rapid development of deep learning and image processing technology, some new line drawing generation methods have also emerged. For example, using computer vision and image processing algorithms, three-dimensional models of ancient buildings or cultural relics can be reconstructed. Based on the three-dimensional model, line drawings of various perspectives can be generated, including front view, top view, side view, etc.
[0003] However, the traditional three-dimensional mesh model line drawing generation method in the related technology is inefficient and difficult to ensure consistency, with high time and economic costs. Other three-dimensional mesh model line drawing generation methods have limited accuracy and are difficult to meet the growing demand for automated line drawing generation, which needs to be solved urgently. Summary of the invention
[0004] The present application provides a line graph generation method and device based on a three-dimensional grid model to solve the problems in the related art that the traditional three-dimensional grid model line graph generation method is inefficient and difficult to ensure consistency, has high time and economic costs, and other three-dimensional grid model line graph generation methods have limited accuracy and are difficult to meet the growing demand for automated line graph generation.
[0005] The first aspect of the present application provides a method for generating a line drawing based on a three-dimensional mesh model, comprising the following steps: clustering triangles in a target three-dimensional mesh model to obtain clustering results, and based on the clustering results, extracting structural feature lines and texture feature lines of the target three-dimensional mesh model; drawing the structural feature lines and the texture feature lines on the target three-dimensional mesh model to obtain model feature lines, and optimizing and orthographically projecting the model feature lines to generate a two-dimensional line drawing of the target three-dimensional mesh model; rendering the two-dimensional line drawing to generate a final elevation line drawing of the target three-dimensional mesh model.
[0006] Optionally, in one embodiment of the present application, the triangles in the target three-dimensional mesh model are clustered to obtain clustering results, including: taking the angle between the normal vectors of the triangles as a similarity measurement criterion, and clustering the triangles in the target three-dimensional mesh model using the normal vectors of the triangles as data units within a target angle value range to obtain an initial clustering result; and classifying according to the connection relationship of the initial clustering results to obtain the clustering results.
[0007] Optionally, in one embodiment of the present application, extracting the structural feature lines and texture feature lines of the target three-dimensional mesh model based on the clustering results includes: extracting the boundary lines of the clustering results based on preset filtering conditions; drawing the boundary lines on the target three-dimensional mesh model, and extracting the structural feature lines of the target three-dimensional mesh model.
[0008] Optionally, in one embodiment of the present application, the optimization processing and orthographic projection of the model feature lines to generate a two-dimensional line graph of the target three-dimensional mesh model includes: optimizing the model feature lines based on a local B-spline curve interpolation fitting algorithm to obtain a closed curve that meets preset optimization conditions; orthographic projection of the closed curve to obtain the contour line of the target three-dimensional mesh model; and generating a two-dimensional line graph of the target three-dimensional mesh model based on the structural feature lines, the texture feature lines and the contour lines.
[0009] The second aspect of the present application provides a line drawing generation device based on a three-dimensional mesh model, including: an extraction module, used to cluster triangles in a target three-dimensional mesh model to obtain clustering results, and based on the clustering results, extract the structural feature lines and texture feature lines of the target three-dimensional mesh model; a processing module, used to draw the structural feature lines and the texture feature lines on the target three-dimensional mesh model to obtain model feature lines, and optimize and orthographically project the model feature lines to generate a two-dimensional line drawing of the target three-dimensional mesh model; a generation module, used to render the two-dimensional line drawing to generate a final elevation line drawing of the target three-dimensional mesh model.
[0010] Optionally, in one embodiment of the present application, the extraction module includes: a clustering unit, used to use the angle between the normal vectors of the triangles as a similarity measurement criterion, and cluster the triangles in the target three-dimensional mesh model using the normal vectors of the triangles as data units within the target angle value range to obtain an initial clustering result; a classification unit, used to classify according to the connection relationship of the initial clustering result to obtain the clustering result.
[0011] Optionally, in one embodiment of the present application, the extraction module includes: a first extraction unit, used to extract the boundary line of the clustering result based on preset filtering conditions; a second extraction unit, used to draw the boundary line on the target three-dimensional mesh model to extract the structural feature line of the target three-dimensional mesh model.
[0012] Optionally, in one embodiment of the present application, the processing module includes: an optimization unit, used to optimize the model feature lines based on a local B-spline curve interpolation fitting algorithm to obtain a closed curve that meets preset optimization conditions; a processing unit, used to orthographically project the closed curve to obtain the contour line of the target three-dimensional mesh model; and a generation unit, used to generate a two-dimensional line graph of the target three-dimensional mesh model based on the structural feature lines, the texture feature lines and the contour lines.
[0013] The third aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the line graph generation method based on the three-dimensional grid model as described in the above embodiment.
[0014] The fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program. When the program is executed by a processor, it implements the above-mentioned line graph generation method based on the three-dimensional grid model.
[0015] The fifth aspect of the present application provides a computer program product, including a computer program, which, when executed, is used to implement the above-mentioned line graph generation method based on the three-dimensional grid model.
[0016] The embodiment of the present application can extract the structural feature lines and texture feature lines of the three-dimensional mesh model through an automated process and an improved algorithm, and then combine the structural feature lines, texture feature lines and outer contour lines through optimization processing, orthographic projection and rendering processing, so as to generate the final line graph corresponding to the three-dimensional mesh model. Thus, while ensuring the quality and consistency of the line graph generated by the three-dimensional mesh model, the efficiency of line graph generation is effectively improved, and the scope of application is wide, and it can be actually applied to various fields such as ancient building protection, cultural relics digitization, three-dimensional printing and graphic design. Thus, the problems of the traditional three-dimensional mesh model line graph generation method in the related art being inefficient and difficult to ensure consistency, having high time cost and economic cost, and other three-dimensional mesh model line graph generation methods being limited in accuracy and difficult to meet the growing demand for automated line graph generation are solved.
[0017] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0019] Figure 1 A flowchart of a line graph generation method based on a three-dimensional grid model provided according to an embodiment of the present application;
[0020] Figure 2 A schematic diagram of the texture feature line extraction effect of a model according to an embodiment of the present application;
[0021] Figure 3 A schematic diagram of a frequency histogram of the total area of triangles according to an embodiment of the present application;
[0022] Figure 4 A schematic diagram of local B-spline curve interpolation fitting according to an embodiment of the present application;
[0023] Figure 5 This is a schematic diagram of the interpolation fitting effect of different k1 and k2 values according to an embodiment of the present application;
[0024] Figure 6 This is a schematic diagram of a semi-automatically extracted elevation line drawing of an embodiment of the present application;
[0025] Figure 7 This is a flow chart of a method for generating a line graph based on a three-dimensional grid model according to an embodiment of the present application;
[0026] Figure 8 is a schematic structural diagram of a line graph generating device based on a three-dimensional grid model according to an embodiment of the present application;
[0027] Fig. 9 Schematic diagram of the structure of an electronic device according to an embodiment of the present application.
[0028] Reference numerals:
[0029] 10-Line diagram generating device based on three-dimensional grid model: 100-extraction module, 200-processing module and 300-generating module; 901-memory, 902-processor and 903-communication interface. DETAILED DESCRIPTION
[0030] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0031] The following describes the line drawing generation method and device based on the three-dimensional grid model of the embodiment of the present application with reference to the accompanying drawings. In view of the problems that the traditional three-dimensional grid model line drawing generation method in the related art mentioned in the above background technology is inefficient and difficult to ensure consistency, and the time cost and economic cost are both high, and other three-dimensional grid model line drawing generation methods are limited in accuracy and difficult to meet the growing demand for automated line drawing generation, the present application provides a line drawing generation method based on a three-dimensional grid model, in which the structural feature lines and texture feature lines of the three-dimensional grid model can be extracted through an automated process and an improved algorithm, and then the structural feature lines, texture feature lines and outer contour lines are combined through optimization processing, orthographic projection and rendering processing to generate the final three-dimensional grid model corresponding line drawing. As a result, while ensuring the quality and consistency of the line drawing generated by the three-dimensional grid model, the efficiency of line drawing generation is effectively improved, and the scope of application is wide, and it can be actually applied to various fields such as ancient building protection, cultural relics digitization, three-dimensional printing and graphic design. As a result, the problems in the related technologies such as the low efficiency and difficulty in ensuring consistency of traditional 3D mesh model line drawing generation methods, high time and economic costs, and the limited accuracy of other 3D mesh model line drawing generation methods are solved.
[0032] Specifically, Figure 1 A flowchart of a line graph generation method based on a three-dimensional grid model provided in an embodiment of the present application.
[0033] like Figure 1 As shown, the line graph generation method based on the three-dimensional grid model includes the following steps:
[0034] In step S101, the triangles in the target three-dimensional mesh model are clustered to obtain clustering results, and based on the clustering results, the structural feature lines and texture feature lines of the target three-dimensional mesh model are extracted.
[0035] It can be understood that a three-dimensional mesh model is a model that represents three-dimensional geometric information through points, lines and surfaces in three-dimensional space. The target three-dimensional mesh model here can be understood as a three-dimensional mesh model of a target object that needs to generate a line map, such as an ancient building, a cultural relic, etc. The structural feature line here can be understood as a straight line, curve, acute angle, obtuse angle and other shapes that highlight the unique features and structural characteristics of an object by depicting the outline, boundary or partial details of the object, which may depend on the characteristics of the object or shape being described. Texture feature lines here can be understood as extracting specific linear structures or patterns from objects or object images with textures, and these structures or patterns can be regarded as texture feature lines.
[0036] In some embodiments, when extracting the structural feature lines of the target three-dimensional network model, the present application may, but is not limited to, using a direction-based clustering algorithm to first cluster the triangles in the target three-dimensional network model, generate clustering results, and then extract the structural feature lines and texture feature lines of the target three-dimensional mesh model based on the clustering results.
[0037] For example, when extracting feature lines of ancient buildings, the feature lines can be divided into two categories according to their sources: structural feature lines of buildings and feature lines based on textures. When extracting structural feature lines in ancient buildings, an angle-based clustering algorithm can be used, but is not limited to, to process the triangular mesh model of the ancient buildings. When extracting texture feature lines in ancient buildings, an edge detection algorithm can be used, but is not limited to, to extract texture feature lines.
[0038] Taking the extraction of texture feature lines in ancient buildings as an example, when using the direction-based clustering algorithm to cluster the triangles in the target 3D network model, all triangles in the triangulated network can be clustered into different categories T according to the different directions of the normal vectors. Then, according to whether there is a connection relationship, all triangles in T are further classified into R = {R1, R2, ..., R n Take any category R, all the triangles it contains have basically the same orientation and are topologically connected to each other.
[0039] On this basis, texture feature lines are extracted: the textures of all triangles in any category R are integrated into a relatively complete texture image. This process can be, but is not limited to, edge detection of the triangle set R obtained above using edge detection algorithms and Canny operators. The two thresholds in the operator can also be set to 60 and 120 respectively, and the detected edge lines are mapped back to space to be drawn on the surface of the target three-dimensional mesh model to obtain and extract texture feature lines. The texture feature lines extracted in this way exist on a two-dimensional plane and need to be transformed by a matrix to be mapped back to the original triangular mesh model.
[0040] Figure 2 This is a schematic diagram of the texture feature line extraction effect of an embodiment of the present application. Figure 2 As shown in the figure, it can be seen that the extraction effect of texture feature lines is more obvious in flat areas, such as the door and window area, where the edges of the lattice windows can be identified relatively well. However, in some areas with more noise, such as fences and brackets, these parts are more exposed to the outside world, and are easily discolored and cracked after being exposed to wind, rain, and sunlight, which will form interference noise on the texture, resulting in the extraction of wrong texture feature lines.
[0041] The embodiment of the present application can cluster triangles in a target three-dimensional mesh model to extract structural feature lines of the target three-dimensional mesh model, and then use the structural feature lines to describe and extract important features and shape information of the target object.
[0042] Optionally, in one embodiment of the present application, triangles in a target three-dimensional mesh model are clustered to obtain a clustering result, including: based on preset filtering conditions, taking the angle between the normal vectors of the triangles as a similarity measurement criterion, clustering the triangles in the target three-dimensional mesh model using the normal vectors of the triangles as data units within a target angle value range to obtain an initial clustering result; and classifying according to the connection relationship of the initial clustering result to obtain a clustering result.
[0043] Based on the relevant descriptions of other embodiments, it can be understood that the present application can, but is not limited to, cluster the triangles in the target three-dimensional mesh model using a clustering algorithm. Further, in the clustering process, the present application embodiment can cluster the triangles in the target three-dimensional mesh model based on a clustering algorithm, using the normal vectors of the triangles in the target three-dimensional mesh model as data units, using the angle between the normal vectors as a similarity measurement criterion, and then combining the area of the triangle as the core of the weight calculation cluster to cluster the triangles in the target three-dimensional network model.
[0044] It should be noted that when extracting structural feature lines from some more complex target three-dimensional grid models, such as some ancient building three-dimensional grid models, since the appearance of the ancient buildings is very complex, in order to more accurately extract the structural feature lines, before using the clustering algorithm, the embodiment of the present application can specify an angle threshold β in advance. Specifically, the range of the threshold β can be determined first, and then a suitable value can be determined. For example, the β value is set to 10° to 90°, increasing by 10° every time, and eventually a suitable threshold can be obtained by professional and technical personnel in this field or through experimental analysis. When the threshold β is moderate, the number of categories after clustering is relatively accurate, the effect is relatively ideal, and the boundary lines formed by areas with different orientations can be properly reflected. For example, the embodiment of the present application can use a threshold β = 40° as a similarity measurement scale.
[0045] Specifically, the process of clustering triangles in the target three-dimensional mesh model using a clustering algorithm can be expressed as follows:
[0046] (1) Traverse each triangle in the triangulated network of the target 3D mesh model and calculate the normal vector of the triangle using the cross product of the vectors The length of represents twice the area of the triangle, and the area value of the triangle is recorded. Then the angle α between the first and second normal vectors is calculated and compared with the pre-specified threshold β. If α>β, the two normal vectors and the triangles they represent are classified into a class T, and the weighted average is calculated using the area value of the triangle as the weight, which is used as the clustering core of this class. If α<β, the two normal vectors and the triangles they represent are classified into two categories T1 and T2; the formula can be expressed as follows:
[0047]
[0048] (2) Take out the i-th normal vector Calculate the clustering core vector of it and all other categories The angle set A={α1,α2,...,α k If all the included angles α in set A are greater than the threshold β, the i-th normal vector and the triangle it represents are classified into a new category; if there is a case in set A that is less than the threshold β, the α with the smallest value is taken out. min The category T represented α , then the ith normal vector and the triangle it represents are assigned to T α , and recalculate the clustering core of this class according to the formula
[0049] (3) Repeat step (2) until all normal vectors in the mesh model are traversed. At this point, the normal vectors are clustered based on direction and the initial clustering result is obtained.
[0050] Furthermore, the embodiments of the present application can further divide the triangles into different categories according to whether they are spatially connected after clustering all normal vectors in the target triangular mesh model according to direction to obtain the initial clustering result. That is, for a set of already clustered triangles, they can be reclassified based on whether there is a connection relationship, and divided into unconnected areas to obtain the final required clustering result.
[0051] Optionally, in one embodiment of the present application, based on the clustering results, structural feature lines and texture feature lines of the target three-dimensional mesh model are extracted, including: based on preset filtering conditions, extracting boundary lines of the clustering results; drawing boundary lines on the target three-dimensional mesh model, and extracting structural feature lines of the target three-dimensional mesh model.
[0052] It can be understood that the preset filtering condition here can be understood as a condition for filtering some clustering results, for example, the number of triangles in some clustering results is less than a certain number and the total area of the triangles is less than a certain area.
[0053] In some embodiments, after obtaining the clustering results, the structural feature lines can be extracted according to the clustering results. That is, based on certain filtering conditions and clustering results, the boundary lines of triangles (i.e., unconnected areas) in the clustering results after reclassification can be extracted and drawn in the target three-dimensional grid model, so as to obtain the structural feature lines that really need to be extracted.
[0054] For example, after clustering all normal vectors in the triangular mesh model of the ancient building according to direction, different categories can be further divided according to whether they are connected to each other in space. It can be understood that for a clustered triangle set T, whether there is a connection relationship is used as the standard to classify it again into unconnected areas, and set certain filtering conditions in this process, which can be specifically expressed as follows:
[0055] In order to achieve a better filtering effect, we can first calculate the triangle set R = {R1, R2, ..., R n} were statistically analyzed for the number and total area of triangles.
[0056] Analyzing the statistical data, we can find that there are some areas formed by a single triangle in each category, and the number is relatively large. Although these areas are oriented differently from other areas and can be separated by clustering, the number of triangles themselves is too small, so these areas can be eliminated to avoid extracting unnecessary boundary lines and interfering with the extraction of structural feature lines.
[0057] After classification again, the triangle set R = {R1, R2, ..., R n}, and the first 5 of the 17 categories are taken. Table 1 is a statistical table of the total area of triangles in the first 5 categories, which can be expressed as follows:
[0058]
[0059] Since the model accuracy is relatively high, the embodiment of the present application may, but is not limited to, set the area unit to square centimeters. Figure 3 This is a frequency histogram of the total area of triangles according to an embodiment of the present application. Figure 3 As shown, the total data when taking the first 5 categories is shown respectively.
[0060] Combining statistical data and frequency histograms, it can be seen that the total area of triangles in each unconnected area is generally in the shape of a "U". The data is distributed more in a smaller range of 200 square centimeters and below and in a larger range of 1000 and above, with a median between 200 and 300 square centimeters. Although there are many areas below 200 square centimeters, considering that their area is too small, if their boundary lines are regarded as structural feature lines for extraction, there will be too many fragments. Therefore, the embodiment of the present application can take the threshold Area at 100 to 200 square centimeters to delete areas with too small an area.
[0061] Taking the three-dimensional grid model of the Yingxian Wooden Pagoda as an example, combined with its high spatial resolution and statistical data, the filtering conditions can be set as, but not limited to, the number of triangles in the clustering results Sum = 2 and the total area of triangles Area = 150 square centimeters, that is, only areas with a number of triangles greater than 2 and a total area of triangles greater than 150 square centimeters are retained, which can effectively remove small and fragmented triangle collections and achieve better results.
[0062] Calculate the boundary line of each area: take the i-th triangle r in the set T i , judge it and all other categories R = {R1, R2, ..., R k}Whether there are common points. If there are no common points, it means that there is no connection relationship, so the i-th triangle is classified as a new type R k+1 , calculate its boundary line B. If there are common points, then it is necessary to judge according to the number of categories with common points. If there is only one category R spe With the i-th triangle r i There is a common point, then r i Classified as R spe and recalculate the boundary line B. If there are two or more categories with r i There are common points, then these categories and r i Merged into new category R new , and recalculate the boundary line B new .
[0063] Repeat the above steps until all triangles in set T are traversed. Set the triangle number threshold Sum and the total area threshold Area to filter the classified categories R = {R1, R2, ..., R n}. If there is R j , where the number of triangles is less than Sum and the total area of triangles is less than Area, then R j Culling to remove fragmented, small triangle collections.
[0064] Based on the recalculated and sorted boundary lines, the boundary lines are drawn on the target triangular mesh model, that is, the structural feature lines of the target three-dimensional mesh model can be extracted.
[0065] Step S102, drawing the structural feature lines and the texture feature lines on the target three-dimensional mesh model to obtain the model feature lines, and performing optimization processing and orthographic projection on the model feature lines to generate a two-dimensional line drawing of the target three-dimensional mesh model.
[0066] As a possible implementation method, after extracting the structural feature lines and texture feature lines of the ancient building, the embodiment of the present application can merge the two and draw them on the surface of the target three-dimensional grid model to form a relatively complete and preliminary model feature lines.
[0067] Based on the model characteristic line, the model characteristic line is then optimized using a B-spline curve fitting method, such as reducing the sharpness of the line based on a local B-spline curve interpolation fitting algorithm and using a B-spline curve for smoothing.
[0068] Then the optimized feature lines are orthographically projected, and after the orthographic projection is completed, the contour lines of the model are extracted to form a two-dimensional line graph of the target three-dimensional mesh model according to the contour lines.
[0069] Next, the process of optimizing and orthographically projecting the model feature lines to generate a two-dimensional line graph of the target three-dimensional mesh model in the embodiment of the present application is further explained.
[0070] Optionally, in one embodiment of the present application, the model feature lines are optimized and orthographically projected to generate a two-dimensional line graph of the target three-dimensional mesh model, including: optimizing the model feature lines based on a local B-spline curve interpolation fitting algorithm to obtain a closed curve that meets preset optimization conditions; orthographically projecting the closed curve to obtain the contour lines of the target three-dimensional mesh model; generating a two-dimensional line graph of the target three-dimensional mesh model based on the structural feature lines, texture feature lines and contour lines.
[0071] In the actual implementation process, the conventional global B-spline curve interpolation fitting algorithm is difficult to meet the use requirements of the embodiment of the present application in terms of line accuracy. Therefore, the present application has made improvements on the global B-spline curve interpolation fitting algorithm and proposed a local B-spline curve interpolation fitting algorithm. In order to prevent the interpolated B-spline curve from deviating too much from the original characteristic line, the local B-spline curve interpolation fitting algorithm proposed in the embodiment of the present application can determine whether the part needs interpolation fitting according to the sharpness of the angle and use the interpolation point to constrain the deviation degree of the B-spline curve.
[0072] It should be noted that before line optimization, manual auxiliary processing can be performed, but is not limited to, to manually delete the wrong structural feature lines and texture feature lines to avoid generating distorted curves and amplifying wrong data. After deletion, the local B-spline curve can be used to interpolate and fit the feature lines.
[0073] Specifically, the main steps of the local B-spline curve interpolation fitting algorithm in the embodiment of the present application can be as follows:
[0074] (1) Import the discrete point set V that constitutes the feature line = {V1, V2, ..., V i}, and set an angle threshold α.
[0075] (2) Traverse each angle of the feature line and determine whether the angle is less than the threshold α. If it is greater than the threshold α, no interpolation fitting is required; if it is less than the threshold α, new discrete points need to be inserted to constrain the B-spline curve. Figure 4 This is a schematic diagram of a local B-spline curve interpolation fitting according to an embodiment of the present application. Figure 4 As shown, we can take out the two sides AB and BC that form the angle and calculate their lengths. Taking the shorter side (AB in the figure) as the standard, insert new discrete points P1 and P2 according to the ratio k1 and k2. Take BP1 on BC according to the length of BP1 and BP2. ‘ ,BP2 ’ . With P1, P2, B, P2 ‘ ,P1 ’ Based on , a B-spline curve interpolation fitting algorithm is used to generate a curve passing through these 5 points, and 100 interpolation points are taken between the points.
[0076] (3) After traversing the feature line, all the curves obtained in (2) are spliced together to form a complete closed line to complete the optimization of the feature line.
[0077] After the optimization using B-spline curves is completed, the feature lines of the model are still in three-dimensional space and need to be projected onto a plane to form an orthophoto. In order to accurately extract the elevation line drawing, the embodiment of the present application can, but is not limited to, produce an orthophoto based on a vertical plane. Specifically, the viewing cone under orthogonal projection is a cuboid, and near and far in the figure represent the near clipping plane and far clipping plane of the viewing cone. Only the model in this viewing cone can be captured by the camera and projected on the screen.
[0078] In order to obtain appropriate orthogonal projection matrix parameters, it is necessary to calculate the center center and radius of the spherical bounding box of the target 3D mesh model, and substitute them into the following formula to obtain the data of the near and far clipping planes of the frustum. Top, bottom, left and right can take values equal to radius. The formula can be expressed as follows:
[0079]
[0080] After setting the parameters of the view cone, you should also adjust the position of the camera, the direction of the camera, and the rotation angle of the camera. In the embodiment of the present application, you can, but are not limited to, set the direction of the camera to point to the center of the bounding box, and the rotation angle of the camera to 0°, that is, the top of the camera points to the z-axis, so that the orthographic image of the model based on the vertical plane can be obtained. At this time, the position of the camera eye can be as follows:
[0081] eye=center+[0,1,0]*radius
[0082] Therefore, the embodiment of the present application will extract the outer contour of the model only after completing the orthographic projection based on the vertical plane. The process of extracting the outer contour of the model can be expressed as follows: during the orthographic projection, a solid color background different from the color of the model, such as white, is set, the model is placed therein, and the model is orthographically projected based on the vertical plane to obtain the orthographic image of the model; the orthographic image is then binarized, and any color different from the background color is classified as black. The binarized image is edge detected using the canny operator, sobel operator, etc., so that the contour of the model can be better extracted.
[0083] Figure 5 FIG. 1 is a schematic diagram of interpolation fitting effects of different k1 and k2 values according to an embodiment of the present application. Figure 5 As shown in Figure 2, by drawing the outer contour of the model on the orthophoto map, we can get Figure 5 At this point, the process of forming a relatively rough two-dimensional line drawing, which can also be called a preliminary elevation line drawing, by means of structural feature lines, texture feature lines, and outer contour lines is completed.
[0084] Step S103, rendering the two-dimensional line drawing to generate a final elevation line drawing of the target three-dimensional mesh model.
[0085] In other embodiments, after obtaining the two-dimensional line drawing of the target three-dimensional mesh model, the present application may also use non-realistic rendering technology to perform artistic processing on the two-dimensional line drawing.
[0086] For example, the present application may, but is not limited to, use an improved algorithm based on linear integral convolution to process the elevation line drawing of the target three-dimensional mesh model through pencil-style rendering of non-realistic rendering technology. The main process of the algorithm can be described as follows:
[0087] (1) Import the elevation line map, convert it into a grayscale image, extract the values with the largest grayscale change rate, and use these values as thresholds to divide the image into several different intervals.
[0088] (2) First, process the interval with the smallest grayscale and use the texture direction of this interval as the direction of the pencil stroke. Calculate the vector field of this interval and use the LIC algorithm combined with random white noise to render this area.
[0089] (3) Process other grayscale intervals, calculate different white noises based on the brightness data of the interval, and use the LIC algorithm to render the area according to the specified brush stroke direction.
[0090] After rendering all areas of the two-dimensional line graph, the final elevation line graph of the target three-dimensional network model can be obtained, such as Figure 6 As shown, it is a schematic diagram of the semi-automatically extracted facade line drawing of the ancient building model according to an embodiment of the present application.
[0091] The present application is described in detail below with reference to a specific embodiment.
[0092] Figure 7 This is a flow chart of a method for generating a line graph based on a three-dimensional grid model according to an embodiment of the present application. Figure 7 As shown:
[0093] Step S701: clustering the triangles in the three-dimensional grid model of the ancient building according to their directions using a direction-based clustering algorithm.
[0094] Step S702, after clustering all normal vectors in the three-dimensional mesh model of the ancient building, they are divided into different categories again according to whether they are connected to each other in space, and certain filtering conditions are set in this process. After classification again, the structural feature lines of the three-dimensional mesh model of the ancient building are extracted.
[0095] Step S703: based on the clustering result of the three-dimensional mesh model of the ancient building, the texture feature lines of the three-dimensional mesh model of the ancient building are extracted using an edge detection algorithm.
[0096] Step S704 , optimizing the extracted feature lines, including manually assisted correction and smoothing using B-spline curves, and orthographically projecting the optimized feature lines to form a two-dimensional line graph.
[0097] Step S705, artistically processing the two-dimensional line drawing using non-realistic rendering technology to obtain a final elevation line drawing of the three-dimensional grid model of the ancient building.
[0098] According to the line drawing generation method based on the three-dimensional grid model proposed in the embodiment of the present application, the structural feature lines and texture feature lines of the three-dimensional grid model can be extracted through an automated process and an improved algorithm, and then the structural feature lines, texture feature lines and outer contour lines are combined through optimization processing, orthographic projection and rendering processing to generate the final line drawing corresponding to the three-dimensional grid model. As a result, while ensuring the quality and consistency of the line drawing generated by the three-dimensional grid model, the efficiency of line drawing generation is effectively improved, and the scope of application is wide, and it can be actually applied to various fields such as ancient building protection, cultural relics digitization, three-dimensional printing and graphic design. As a result, the problems of the traditional three-dimensional grid model line drawing generation method in the related art being inefficient and difficult to ensure consistency, having high time cost and economic cost, and other three-dimensional grid model line drawing generation methods being limited in accuracy and difficult to meet the growing demand for automated line drawing generation are solved.
[0099] Next, a line graph generating device based on a three-dimensional grid model proposed in an embodiment of the present application is described with reference to the accompanying drawings.
[0100] Figure 8 It is a structural schematic diagram of a line graph generating device based on a three-dimensional grid model according to an embodiment of the present application.
[0101] like Figure 8 As shown, the line graph generating device 10 based on the three-dimensional grid model includes: an extraction module 100 , a processing module 200 and a generating module 300 .
[0102] The extraction module 100 is used to cluster the triangles in the target three-dimensional mesh model to obtain clustering results, and extract the structural feature lines and texture feature lines of the target three-dimensional mesh model based on the clustering results.
[0103] The processing module 200 is used to draw the structural feature lines and the texture feature lines on the target three-dimensional mesh model to obtain the model feature lines, and to optimize and orthographically project the model feature lines to generate a two-dimensional line drawing of the target three-dimensional mesh model.
[0104] The generation module 300 is used to render the two-dimensional line drawing to generate a final elevation line drawing of the target three-dimensional mesh model.
[0105] Optionally, in one embodiment of the present application, the extraction module 100 includes: a clustering unit and a classification unit.
[0106] Among them, the clustering unit is used to cluster the triangles in the target three-dimensional mesh model using the angle between the normal vectors of the triangles as a similarity measurement criterion and the normal vectors of the triangles as data units within the target angle value range to obtain an initial clustering result.
[0107] The classification unit is used to classify according to the connection relationship of the initial clustering results to obtain the clustering results.
[0108] Optionally, in one embodiment of the present application, the extraction module 100 includes: a first extraction unit and a second extraction unit.
[0109] Wherein, the first extraction unit is used to extract the boundary line of the clustering result based on the preset filtering condition.
[0110] The second extraction unit is used to draw the boundary line on the target three-dimensional grid model and extract the structural feature line of the target three-dimensional grid model.
[0111] Optionally, in one embodiment of the present application, the processing module 200 includes: an optimization unit and a processing unit.
[0112] The optimization unit is used to optimize the model characteristic line based on the local B-spline curve interpolation fitting algorithm to obtain a closed curve that meets the preset optimization conditions.
[0113] The processing unit is used to perform orthographic projection on the closed curve to obtain the contour line of the target three-dimensional mesh model; the generating unit is used to generate a two-dimensional line graph of the target three-dimensional mesh model based on the structural feature lines, texture feature lines and contour lines.
[0114] It should be noted that the aforementioned explanation of the embodiment of the line graph generation method based on the three-dimensional grid model is also applicable to the line graph generation device based on the three-dimensional grid model of this embodiment, and will not be repeated here.
[0115] According to the line drawing generation device based on the three-dimensional grid model proposed in the embodiment of the present application, the structural feature lines and texture feature lines of the three-dimensional grid model can be extracted through an automated process and an improved algorithm, and then the structural feature lines, texture feature lines and outer contour lines are combined through optimization processing, orthographic projection and rendering processing to generate the final line drawing corresponding to the three-dimensional grid model. As a result, while ensuring the quality and consistency of the line drawing generated by the three-dimensional grid model, the efficiency of line drawing generation is effectively improved, and the scope of application is wide, and it can be actually applied to various fields such as ancient building protection, cultural relics digitization, three-dimensional printing and graphic design. As a result, the problems of the traditional three-dimensional grid model line drawing generation method in the related art being inefficient and difficult to ensure consistency, having high time cost and economic cost, and other three-dimensional grid model line drawing generation methods being limited in accuracy and difficult to meet the growing demand for automated line drawing generation are solved.
[0116] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:
[0117] A memory 901 , a processor 902 , and a computer program stored in the memory 901 and executable on the processor 902 .
[0118] When the processor 902 executes the program, the line graph generation method based on the three-dimensional grid model provided in the above embodiment is implemented.
[0119] Furthermore, the electronic device further comprises:
[0120] The communication interface 903 is used for communication between the memory 901 and the processor 902 .
[0121] The memory 901 is used to store computer programs that can be executed on the processor 902 .
[0122] The memory 901 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0123] If the memory 901, the processor 902 and the communication interface 903 are implemented independently, the communication interface 903, the memory 901 and the processor 902 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0124] Optionally, in a specific implementation, if the memory 901, the processor 902 and the communication interface 903 are integrated on a chip, the memory 901, the processor 902 and the communication interface 903 can communicate with each other through an internal interface.
[0125] The processor 902 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0126] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned line graph generation method based on a three-dimensional grid model.
[0127] An embodiment of the present application also provides a computer program product, including a computer program, which can run computer instructions. When the computer instructions are executed by a processor, the line diagram generation method based on the three-dimensional grid model provided in the embodiment of the present application is implemented.
[0128] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0129] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0130] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0131] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or N wirings (electronic devices), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways as necessary and then storing it in a computer memory.
[0132] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented by hardware, as in another embodiment, it can be implemented by any one or a combination of multiple of the following technologies known in the art: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0133] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0134] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0135] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A line graph generation method based on a three-dimensional grid model, characterized in that: The following steps are involved: Clustering triangles in the target three-dimensional mesh model to obtain clustering results, and extracting structural feature lines and texture feature lines of the target three-dimensional mesh model based on the clustering results; Drawing the structural feature lines and the texture feature lines on the target three-dimensional mesh model to obtain model feature lines, and performing optimization processing and orthographic projection on the model feature lines to generate a two-dimensional line drawing of the target three-dimensional mesh model; The two-dimensional line drawing is rendered to generate a final elevation line drawing of the target three-dimensional mesh model.
2. The method according to claim 1, characterized in that The clustering of triangles in the target three-dimensional mesh model to obtain a clustering result includes: The angle between the normal vectors of the triangles is used as a similarity measurement criterion, and the normal vectors of the triangles are used as data units to cluster the triangles in the target three-dimensional mesh model within a target angle value range to obtain an initial clustering result; Classification is performed according to the connection relationship of the initial clustering results to obtain the clustering results.
3. The method according to claim 1, characterized in that The step of extracting structural feature lines and texture feature lines of the target three-dimensional mesh model based on the clustering result includes: Based on a preset filtering condition, extracting a boundary line of the clustering result; The boundary line is drawn on the target three-dimensional mesh model, and the structural feature line of the target three-dimensional mesh model is extracted.
4. The method according to claim 1, characterized in that: The step of optimizing and orthographically projecting the model feature lines to generate a two-dimensional line graph of the target three-dimensional mesh model includes: Based on a local B-spline curve interpolation fitting algorithm, the model characteristic line is optimized to obtain a closed curve that meets preset optimization conditions; Performing orthographic projection on the closed curve to obtain a contour line of the target three-dimensional mesh model; A two-dimensional line graph of the target three-dimensional mesh model is generated based on the structural feature lines, the texture feature lines and the contour lines.
5. A line graph generating device based on a three-dimensional grid model, characterized in that: include: An extraction module, used for clustering triangles in a target three-dimensional mesh model to obtain a clustering result, and extracting structural feature lines and texture feature lines of the target three-dimensional mesh model based on the clustering result; A processing module, used for drawing the structural feature lines and the texture feature lines on the target three-dimensional mesh model to obtain model feature lines, and performing optimization processing and orthographic projection on the model feature lines to generate a two-dimensional line drawing of the target three-dimensional mesh model; A generation module is used to render the two-dimensional line drawing to generate a final elevation line drawing of the target three-dimensional grid model.
6. The device according to claim 5, characterized in that The extraction module comprises: A clustering unit, for clustering triangles in a target three-dimensional mesh model using the angle between the normal vectors of the triangles as a similarity measurement criterion and using the normal vectors of the triangles as data units within a target angle value range to obtain an initial clustering result; The classification unit is used to classify according to the connection relationship of the initial clustering result to obtain the clustering result.
7. The device according to claim 5, characterized in that The extraction module comprises: A first extraction unit, configured to extract a boundary line of the clustering result based on a preset filtering condition; The second extraction unit is used to draw the boundary line on the target three-dimensional mesh model to extract the structural feature line of the target three-dimensional mesh model.
8. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the line graph generation method based on a three-dimensional grid model as described in any one of claims 1 to 4.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the line graph generation method based on a three-dimensional grid model as described in any one of claims 1 to 4.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed, it is used to implement the line graph generation method based on the three-dimensional grid model as described in any one of claims 1-4.
Citation Information
Patent Citations
Non-photorealistic rendering method for three-dimensional network model with stylized typical lines
CN101984467A
Three-dimensional automatic camera track smooth processing method
CN106846376A
A method and apparatus for texture mapping of a three-dimensional building model
CN109544672A
Lane line smoothing method and system
CN111192216A
Artificial intelligence three-dimensional modeling system and method based on cultural relic CT image
CN117351155A
