Cultural relic-oriented three-dimensional curved surface pattern flattening methodTechnical Field
The invention relates to the fields of computer graphics and computer vision, in particular to a method for flattening three-dimensional curved surface patterns of cultural relics.
Background
Cultural relics with different shapes and patterns are generated in each period, and the patterns on the cultural relics have important reference values for researching the current social aspects and folk culture, and have high values for artistic re-creation. In order to reflect the texture structure and artistic style of the curved pattern of the cultural relics, the pattern needs to be unfolded. The pattern is born on different cultural carriers, and as the surface of the cultural relics is formed by irregular curved surfaces, the pattern obtained by photographing deforms to a certain extent, so that the conventional pattern with more complete geometry and richer meaning is a very challenging problem.
The traditional cultural relics have the characteristics of various types and complex design, and are designed manually by hands instead of mechanically. The three-dimensional relic curved surface pattern is flattened, and the essence is that the pattern of the curved surface pattern is obtained under the condition of fidelity. The input data sources are three-dimensional models, the three-dimensional models are mainly composed of grids and textures, the grids are composed of a plurality of point clouds of an object, and the textures are color patterns mapped on the surface by establishing mapping relations between images and the grids.
The processing of three-dimensional curved surface grids is a difficult task due to the complex geometry of the cultural relics. For the problem of three-dimensional curved surface pattern flattening of cultural relics, core problems comprise grid model cutting, mapping of a grid model to a two-dimensional parameter domain, texture mapping, affine transformation of a grid and the like.
For the problems in the related art, no effective solution has been proposed at present.
Disclosure of Invention
Aiming at the problems in the related art, the invention provides a method for flattening a three-dimensional curved surface pattern of a cultural relic, which aims to solve the technical problems in the prior art.
For this purpose, the invention adopts the following specific technical scheme:
a method for flattening a three-dimensional curved surface pattern facing cultural relics, comprising the following steps:
s1, collecting sample points and performing iterative computation to obtain a symmetry axis;
S2, cutting the grid model by using a normal angle as a measurement standard;
s3, marking a texture region through texture sampling, subdividing the cut grid model, and parameterizing the three-dimensional grid into a two-dimensional plane domain by adopting a conformal mapping mode;
s4, converting textures corresponding to the three-dimensional model grids into mapped two-dimensional grids by adopting an affine transformation mode, and obtaining a complete texture sample flattening image.
Further, the step of collecting the sample points and performing iterative computation to obtain the symmetry axis in the step S1 further includes the following steps:
S11, firstly, acquiring part of sampling points in a preset grid model, and determining the critical domain of the sampling points by taking the Markov distance between the sampling points and the adjacent points as a judgment basis, wherein the Markov distance is smaller than a threshold value epsilon;
s12, continuously updating the cut plane at the sampling point in an iterative calculation mode, so that the cut plane can best simulate the rotational symmetry of the grid model to obtain the best cut plane;
S13, obtaining corresponding local rotation symmetry points through the minimum value of the square of the distance from the minimum sampling point to the normal vector of the optimal cutting plane, and then connecting all rotation symmetry points to obtain the rotation symmetry axis of the grid model.
Further, the step of cutting the grid model in S2 by using the normal angle as the measurement standard further includes the following steps:
S21, determining a section by using the gravity center and the symmetry axis of the triangular grid, and establishing a local coordinate system by using the intersection line of the gravity center of the triangular grid and the symmetry axis as a transverse axis and using the symmetry axis as a longitudinal axis;
S22, selecting two sides from three points in the anticlockwise direction in the triangular grid, solving normal vectors of the triangular grid through the two sides, orthogonally projecting the normal vectors to the cross section to obtain projection vectors, calculating to obtain angles of the projection vectors in a local coordinate system, and eliminating the triangular grid when the angles of the projection vectors in the local coordinate system are not within the specified input angle range, so as to obtain a grid model after cutting.
Further, in the step S3, the texture area is identified by texture sampling, the cut grid model is subdivided, and then the three-dimensional grid is parameterized into the two-dimensional plane area by adopting a conformal mapping mode, and the method further comprises the following steps:
s31, drawing vertical lines from the center of the triangular mesh to three sides, dividing the triangular mesh into three areas, respectively sampling textures, and then marking the triangular mesh by using whether the three areas are target textures;
S32, according to the equal angles of the triangular grids before and after mapping, bringing all angle values meeting the target texture area into the relation according to the proportional relation of the two sides, and determining a linear equation set, wherein the solution of the equation set is a two-dimensional triangular point set after mapping.
Further, in S11, the calculation formula using the mahalanobis distance between the sampling point and the neighboring point as the judgment basis is as follows:
d(pj,pi)≤∈
Where pj denotes a sampling point and pi denotes a mahalanobis distance.
Further, the calculation formula of the minimum value of the square of the distance from the minimum sampling point to the normal vector of the optimal cutting plane in the step S13 is as follows:
Where N (pj) represents the normal vector of point pj, R represents the distance of point pj to the optimal cutting plane, R represents the global coordinate space, and Ni represents the vertex i neighborhood coordinate space.
Further, the calculation formula for obtaining the projection vector proj in S22 is as follows:
Where u represents the vector to be projected and n represents the normal vector of the projection plane.
Further, the calculation formula of the angle of the projection vector in the local coordinate system obtained in S22 is as follows:
Where v1 represents the post-projection vector and v2 represents the positive direction of the horizontal axis of the local coordinate system.
Further, in S31, the triangular mesh is divided into three areas by using the triangular mesh center to draw a perpendicular line to three sides, and texture sampling is performed respectively, and then the labeling result of labeling the triangular mesh by using whether the three areas are target textures is as follows:
where i represents the ith triangle mesh.
Further, the calculation formula of affine transformation in S4 is as follows:
Wherein the four coefficients a, b, c and d of the affine transformation matrix represent rotation, scaling and cropping operations, tx and ty represent translation operations.
The method has the beneficial effects that through the specific algorithm flow, the whole process of flattening the three-dimensional curved surface pattern of the cultural relics is completed, and the pattern image result after flattening is obtained. For the three-dimensional curved surface flattening results of cultural relics with different configurations, the original morphological structure and the original proportional size are basically reserved, and the method has good universality. Therefore, for the configuration of the cultural relics with smoother curved surfaces, the three-dimensional curved surface pattern of the cultural relics can be flattened through the algorithm, and the method is irrelevant to the format, illumination, materials, resolution and the like of the three-dimensional curved surfaces.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a method for three-dimensional curved surface pattern flattening for cultural relics according to an embodiment of the invention.
Detailed Description
For the purpose of further illustrating the various embodiments, the present invention provides the accompanying drawings, which are a part of the disclosure of the present invention, and which are mainly used to illustrate the embodiments and, together with the description, serve to explain the principles of the embodiments, and with reference to these descriptions, one skilled in the art will recognize other possible implementations and advantages of the present invention, wherein elements are not drawn to scale, and like reference numerals are generally used to designate like elements.
According to the embodiment of the invention, a method for flattening a three-dimensional curved surface pattern facing cultural relics is provided.
The invention will be further described with reference to the accompanying drawings and detailed description, as shown in fig. 1, a method for flattening a three-dimensional curved pattern facing to cultural relics according to an embodiment of the invention, the method comprises the following steps:
s1, collecting sample points and performing iterative computation to obtain a symmetry axis;
S2, cutting the grid model by using a normal angle as a measurement standard;
s3, marking a texture region through texture sampling, subdividing the cut grid model, and parameterizing the three-dimensional grid into a two-dimensional plane domain by adopting a conformal mapping mode;
s4, converting textures corresponding to the three-dimensional model grids into mapped two-dimensional grids by adopting an affine transformation mode, and obtaining a complete texture sample flattening image.
In one embodiment, the step of collecting the sample points and performing iterative calculation to obtain the symmetry axis in S1 further includes the following steps:
S11, firstly, acquiring part of sampling points in a preset grid model, and determining the critical domain of the sampling points by taking the Markov distance between the sampling points and the adjacent points as a judgment basis, wherein the Markov distance is smaller than a threshold value epsilon;
s12, continuously updating the cut plane at the sampling point in an iterative calculation mode, so that the cut plane can best simulate the rotational symmetry of the grid model to obtain the best cut plane;
S13, obtaining corresponding local rotational symmetry points through the minimum value from the minimum sampling point to the square of the normal vector distance of the optimal cutting plane, and then connecting all the rotational symmetry points to obtain the rotational symmetry axis of the grid model;
The method is characterized in that a model with central symmetry is needed for a three-dimensional curved surface model of the cultural relic to be processed, the curved surface pattern of the cultural relic is clear, and the model is a data model with common formats such as obj.
In one embodiment, the cutting the grid model in S2 using the normal angle as a metric further includes the steps of:
S21, determining a section by using the gravity center and the symmetry axis of the triangular grid, and establishing a local coordinate system by using the intersection line of the gravity center of the triangular grid and the symmetry axis as a transverse axis and using the symmetry axis as a longitudinal axis;
S22, selecting two sides from three points in the anticlockwise direction in the triangular grid, solving normal vectors of the triangular grid through the two sides, orthogonally projecting the normal vectors to the cross section to obtain projection vectors, calculating to obtain angles of the projection vectors in a local coordinate system, and eliminating the triangular grid when the angles of the projection vectors in the local coordinate system are not within the specified input angle range, so as to obtain a grid model after cutting.
In one embodiment, the identifying the texture region by texture sampling and subdividing the cut grid model in S3, and then parameterizing the three-dimensional grid into the two-dimensional plane domain by adopting a conformal mapping manner further includes the following steps:
s31, drawing vertical lines from the center of the triangular mesh to three sides, dividing the triangular mesh into three areas, respectively sampling textures, and then marking the triangular mesh by using whether the three areas are target textures;
S32, according to the equal angles of the triangular grids before and after mapping, bringing all angle values meeting the target texture area into the relation according to the proportional relation between the two sides, and determining a linear equation set, wherein the solution of the equation set is a two-dimensional triangular point set after mapping;
Wherein the angles of the triangular meshes before and after mapping are equal, and the corresponding proportional relation between the two clamped sides is as follows:
uk-ui=rjikR(θjik)(uj-ui)
wherein u represents triangle vertex, i, j and k represent triangle vertex indexes respectively, R is the side length ratio of two sides of the included angle, R represents rotation transformation,Is a rotation matrix rotated by an angle θ on a plane.
In one embodiment, the calculation formula for determining that the mahalanobis distance between the sampling point and the neighboring point in S11 is smaller than the threshold e is as follows:
d(pj,pi)≤∈
Where pj denotes a sampling point and pi denotes a mahalanobis distance.
In one embodiment, the minimum value of the square of the distance from the minimum sampling point to the normal vector of the optimal cutting plane in S13 is calculated as follows:
Where N (pj) represents the normal vector of point pj, R represents the distance of point pj to the optimal cutting plane, R represents the global coordinate space, and Ni represents the vertex i neighborhood coordinate space.
In one embodiment, the calculation formula for obtaining the projection vector proj in S22 is as follows:
Where u represents the vector to be projected and n represents the normal vector of the projection plane.
In one embodiment, the calculation formula of the angle of the projection vector in the local coordinate system obtained in S22 is as follows:
Where v1 represents the post-projection vector and v2 represents the positive direction of the horizontal axis of the local coordinate system.
In one embodiment, in S31, the triangle mesh is divided into three areas by making a perpendicular line from the center of the triangle mesh to three sides, and texture sampling is performed respectively, and then the labeling result of identifying the triangle mesh by using whether the three areas are target textures is as follows:
where i represents the ith triangle mesh.
In one embodiment, the calculation formula of the affine transformation in S4 is as follows:
Wherein the four coefficients a, b, c and d of the affine transformation matrix represent rotation, scaling and cropping operations, tx and ty represent translation operations.
In summary, by means of the technical scheme of the invention, the invention completes the whole process of flattening the three-dimensional curved surface pattern of the cultural relics through the specific algorithm flow described above, and obtains the pattern image result after flattening. For the three-dimensional curved surface flattening results of cultural relics with different configurations, the original morphological structure and the original proportional size are basically reserved, and the method has good universality. Therefore, for the configuration of the cultural relics with smoother curved surfaces, the invention can realize the flattening of the three-dimensional curved surface pattern of the cultural relics by the algorithm, and is irrelevant to the format, illumination, material, resolution and the like of the three-dimensional curved surfaces
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.