Detailed Description
The specific implementation steps are described in detail below with reference to the accompanying drawings.
As shown in FIG. 1, the present invention implements a general flow chart for automatic classification of three-dimensional models, which contains the major steps required to achieve the final classification. Firstly, a three-dimensional grid model is given, geodesic line distances of any two vertexes of the three-dimensional model are calculated, then dimension reduction and feature decomposition are carried out on a geodesic line distance matrix to obtain global features of the three-dimensional grid model, the features are classified by using a support vector machine to build a binary classifier, the binary classifier is combined pairwise to form a multi-element classifier by using the support vector machine binary classifier, and classification results can be obtained by using the multi-element classifier. In the testing stage, the obtained global features of the three-dimensional grid model can be input into a binary classifier and a multivariate classifier of the support vector machine for testing. Therefore, the invention can realize automatic classification of the three-dimensional model.
The specific implementation steps are described in detail below with reference to the accompanying drawings.
Firstly, the geodesic distance of any two vertexes of the three-dimensional model is calculated.
The invention assumes that the three-dimensional model to be classified is represented by polygonal meshes, and each mesh is composed of vertexes, edges and polygons according to topological relation. The invention obtains the global characteristic of each grid through the distance of the characteristic peak, and utilizes the global characteristic to train a classifier to classify the newly input distance characteristic. However, the present invention does not directly use the euclidean distance of the vertices for characterization, because the euclidean distance cannot cope with the non-rigid deformation of the three-dimensional mesh, however, many three-dimensional models have flexible transformation such as certain bending, and therefore, the euclidean distance will have poor robustness to the non-rigid transformation, and directly affect the final classification result, so that the classification accuracy of the classifier is poor. Therefore, the invention adopts the geodesic distance of the vertex to obtain the global characteristic of the three-dimensional shape, the geodesic distance can not change along with the bending of a part of the three-dimensional shape, and the distance is not changed for non-rigid transformation.
The geodesic distance of any two vertexes on the three-dimensional grid is actually a shortest path from the starting point to the end point by dynamic planning. Any two adjacent vertexes, namely vi and vj, exist on the path of the starting point and the end point, and the shortest path of the starting point and the end point can be expressed into an optimization problem by a formula:
according to the invention, the geodesic distance between any two points of the three-dimensional grid is calculated by solving the optimization problem. The method comprises the following steps:
let the starting vertex be v0The terminating vertex is vn. Each vertex v on the path from the starting point to the end pointiRecording the geodesic distance d to the starting pointiWherein d isie.R is from the starting vertex v0To an arbitrary vertex viLength of the shortest path of (2). v. ofi-1Is v isiAnd connecting adjacent three-dimensional grid vertexes, wherein the distance of the adjacent three-dimensional grid vertexes is measured by Euclidean distance. The expression of the optimization problem is as follows:
d0=0
di=min(di-1+||vi-1-vi||)
the invention adopts a dynamic planning method and an iterative planning mode to ensure that the path of each step is shortest, and a final result is dynamically planned. The dynamic planning process is implemented using width searches, i.e., each search traverses the k-neighbors of the three-dimensional mesh vertices. The invention adopts the adjacent storage list of the vertex, the edge and the polygon to realize the three-dimensional mesh topological structure, and establishes the adjacent list of the vertex, the adjacent list of the edge and the adjacent list of the polygon in the three-dimensional mesh reading process. Therefore, the traversal of k-neighbors only needs the time complexity of O (1), and the traversal speed can be ensured to be fast enough, so that the dynamic programming speed is increased. In addition, in order to further increase the planning speed so as to deal with the large-scale three-dimensional mesh, the invention adds two constraint conditions in the dynamic planning process, namely the vertices of the three-dimensional mesh meeting the constraint conditions are traversed preferentially.
The first constraint is
(vi-vs)·(vt-vs)>0
The constraint essentially stipulates the planning direction (v) for each dynamic planningi-vs) And the starting point to the end point direction (v)t-vs) And (5) the consistency is achieved. The direction is a preferential planning direction, once the terminal point is reached, the planning can be stopped, the speed of dynamic planning can be greatly increased by increasing the constraint condition, and the calculation speed of the geodesic distance between any two points is ensured to be highAnd (4) accelerating.
The second constraint is
d(vi,vs)≥||vt-vs||2
This constraint ensures that, during traversal, the geodesic distance d (v) of the two verticesi,vs) Must be greater than the European distance v of starting and ending pointt-vs||2. Because the Euclidean distance between the two points is the shortest distance of the space and is certainly less than or equal to the geodesic distance between the two points, whether the terminal point is reached is not required to be judged when the Euclidean distance is not reached in the planning process, and the time can be saved.
The steps of the invention can quickly calculate the geodesic distance of any two points.
And secondly, dimension reduction and characteristic decomposition of the geodesic distance matrix.
And (2) calculating the geodesic distance of any two vertexes of the three-dimensional grid through the step 1), thereby forming a high-dimensional matrix D, wherein the indexes of rows and columns correspond to the indexes of the vertexes of the three-dimensional grid, and each matrix element represents the geodesic distance of any two vertexes of the three-dimensional grid. Because the eigenvalues of the geodesic distance matrix represent the global characteristics of the three-dimensional grid, the invention considers the characteristic decomposition of the geodesic distance matrix. However, a large-scale three-dimensional mesh shape with a number of vertices of N1M or more will form a high-dimensional matrix of N1M, which requires O (N) for feature decomposition3) The computational complexity of (2) cannot be realized at all in a reasonable time. Therefore, the invention researches a dimension reduction method of high-dimensional geodesic distance, and aims to sample few representative vertexes from large-scale vertexes of a three-dimensional shape, and a low-dimensional matrix formed by the vertex geodesic distances is approximately equal to the characteristic decomposition of a high-dimensional matrix formed by all vertexes, so that the calculation pressure of characteristic decomposition of the high-dimensional matrix is avoided, and the training speed and the operation classification speed of the invention are greatly increased. As shown in FIG. 2, the dimension reduction methodThe method comprises the following steps:
1) the mathematical expectation of all geodesic distances is calculated, where d (i, j) is the geodesic distance of the two vertex indices i and j.
dm=E[d(i,j)]
2) The dimension reduction matrix is set to L and is initially null. First, a pair of vertex indexes (x) with the largest geodesic distance is selected1,x2) Adding to an empty dimension reduction matrix L, wherein the dimension reduction matrix is changed into:
3) and traversing the grid vertex list according to the original matrix index sequence, and adding the vertex index x meeting the following two conditions and the corresponding distance of the selected vertex in the dimension reduction matrix into the matrix L.
a) The vertex x to all vertex indices x of the matrix LjGeodesic distance ofThe distance being greater than the mathematical desired value dm:
b) The vertex x to all vertices x of the matrix LjThe sum of the geodesic distances of (a):
4) repeating the step 3) until any one of the following stop conditions is met:
a) the number of vertices of the matrix exceeds a set value k. In this patent, k is set to 64;
b) no three-dimensional mesh vertices have satisfied the conditions set in step 3).
After the dimension reduction step described above, the dimension of the original matrix D is reduced to the value k, and the eigen decomposition is easily performed in a short time. However, after matrix dimensionality reduction, we further gauss the geodesic distances, which aims to reduce the influence of longer geodesic distances on feature decomposition and enhance the robustness of the classification method. The method comprises the following steps:
wherein is dijTwo points of geodesic distance, σ is the Gaussian width, d'ijIs the gaussian geodesic distance. In this patent, we define the Gaussian width σ as
σ=max(i,j){dij}
I.e. the maximum value of the geodesic distances between all vertices. Defining σ as such a data-dependent form makes the final eigen-decomposition result invariant to uniform scaling, which the present invention defines to be aimed at normalizing geodesic distances. The present invention can be seen from a number of observations of the experimental results that the final eigen decomposition is relatively stable with respect to σ as long as σ is sufficiently large.
After the dimensionality reduction and the gauss of the geodesic distance matrix are carried out, the characteristic decomposition is carried out on the matrix D, and the characteristic value of the matrix D is calculated. The characteristic decomposition formula is as follows:
Dv=λv
the method adopts a general Jacobi method to carry out characteristic decomposition, and orders characteristic values from large to small.
The invention uses the vector formed by the characteristic values
Dimension reduction is performed again by a cutoff (cutoff) method, and a characteristic value smaller than the set value c is cut off and discarded. In this patent, it was experimentally observed that c is 16. Reduced vector
The classifier is trained by calculating the input features of each sample as the input features of the classifier, and in the same way, in the actual operation, the input features are extracted firstly and then input into the trained classifier to classify the classifier.
And thirdly, constructing a binary classifier of the three-dimensional model features by using a support vector machine.
The present invention resolves a multi-classification problem into a multiple binary classifier combinatorial problem. There is a certain correspondence between the multi-classification problem and the binary classification problem. If one question is that multiple classes can be separated, any two classes in the multiple classes can be separated certainly; on the contrary, in a multi-classification problem, if any two groups of the multi-classification problem are known to be separable, multiple types of classification can be finally realized through two groups of the multi-classification problem through a certain combination rule. Different combination rules form different classification algorithms, which combination rules will be elaborated in step 4). The invention provides a method for binary classification of the three-dimensional model features extracted in the step 2) by adopting a support vector machine. The classification process based on the support vector machine is shown in figure 3, the characteristics of a group of three-dimensional grid models are extracted as classification samples through step 2) and are divided into a training set and a test set, the support vector machine is trained, a kernel function is selected, the normal coefficient of a classification surface is selected through an optimization mode, the offset parameter of the classification surface is determined through the support vector set to determine the classification surface, a binary classifier is formed, then the binary classifier is combined into a multi-element classifier, and classification results can be output for the training set and the test set. The binary classifier based on the 0 support vector machine is implemented as follows.
Suppose for a feature sample set (x) composed of three-dimensional mesh modelsi,yi) Wherein i ∈ [1, n ]]Feature xi∈RMAnd is located in an M-dimensional feature space. y isiE { +1, -1} is a category label. From this feature sample set, the classification surface equation can be obtained as:
H(x)=ωTx+b=0
where ω is the vector of the M-dimensional feature space, which is the normal coefficient of the classification plane, and b is the scalar, which is the offset parameter of the classification plane. The position of the classification plane can be determined using ω and b. The constructed classification surface needs to separate the two types of samples obviously, namely, when y is satisfiediWhen 1, H (x)i) When y is equal to 1, the same holds trueiWhen is-1, H (x)i)=-1。
As shown in fig. 4, the classification interval is maximized under the condition that the two types of samples are correctly separated based on the principle of minimizing the structural risk. The classification surface is located in the middle of two boundary lines, and the points of the boundary lines are determined by the support vectors. When the support vector is obtained, no other samples are needed, and the sample processing time can be reduced. According to the knowledge of geometry, the distance between two boundary lines is 2/| omega | | torry2The method adopted by the method is to obtain the maximum distance by using an optimization method, namely, the maximum distance is minimizedIn the invention, interference factors are considered, a relaxation variable xi and a penalty coefficient C are introduced, the problem of determining a classification surface can be converted into the solution of the following optimal problem, and two constraint conditions are introduced:
yi(ωTxi+b)≥1-ξi
ξi≥0
under the above constraint, calculating function
Is measured. This constrained optimization problem can be solved by constructing Lagrange functions as follows:
the Lagrange function is solved for its minimum value, which must be found at the saddle point, for ω and b. Therefore, the saddle point satisfies the following condition:
αi(yi(ωTxi+b)-1+ξi)=0
βiξi=0
αi≥0,βi≥0,ξi≥0
solving to obtain:
αi+βi=C
substituting into Lagrange function yields:
wherein the coefficient alphaiSatisfy the requirement of
αi≥0
Therefore, the following classification discriminant function is established by using the optimal classification surface parameters:
wherein,
where U denotes the number of elements that support the vector set.
The invention judges the category of the binary classification of the sample x according to the symbol of the value of H (x) in the formula.
The invention adopts a nonlinear method to try to carry out binary classification on the three-dimensional grid characteristics, and utilizes nonlinear vectors to map the three-dimensional grid characteristics to a high-dimensional characteristic space so as to enable the three-dimensional grid characteristics to be linearly separable. Defining a non-linear vector
The vector maps the m-dimensional input features x to k-dimensional feature space, making the classification data linearly separable in the high-dimensional feature space. The corresponding classification discriminant function is:
we consider introducing a kernel function K (x)iX) solving the computational complexity and over-learning problems caused by the high-dimensional computation in the above equation. If only a proper kernel function meeting the Mercer condition is found in the input space, the kernel function can be used for replacing the inner product operation of the high-dimensional feature space, and the constructed discriminant function of the optimal classification surface is as follows:
the invention tries three common kernel functions, including a linear kernel function, a gaussian radial basis kernel function and a Sigmoid kernel function. Wherein the linear kernel function expression is as follows
K(xi·xj)=xi·xj
The gaussian radial basis function is expressed as follows:
where σ is the variance of the sample.
The expression of the Sigmoid kernel is as follows:
K(xi·xj)=tanh{gxi·xj-h}
it constitutes a multi-layer perceptron neural network, where the parameter g is a scaling factor and h is an offset factor.
Experiments show that the kernel function of the Gaussian radial basis gives better classification performance, so that the Gaussian radial basis function is adopted as the kernel function of the support vector machine.
Fourthly, combining the binary classifiers into a multivariate classifier
As the three-dimensional shape classification problem is mainly focused on multi-classification, the invention adopts the binary classifier constructed in the step 3) to combine into a multi-element classifier. Generally, the multi-classification methods mainly include: one-to-one, one-to-many, and directed acyclic graphs. One-to-one classification method is a better multi-classification method, is suitable for practical application, has higher calculation efficiency, and leads the two types of samples to tend to be balanced, thus leading the classification judgment to be more reasonable. The present invention uses a one-to-one classification method. For the K classification problem, the K training samples are combined pairwise, L ═ K (K-1)/2 training sets can be constructed, and each pair of training sets is learned by using a support vector machine binary classifier respectively, so that L binary classifiers are generated. The "voting method" is adopted in the classification of test samples: and inputting the test sample into L binary classifiers constructed by K types of samples, and adding a ticket to the type if the output result of the sample x is judged to be the type. After the L binary classifiers classify the test samples, which class of the K classes has the most ticket, and then the class to which the test samples belong is judged. Thus, the invention realizes an automatic classification method of three-dimensional models.
The effects of the present invention can be further illustrated by the following experiments. The experimental data set is from McGilluniversity Shape Benchmark, Canada, and the three-dimensional model data set contains 10 types of general shapes including animals, human, machinery and the like, and the specific categories are shown in Table 1. The present invention separates the data set into a training set and a test set. The training set contains 10 classes of shapes, 10 models per class, for a total of 100 models. The test set contains 10 types of shapes, 10 models per type, for a total of 100 models. And training on a training set to obtain a multi-element classifier, and evaluating the classification result of the multi-element classifier on a test set. During training, 10 types of shapes in the training set are respectively assigned with respective class labels, and any two types of sample values are taken for training and learning, so that a multi-element classifier consisting of 45 binary classifiers can be obtained. When in test, 10 types of sample values are input into the multi-element classifier in sequence to obtain all classification results. And counting the classification results, wherein the statistical results are shown in table 1, and the error rate and the accuracy rate respectively refer to the percentage of the number of the three-dimensional models with the wrong classification and the correct classification to the total number of the classification models.
TABLE 1 Classification accuracy of the present invention on a three-dimensional model test set
The classification result shows that the classification precision of the three-dimensional model automatic classification method provided by the invention reaches 86%, and the three-dimensional model automatic classification method has certain superiority in the existing three-dimensional model classification method, has good classification performance, and has stronger robustness for complex general models and non-rigid transformation. While the foregoing is directed to the preferred embodiment of the present invention, several modifications may be made by one skilled in the art without departing from the principles of the invention, including changes in the kernel function of the support vector machine, etc., the scope of which is defined in the appended claims and their equivalents.