A two-stage image classification method based on structured parsing dictionary learning
By simplifying the SADL algorithm and introducing the support vector machine classifier, the problems of high computational complexity and poor classifier performance in sparse parsing dictionary learning are solved, and the accuracy of image classification is improved and the computational efficiency is optimized.
Patent Information
- Application Number
- CN202210637417.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-07
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-06-07
AI Technical Summary
Existing sparse parsing dictionary learning algorithms have high computational complexity in image classification, linear classifiers are not ideal for improving the classification effect, and too many training parameters lead to large time and memory overhead, affecting classification accuracy.
A two-stage image classification method based on structural analytic dictionary learning is proposed. The original SADL algorithm is simplified, Frobenius norm is used instead of l1 norm, a new structural analytic dictionary learning model is established, and support vector machine learning is used in the second stage. The model replaces linear classifiers, shortens training time and improves classification accuracy.
It achieves accelerated training time in image classification, improves classification accuracy, and improves recognition accuracy. It is suitable for fields such as object recognition, face recognition, and scene recognition.
Smart Images

Figure CN114943862B
Abstract
Description
Technical field:
[0001] The present invention belongs to the field of computer vision, and in particular relates to a two-stage image classification method based on structured parsing dictionary learning. Background technology:
[0002] In recent years, sparse representation and dictionary learning have been widely used in computer vision and image processing. Due to the sparse characteristics of image signals, sparse representation and dictionary learning have achieved good results in image classification, image denoising, image compression, image restoration, and abnormal behavior detection.
[0003] Sparse representation refers to using an overcomplete dictionary to represent a signal as a sparse vector. The purpose of dictionary learning is to learn an adaptive dictionary from the signal of interest. The learned adaptive dictionary can represent the signal better than the predefined dictionary. This method was originally used for image denoising. Depending on the sparse representation model, dictionary learning can be divided into: dictionary learning based on sparse comprehensive models and dictionary learning based on sparse parsing models.
[0004] The successful application of dictionary learning in image denoising has triggered its application in the field of image classification. By adding label information to the training data, dictionary learning can train a discriminative dictionary. Discriminative dictionary learning can also be divided into two categories: discriminative dictionary learning based on sparse comprehensive models and discriminative dictionary learning based on sparse analytical models. The support vector-based dictionary learning (SVGDL) algorithm introduces the weighted sum of squared distances of coefficients into the sparse comprehensive model, which can achieve good classification results. However, the sparse comprehensive model encounters NP-hard problems when calculating the coding coefficients, and the computational complexity is relatively high. The encoding process of the sparse analytical model has a low computational complexity. Fisher discriminant dictionary learning (FDDL) learns a structured analytical dictionary and applies the Fisher criterion to the coding coefficients to enhance the recognition ability, but the recognition accuracy is not ideal. In order to improve the classification accuracy and shorten the optimization time, the structured analytical dictionary learning (SADL) algorithm introduces the structural mapping of the coding coefficients into the analytical model. However, the linear classifier used in the SADL algorithm does not improve the classification effect ideally, and there are too many training parameters in SADL, resulting in unnecessary time and memory overhead.
[0005] In view of the above problems, the present invention proposes a two-stage image classification method based on structural analytic dictionary learning. In the first stage, the SADL algorithm is simplified, and the constraint of minimizing the classification error under the linear classifier in the original model is omitted. In order to further reduce the computational cost, the Frobenius norm is used to replace the original l1 norm to constrain the representation coefficient. On this basis, a new structural analytic dictionary learning model is established. In the second stage, the training set is the structural sparse representation coefficient of the training sample on the analytic dictionary, and the support vector classifier is learned to replace the original linear classifier, thereby achieving the image classification task on the test set. Summary of the invention:
[0006] The problem solved by the present invention is: to overcome the deficiencies of the prior art and provide a two-stage image classification method based on structural analytical dictionary learning, which speeds up the training time and further improves the image classification accuracy on the basis of simplifying the original SADL algorithm.
[0007] The present invention discloses a two-stage image classification method based on structured parsing dictionary learning, comprising:
[0008] Step 1: Extract features from the original dataset and construct training set X and test set ;
[0009] Step 2: Phase 1, building a structural parsing dictionary learning model;
[0010] Step 3: Optimize and solve the structural parsing dictionary learning model on the training set to obtain the parsing dictionary Ω and the projection matrix Q;
[0011] Step 4: In phase 2, a support vector machine learning model is established. Based on the parsing dictionary Ω and the projection matrix Q adapted to the training set, the sparse representation coefficient ΩX of the training set is obtained. Based on the structural sparse representation coefficient on the training set, the support vector machine classifier is trained.
[0012] Step 5: Use the trained parsing dictionary Ω and projection matrix Q to obtain the structural sparse representation coefficients of the test set, which is used as the test set and classified using the support vector machine (SVM) classifier adapted to the training set.
[0013] In the above two-stage image classification method based on structural parsing dictionary learning, the original data set is feature extracted, and the training set X and the test set are constructed. ,include:
[0014] When extracting features from the original data set, you can use random features of the image or spatial pyramid features based on the scale-invariant feature transform (SIFT), both of which can achieve data dimensionality reduction; random features use random matrices to project the image into a vector of fixed dimension, and vectorize the generated feature vector into a unit vector of length 1; the SIFT-based spatial pyramid feature extraction method is as follows: dense SIFT descriptors are extracted on three grid sizes to calculate spatial pyramid matching features, with grid sizes of 1x1, 2x2, and 4x4, respectively, and then a vector quantization-based encoding method is used to extract intermediate layer features, and a standard maximum pooling method is used to construct high-dimensional pool features, and finally the data is reduced in dimensionality through principal component analysis.
[0015] The feature-processed data is divided into two parts, one as a training set and the other as a test set.
[0016] In the above two-stage image classification method based on structural parsing dictionary learning, stage 1, a structural parsing dictionary learning model is established, including:
[0017] Based on the SADL model, a new structural dictionary learning model is proposed. The Frobenius norm is used to replace the l1 norm regularization term, and the classification error term constraint based on the linear classifier is removed. The specific model is as follows:
[0018]
[0019] stH=QU+ε
[0020] In the formula, is the training set, is the parsing dictionary, represents the sparse representation matrix, represents the projection matrix, represents the structure matrix, ε is the tolerance for relaxing the structured constraints, λ1, λ2 and ρ are regularization parameters; the projection matrix Q projects the sparse representation matrix U onto the structure matrix H.
[0021] The structure matrix H is pre-defined based on the labels of the training set to ensure the consistency of the intra-class representation. Its definition is as follows:
[0022]
[0023] Among them, the i-th column vector of H represents the representation coefficient of the i-th sample with respect to its category (j-th category). H is a square matrix composed of block diagonal matrices. Each diagonal block in H is composed of a matrix of all 1s. The column vector predefined by the i-th sample The elements that are 1 in should be located in the jth diagonal block of the large matrix H, which means that each diagonal block matrix in H represents a subspace of each class. The diagonal block structure is to make the mapping representations between samples belonging to different classes different.
[0024] In the above two-stage image classification method based on structural parsing dictionary learning, the structural parsing dictionary learning model is optimized and solved on the training set to obtain the parsing dictionary Ω and the projection matrix Q, including:
[0025] The model is solved by alternating iteration method, the dual variable Z is introduced, and the variables U, Q, Ω, ε, and Z are updated in sequence. When updating any of the variables, other variables need to be fixed, and iterations ①-⑤ are repeated. When the maximum number of iterations is reached or the objective function value converges, the iteration is stopped to obtain the optimal result.
[0026] In order to facilitate the optimization solution, the original model is first rewritten using the augmented Lagrangian function, and the dual variable Z is introduced to convert the constrained optimization problem into an unconstrained optimization problem. The rewritten model is as follows:
[0027]
[0028] During the update process, in order to ensure the convergence of the algorithm, the parameter η about the learning rate is introduced U and η Q , where η U is the learning rate of the model modified by the Lagrangian function with respect to the variable U, η Q is the learning rate of the model with respect to the variable Q.
[0029] ①Fix Ω, Q, Z, ε, and update U:
[0030] When Ω, Q, Z, ε are fixed, and It is an irrelevant item in the optimization process and can be omitted. The gradient descent method is used to update U. The specific process is as follows:
[0031]
[0032] ②Fix U,Ω,Z,ε, and update Q:
[0033] When the variables U, Ω, Z, ε are fixed, and The irrelevant terms belonging to the variable Q can be omitted, and the simplified update process is as follows:
[0034]
[0035] ③Fix U, Q, Z, ε, and update Ω:
[0036] When the variables U, Q, Z, ε are fixed, the variables in the objective function that are not related to the update of Ω are omitted, and the process of updating Ω can be simplified to:
[0037]
[0038] By setting the gradient of the objective function with respect to Ω to zero, the analytical solution of Ω can be obtained, namely:
[0039] Ω t+1 =U t+1 X T (XX T +λ2I) -1
[0040] ④Fix U, Q, Z, Ω, and update ε:
[0041]
[0042] ⑤Fix U, Q, Ω, ε, and update Z:
[0043] Z t+1 =Z t +μ(HQ t+1 U t+1 )
[0044] In the above two-stage image classification method based on structural parsing dictionary learning, in stage 2, a support vector machine learning model is established, based on the parsing dictionary Ω and the projection matrix Q adapted to the training set, the sparse representation coefficient ΩX of the training set is obtained, and based on the structural sparse representation coefficient on the training set, the support vector machine classifier is trained, including:
[0045] Support vector machine classification is used instead of the linear classifier in SADL. The support vector machine model is trained using the projection of sparse representation coefficients on the training set. The specific model is as follows:
[0046]
[0047] Among them, QU=QΩX is the projection of the sparse representation coefficient ΩX on the training set on the projection matrix Q, c represents the number of categories, n represents the number of samples, D=[d1,d2,...,d k ,...,d c ] and b=[b1,b2,...,b k ,...,b c ] are the hyperplane and bias of the support vector machine, d k is the kth hyperplane in D, b k Represents the k-th class deviation, which is used to separate the projection of the coding coefficients belonging to the k-th class and the projection of the coding coefficients not belonging to the k-th class on the training set. θ>0 is a fixed parameter in the support vector machine. is the sample label of the k-th class of data, is the squared hinge loss function.
[0048] The squared hinge loss function is defined as follows:
[0049]
[0050] The squared hinge loss function is used to reflect the classification error. When , the squared hinge loss function is defined as when When , the square hinge loss function
[0051] After updating the variables U, Q, Ω, ε, and Z in stage 1, the structural sparse representation coefficient QΩX on the training set can be obtained.<D,b> The update of can be regarded as a type c one-to-many linear SVM classification, and the existing multivariate support vector machine algorithm is used to implement the support vector machine parameters<D,b> Updates.
[0052] In the above two-stage image classification method based on structural parsing dictionary learning, the trained parsing dictionary Ω and projection matrix Q are used to obtain the structural sparse representation coefficients of the test set, which is used as the test set and classified by a support vector machine (SVM) classifier adapted to the training set, including:
[0053] First, the training set X is used as the input of the structural parsing dictionary learning model to train the parsing dictionary Ω and projection matrix Q suitable for the training set; then the above parsing dictionary Ω, projection coefficient Q and training set X are used to train the support vector machine parameters<D,b> ; Finally, use the parsing dictionary Ω and projection coefficient Q on the training set to test the set Encode, the encoded structural sparse representation coefficient is Then Input into the trained support vector machine and calculate The jth element of the i-th column vector of matrix A represents the i-th test sample a i The confidence that a belongs to the jth class, a i The classification result is determined to belong to the category with the highest confidence.
[0054] The present invention has the following advantages:
[0055] A new model and method for image classification are proposed. The method is divided into two parts. In the first part, a parsing dictionary is learned so that the representation coefficients under the parsing dictionary can be projected into a structural subspace. In the second part, an SVM classifier is trained. Compared with the previous linear classifier, the SVM classifier can improve the classification accuracy. The classification method can be widely used in object recognition, face recognition, scene recognition, etc. Compared with previous algorithms, the dictionary learning method proposed in the present invention can achieve higher accuracy. Description of the drawings:
[0056] Figure 1 is a flow chart of the present invention; Specific implementation method:
[0057] Embodiment 1:
[0058] Reference Figure 1 This example conducts face recognition experiments based on the AR database. The AR dataset is a widely used face image dataset with 2,600 face images from 50 men and 50 women. The size of each image is 165×120. The dataset covers many aspects of facial changes, such as different lighting conditions, expressions, and facial disguises.
[0059] In step 1, random features of the image are used to extract features from the AR dataset. All images in the AR database are projected into 540-dimensional vectors using a random matrix, and then the feature vectors are converted into unit vectors with a length of 1. After feature extraction, each individual randomly selects 20 feature vectors as the training set X, and all the remaining feature vectors are used as the test set. The training set X is used as the input of the dictionary learning model to obtain the parsing dictionary Ω, projection matrix Q, and SVM classifier parameters suitable for the training set. The structure matrix H is defined to contain 5 column vectors per category, the sub-dictionary of the parsing dictionary Ω contains 5 dictionary atoms, and the total number of atoms in the parsing dictionary is 500. The parameters are set as follows: λ1=1e-4, λ2=1e-1, θ=0.5. The maximum number of iterations is set to 200. After training the model on the training set X, support vector machine (SVM) classification is used. In this example, the number of categories is 100.
[0060] In order to ensure the fairness of the comparative experiment, the method of the present invention and the existing classification method based on dictionary learning are experimented under the same experimental setting. The other classification methods involved in the comparison are FDDL, SVGDL, LC-KSVD, RBD-DPL, and SADL.
[0061] Table 1 Classification results of different methods on AR database
[0062] method Accuracy FDDL 96.9% SVGDL 94.6% LC-KSVD 97.8% RBD-DPL 97.6% SADL 97.2% Method of the present invention 98.0%
[0063] The algorithm achieved a recognition accuracy of 98.0% on the AR database, surpassing all other algorithms compared with it and improving the classification accuracy of the SADL algorithm by 0.8%.
[0064] Embodiment 2:
[0065] The scene classification experiment was conducted on the Scene15 dataset, which contains 4485 scene images from 15 natural scene categories, each category contains 200 images, and the size of each image is about 250×300 pixels. The scenes in this dataset include kitchen, suburbs, living room, etc.
[0066] In this embodiment, the operation steps are similar to those in Example 1. This example uses a spatial pyramid feature extraction method based on SIFT to extract image features. After the extraction is completed, the dimension of the features is reduced to 3000 dimensions through principal component analysis technology. When allocating training sets and test sets, the features of 100 images of each category are randomly selected as training sets, and the features of the remaining images are used as test sets. Input parameters λ1=1e-1, λ2=3e-4, θ=5, and set the maximum number of iterations to 200. The classification methods involved in the comparison are FDDL, SVGDL, LC-KSVD, RBD-DPL, and SADL.
[0067] Table 2 Classification results of different methods on Scene15 database
[0068]
[0069]
[0070] The method invented in this paper achieved an accuracy of 98.8% on the Scene15 dataset, which is higher than the accuracy of other algorithms and 0.3% higher than the accuracy of the SADL algorithm.
[0071] Embodiment 3:
[0072] Object classification experiments are conducted on the Caltech101 dataset, which contains 9144 images from 101 object categories, including animals, vehicles, flowers, etc. These images have large variations in object size, pose, position, and shape, making classification difficult.
[0073] The operation steps are similar to those of Example 1 and Example 2. This example uses a spatial pyramid feature extraction method based on SIFT to extract image features. After the extraction is completed, the dimension of the features is reduced to 3000 dimensions through principal component analysis technology. When allocating training sets and test sets, the features of 30 images of each category are randomly selected as training sets, and the features of the remaining images are used as test sets. Input parameters λ1=1e-3, λ2=3, θ=1, and set the maximum number of iterations to 200. The classification methods involved in the comparison are FDDL, SVGDL, LC-KSVD, RBD-DPL, and SADL.
[0074] Table 3 Classification results of different methods on Caltech101 database
[0075] method Accuracy FDDL 73.1% SVGDL 76.7% LC-KSVD 73.6% RBD-DPL 72.8% SADL 74.5% Method of the present invention 77.4%
[0076] As can be seen from the table, the method of the present invention achieves an accuracy rate of 77.4% on the Caltech101 dataset, which is higher than other algorithms compared with it. The recognition accuracy of the method of the present invention is improved by 2.9% over that of the SADL method.
Claims
1. A two-stage image classification method based on structured parsing dictionary learning, Features: Perform feature extraction on the original data set to construct training set X and test set Phase 1: Establish a structural parsing dictionary learning model; Optimize and solve the structural parsing dictionary learning model on the training set to obtain the parsing dictionary Ω and projection matrix Q; Phase 2: Establish a support vector machine learning model, obtain the sparse representation coefficient ΩX of the training set based on the parsing dictionary Ω and projection matrix Q adapted to the training set, and train the support vector machine classifier based on the structural sparse representation coefficient on the training set; Use the trained parsing dictionary Ω and projection matrix Q to obtain the structural sparse representation coefficients of the test set, and use this as the test set to classify it using the support vector machine (SVM) classifier adapted to the training set; The stage 1, building a structural parsing dictionary learning model, includes: Based on the SADL model, a new structural dictionary learning model is proposed, using the Frobenius norm to replace l 1 The norm regularization term removes the classification error term constraint based on the linear classifier; the specific model is as follows: In the formula, is the training set, is the parsing dictionary, represents the sparse representation matrix, represents the projection matrix, represents the structural matrix, ε is the tolerance of structural constraint relaxation, and λ 1 and λ 2 and ρ are regularization parameters; the projection matrix Q projects the sparse representation matrix U onto the structure matrix H. The structure matrix H is pre-defined based on the labels of the training set to ensure the consistency of the intra-class representation. Its definition is as follows: Among them, the i-th column vector of H represents the representation coefficient of the i-th sample with respect to the j-th category to which it belongs. H is a square matrix composed of block diagonal matrices. Each diagonal block in H is composed of a matrix of all 1s. The column vector predefined by the i-th sample The elements that are 1 in should be located in the jth diagonal block of the large matrix H, which means that each diagonal block matrix in H represents a subspace of each class. The diagonal block structure is to make the mapping representations between samples belonging to different classes different; The stage 2 is to establish a support vector machine learning model, obtain the sparse representation coefficient ΩX of the training set based on the parsing dictionary Ω and the projection matrix Q adapted to the training set, and train the support vector machine classifier based on the structural sparse representation coefficient on the training set, including: The support vector machine classifier is used to replace the linear classifier in SADL. The support vector machine model is trained using the projection of the sparse representation coefficients on the training set. The specific model is as follows: Among them, QU=QΩX is the structural sparse representation coefficient on the training set, c represents the number of categories, n represents the number of samples, D=[d 1 , d 2 , ..., d k , ..., d c ] and b=[b 1 , b 2 , ..., b k , ..., b c ] are the hyperplane and bias of the support vector machine, d k is the kth hyperplane in D, b k Represents the k-th class deviation, which is used to separate the projection of the coding coefficients belonging to the k-th class and the projection of the coding coefficients not belonging to the k-th class on the training set. θ>0 is a fixed parameter in the support vector machine. is the sample label of the k-th category data; is the squared hinge loss function, defined as follows: The squared hinge loss function is used to reflect the classification error. When , the squared hinge loss function is defined as when When , the square hinge loss function After updating the variables U, Q, Ω, Z, ε in stage 1, the structural sparse representation coefficient QΩX on the training set is obtained.<D,b> The update of is regarded as a one-to-many linear SVM classification of type c, and the existing multivariate support vector machine algorithm is used to implement the support vector machine parameters<D,b> Updates.
2. The two-stage image classification method based on structured parsing dictionary learning according to claim 1, Features The optimization and solution of the structural parsing dictionary learning model to obtain the parsing dictionary Ω and the projection matrix Q includes: When optimizing the solution, the alternating iteration method is used to solve the model. The dual variable Z is introduced, and the variables U, Q, Ω, ε, and Z are updated in sequence. When updating any of the variables, the other variables need to be fixed. Iterate ①-⑤ repeatedly. When the maximum number of iterations is reached or the objective function value converges, the iteration is stopped to obtain the optimal result: ①Fix Ω, Q, Z, ε, and update U; ②Fix U,Ω,Z,ε, and update Q; ③Fix U, Q, Z, ε, and update Ω; ④Fix U, Q, Z, Ω, and update ε; ⑤Fix U, Q, Ω, ε, and update Z; When the objective function value converges or the maximum number of iterations is reached, the iteration is stopped to obtain the optimal output result.
3. The two-stage image classification method based on structured parsing dictionary learning according to claim 1, Features The structured sparse representation coefficients of the test set are obtained by using the trained parsing dictionary Ω and the projection matrix Q, which are used as the test set and classified by a support vector machine (SVM) classifier adapted to the training set, including: Take the training set X as the input of the structural parsing dictionary learning model, train the parsing dictionary Ω and projection matrix Q suitable for the training set, and use the parsing dictionary Ω, projection matrix Q and training set X to train the support vector machine parameters<D,b> ; Use the parsing dictionary Ω and projection matrix Q on the training set to test the test set Encode, the encoded structural sparse representation coefficient is Will Input into the trained support vector machine and calculate The jth element of the i-th column vector of matrix A represents the i-th test sample a i The confidence that a belongs to the jth class, a i The classification result is determined to belong to the category with the highest confidence.
