Inverse Nearest Neighbor Linear Discriminant Analysis Method and Device Based on Feature Spectrum Regularization
Through the inverse nearest neighbor linear discriminant analysis method of feature spectrum regularization, the problem of singularity of intra-class divergence matrix under small sample size is solved, and a higher recognition rate and better generalization performance is achieved, which is suitable for applications such as object and face recognition.
Patent Information
- Application Number
- CN202310180179.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-02-27
AI Technical Summary
In the case of small sample size, the intra-class divergence matrix in the linear discriminant analysis method is easy to be strange and it is difficult to find the optimal solution.
The inverse nearest neighbor linear discriminant analysis method based on feature spectrum regularization is adopted. By calculating the feature decomposition, regularization and weighting of the intraneous divergence matrix, the weighted feature vector is obtained, and the overall projection matrix is constructed for image classification.
It effectively avoids the singularity of the in-class divergence matrix, improves the generalization performance and recognition rate of the classifier, maintains the ability to solve multiple subclass problems, and has good timeliness.
Smart Images

Figure CN116168247B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular, to an inverse nearest neighbor linear discriminant analysis method and device based on feature spectrum regularization. Background Art
[0002] When using LDA to solve problems, when the number of training samples is very small and the dimension of a single sample is too high, it often causes the within-class scatter matrix to be non-invertible [1], that is, when the matrix is singular, it is difficult for LDA to obtain the optimal solution. This problem is also often referred to as the small sample size (SSS) problem [2]. In ccLDA [1], the within-class scatter matrix and the between-class scatter matrix are used to regularize the within-class scatter matrix and the between-class scatter matrix to solve the SSS problem, but this method is applicable to the case where there are only a small number of training samples.
[0003] [1] Yanwei Pang, Shuang Wang, and Yuan Yuan. Learning regularized lda by clustering. IEEE transactions on neural networks and learning systems, 25(12): 2191–2201, 2014.
[0004] [2] Xudong Jiang, Bappaditya Mandal, and Alex Kot. Eigenfeature regularization and extraction in face recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence, 30(3): 383–394, 2008. Summary of the Invention
[0005] The purpose of the present invention is to provide an inverse nearest neighbor linear discriminant analysis method and device based on feature spectrum regularization, aiming to solve the inverse nearest neighbor linear discriminant analysis method and device based on feature spectrum regularization.
[0006] The present invention provides an inverse nearest neighbor linear discriminant analysis method based on feature spectrum regularization, including:
[0007] S1. Obtain a classified training image set;
[0008] S2. Calculate the within-neighbor scatter matrix according to the training image set, and perform eigen-decomposition on the within-neighbor scatter matrix to obtain eigenvectors and eigenvalues;
[0009] S3. Regularize the eigenvalues of the within-class scatter matrix to form multiple weighting functions, select one of the multiple weighting functions to weight the eigenvectors to obtain weighted eigenvectors, and use the weighted eigenvectors to project the pixel values of each image in the training image set to obtain new image features;
[0010] S4. Calculate the total scatter matrix according to the features of the new training image set;
[0011] S5. Perform eigen-decomposition on the total scatter matrix to obtain the total eigenvectors and total eigenvalues, sort the total eigenvectors in descending order according to the corresponding total eigenvalues, and retain the first several eigenvectors to obtain the dimensionality reduction matrix;
[0012] S6. Construct the total projection matrix according to the weighted eigenvectors and the dimensionality reduction matrix, and project the training image set according to the total projection matrix to obtain the dimensionality-reduced image features;
[0013] S7. Input the image to be classified, project the image to be classified according to the total projection matrix to obtain the features of the image to be classified, measure the closest distance between the features of the image to be classified and the dimensionality-reduced image features, and obtain the category of the image to be classified according to the closest distance.
[0014] The present invention also provides an inverse nearest neighbor linear discriminant analysis device based on feature spectrum regularization, including:
[0015] An acquisition module, configured to acquire the classified training image set;
[0016] A calculation and decomposition module, configured to calculate the within-class scatter matrix according to the training image set, and perform eigen-decomposition on the within-class scatter matrix to obtain eigenvectors and eigenvalues;
[0017] A weighting module, configured to regularize the eigenvalues of the within-class scatter matrix to form multiple weighting functions, select one of the multiple weighting functions to weight the eigenvectors to obtain weighted eigenvectors, and use the weighted eigenvectors to project the pixel values of each image in the training image set to obtain new image features;
[0018] A calculation module, configured to calculate the total scatter matrix according to the features of the new training image set;
[0019] A dimensionality reduction module, configured to perform eigen-decomposition on the total scatter matrix to obtain the total eigenvectors and total eigenvalues, sort the total eigenvectors in descending order according to the corresponding total eigenvalues, and retain the first several eigenvectors to obtain the dimensionality reduction matrix;
[0020] A projection module, configured to construct the total projection matrix according to the weighted eigenvectors and the dimensionality reduction matrix, and project the training image set according to the total projection matrix to obtain the dimensionality-reduced image features;
[0021] A classification module, which is used to input an image to be classified, project the image to be classified according to the overall projection matrix to obtain the features of the image to be classified, measure the nearest distance between the features of the image to be classified and the features of the image after dimensionality reduction, and obtain the category of the image to be classified according to the nearest distance.
[0022] The calculation and decomposition module is specifically used for:
[0023] Calculate the within-class scatter matrix according to the training image set, and the formula is as follows:
[0024]
[0025] where p represents the number of classes, q i is the number of the i-th class, |RNN k (x ij ,X i )|≥t means that the number of inverse nearest neighbors of the image x ij belonging to the i-th class should be greater than or equal to t, x iv ∈RNN k (x ij ,X i ) refers to the inverse nearest neighbor of the image x iv belonging to the i-th class, and ij |RNN (x k ,X ij ,X i )| represents the number of inverse neighbors of the image x ij belonging to the i-th class;
[0026] Then perform eigen-decomposition on to obtain the eigenvectors and eigenvalues [λ1,λ2,…,λ r ,…,λ D , and the eigenvectors are arranged in descending order of eigenvalues. r is the rank of the within-class scatter matrix , and D is the dimension of the image.
[0027] The weighting module is specifically used for: regularize the eigenvalues of the within-class scatter matrix through the ERE, CDEFE, and DVPE models to form multiple weighting functions, select one of the multiple weighting functions to perform weighting processing on the eigenvectors to obtain weighted eigenvectors, and use the weighted eigenvectors to project the pixel values of each image in the training image set to obtain new image features.
[0028] The calculation module is specifically used for:
[0029] Calculate the overall scatter matrix according to the pixel values of the new training image set, and the formula is as follows:
[0030]
[0031] Among them, c i = 1 / p, represents the overall mean of the new set of image features.
[0032] An embodiment of the present invention also provides an inverse nearest neighbor linear discriminant analysis method based on feature spectrum regularization, including: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, the steps of the above method are implemented.
[0033] An embodiment of the present invention also provides a computer-readable storage medium. An implementation program for information transmission is stored on the computer-readable storage medium. When the program is executed by a processor, the steps of the above method are implemented.
[0034] By adopting the embodiment of the present invention, a feature spectrum regularization technology is added on the basis of the inverse nearest neighbor linear discriminant analysis (nLDA) method, thereby avoiding the problem that the within-class scatter matrix is singular due to too few training samples in ordinary linear discriminant analysis, and it is difficult to obtain the optimal projection matrix by using eigenvalue decomposition.
[0035] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it is implemented in accordance with the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following specifically describes the specific embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0037] Figure 1 is a flowchart of the inverse nearest neighbor linear discriminant analysis method based on feature spectrum regularization according to an embodiment of the present invention;
[0038] Figure 2 is a schematic diagram of the specific device of the inverse nearest neighbor linear discriminant analysis based on feature spectrum regularization according to an embodiment of the present invention;
[0039] Figure 3 is a schematic diagram of the inverse nearest neighbor linear discriminant analysis device based on feature spectrum regularization according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0040] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0041] Method Embodiment
[0042] According to an embodiment of the present invention, an inverse nearest neighbor linear discriminant analysis method based on feature spectrum regularization is provided. Figure 1 It is a flowchart of the inverse nearest neighbor linear discriminant analysis method based on feature spectrum regularization according to the embodiment of the present invention, as Figure 1 shown, and specifically includes:
[0043] Given a sample set X, where the jth sample x of the ith class ij ∈X, then the kth-order inverse nearest neighbor of the sample point x ij in the data set X is defined as:
[0044] RNN k (x ij , X) = {x iv ∣x iv ∈X\{x ij}, x ij ∈NN k (x iv , X)}
[0045] where NN k (x iv , X) is the kth-order nearest neighbor of the point x iv in the sample set X. It should be noted that the number of samples in the k-inverse nearest neighbor set can be greater than k, equal to k, or less than k. In some extreme cases, this set may be empty. For specific references, please refer to the relevant papers on inverse nearest neighbors. The number of this set is related to the sample position in the data distribution. The reason for using inverse nearest neighbors is that it is an unsupervised outlier detection method, which can eliminate the "outliers" in the training set.
[0046] An inverse nearest neighbor linear discriminant analysis method based on feature spectrum regularization, and the steps of using it to classify images are as follows:
[0047] Step 1: Given a training image set X, including p categories, and the number of images in the ith category is q i .
[0048] Step 2: Calculate the within-class scatter matrix:
[0049]
[0050] Among them, p represents the number of classes, and q i is the number of the i-th class. RNN k (x ij ,X i )≥t means that the number of inverse nearest neighbors of the image x ij belonging to class i is greater than or equal to t, and x iv ∈RNN k (x ij ,X i )
[0051] refers to the inverse nearest neighbor of the image x iv belonging to class i, and ij while
[0052] |RNN k (x ij ,X i )| represents the number of inverse neighbors of the image x ij belonging to class i.
[0053] Then, the eigenvectors obtained by performing eigen-decomposition on and the eigenvalues [λ1, λ2, …, λ r , …, λ D , the eigenvectors are arranged in descending order of eigenvalues. r is the rank of the within-class scatter matrix , and D is the dimension of the image.
[0054] Step 3: Select the feature spectrum regularization model to regularize the eigenvalues of the within-class scatter matrix : [λ1, λ2, …, λ r , …, λ D . The feature spectrum regularization model comes from the ERE, CDEFE, and DVPE algorithms respectively:
[0055] The weighting function of ERE is as follows:
[0056]
[0057] Among them, [λ1, λ2, …, λ m1 , …, λ r , …, λ D are the eigenvalues of the within-class scatter matrix , and
[0058] m1 is determined by
[0059] and the median function .
[0060] The weighting function of CDEFE is as follows:
[0061]
[0062] m2 is determined by and δ k = λ k / λ k+1 to obtain
[0063] In addition
[0064] The weighting function of DVPE is as follows:
[0065]
[0066] Select one of the above weighting functions to weight the feature vector Φ w to get g = m, g = r or g = mr.
[0067] Use to project the original image feature x ij ∈ X to calculate the new image feature
[0068] Step 4: Use y ij to calculate the total scatter matrix:
[0069]
[0070] where c i = 1 / p, represents the overall mean of all new image features y ij Then perform eigen-decomposition on this total scatter matrix to obtain eigenvectors, and then arrange these eigenvectors in descending order of eigenvalues to get W = [w1, w2,..., w D , and select the top d eigenvalues to obtain for subsequent dimensionality reduction.
[0071] Step 5: Use and to reconstruct the projection matrix Use this projection matrix to project the original training image x ij to obtain the image feature after dimensionality reduction For a newly incoming image x tes t to be classified, use to project to obtain Finally, the nearest neighbor classifier (1-NN) can be used to measure the image to be classified to find the training image with the closest distance, so as to determine which class it belongs to.
[0072] Through the above steps, the feature spectrum regularization inverse nearest neighbor linear discriminant analysis method (ERRLDA) proposed by the present invention can constitute three algorithms according to the regularization models used, namely: ERRLDA-m, ERRLDA-r, and ERRLDA-mr. Among them, ERRLDA-m adopts the weighted model in the ERE algorithm, ERRLDA-r adopts the feature spectrum weighted model in the CDEFE algorithm, and ERRLDA-mr adopts the weighted model in the DVPE algorithm.
[0073] The present invention adds a feature spectrum regularization technique to the inverse nearest neighbor linear discriminant analysis (nLDA) method, thereby avoiding the problem that the within-class scatter matrix is singular due to too few training samples in ordinary linear discriminant analysis, making it difficult to use eigenvalue decomposition to obtain the optimal projection matrix. At the same time, due to the regularization of the feature spectrum, the classifier can avoid overfitting and has better generalization performance. And it can also maintain the ability to solve multi-subclass problems.
[0074] The above effects are reflected in the application implementations such as object recognition and face recognition:
[0075] 1. The present invention has a higher recognition rate compared with the original nLDA method, and can basically maintain the stability of the recognition rate as the extracted feature dimension increases, reflecting the generalization ability of the special spectrum regularization.
[0076] 2. The three methods of ERRLDA-m, ERRLDA-r, and ERRLDA-mr of the present invention have better performance in dealing with multi-subclass problems compared with the original models ERE, CDEFE, and DVPE that do not construct the scatter matrix with inverse nearest neighbors.
[0077] 3. The ERRLDA algorithm proposed by the present invention has better timeliness compared with the original nLDA algorithm because it does not need to calculate the between-neighbor scatter matrix.
[0078] Device Embodiment
[0079] According to an embodiment of the present invention, an inverse nearest neighbor linear discriminant analysis device based on feature spectrum regularization is provided. Figure 2 It is a schematic diagram of the specific device of the inverse nearest neighbor linear discriminant analysis based on feature spectrum regularization according to an embodiment of the present invention, as Figure 2 shown, and specifically includes:
[0080] An acquisition module, configured to acquire a set of classified training images;
[0081] A calculation and decomposition module, which is used to calculate the within-neighborhood scatter matrix according to the training image set, and perform eigen-decomposition on the within-neighborhood scatter matrix to obtain eigenvectors and eigenvalues;
[0082] A weighting module, which is used to regularize the eigenvalues of the within-neighborhood scatter matrix to form multiple weighting functions, select one of the multiple weighting functions to perform weighting processing on the eigenvectors to obtain weighted eigenvectors, and use the weighted eigenvectors to project the pixel values of each image in the training image set to obtain new image features;
[0083] A calculation module, which is used to calculate the total scatter matrix according to the new training image set features;
[0084] A dimensionality reduction module, which is used to perform eigen-decomposition on the total scatter matrix to obtain total eigenvectors and total eigenvalues, sort the total eigenvectors in descending order according to the corresponding total eigenvalues, retain the first several eigenvectors to obtain a dimensionality reduction matrix;
[0085] A projection module, which is used to construct a total projection matrix according to the weighted eigenvectors and the dimensionality reduction matrix, and project the training image set according to the total projection matrix to obtain the dimensionality-reduced image features;
[0086] A classification module, which is used to input an image to be classified, project the image to be classified according to the total projection matrix to obtain the features of the image to be classified, measure the nearest distance between the features of the image to be classified and the dimensionality-reduced image features, and obtain the category of the image to be classified according to the nearest distance.
[0087] The calculation and decomposition module is specifically used for:
[0088] Calculate the within-neighborhood scatter matrix according to the training image set, and the formula is as follows:
[0089]
[0090] Among them, p represents the number of classes, q i is the number of the i-th class, |RNN k (x ij ,X i )|≥t means that the number of inverse nearest neighbors of the image x ij belonging to the i-th class should be greater than or equal to t, x iv ∈RNN k (x ij ,X i ) refers to the inverse nearest neighbor of the image x iv belonging to the i-th class of the image x ij and
[0091] |RNN k (x ij ,Xi )|represents the number of inverse neighbors of the image x belonging to class i ij ;
[0092] Then, for the eigenvector obtained by performing eigen - decomposition on and the eigenvalues [λ1, λ2, …, λ r , …, λ D , the eigenvectors are arranged in descending order of eigenvalues, r is the rank of the within - neighborhood scatter matrix , and D is the dimension of the image.
[0093] The weighted module is specifically used for: forming multiple weighted functions by regularizing the eigenvalues of the within - neighborhood scatter matrix through the ERE, CDEFE, and DVPE models, selecting one of the multiple weighted functions to perform weighted processing on the eigenvectors to obtain weighted eigenvectors, and using the weighted eigenvectors to project the pixel values of each image in the training image set to obtain new image features.
[0094] The calculation module is specifically used for:
[0095] Calculating the total scatter matrix according to the pixel values of the new training image set, and the formula is as follows:
[0096]
[0097] where c i = 1 / p, represents the overall mean of the new image feature set.
[0098] This embodiment of the present invention is a device embodiment corresponding to the above - mentioned method embodiment. The specific operations of each module can be understood by referring to the description of the method embodiment and will not be elaborated here.
[0099] Device Embodiment 1
[0100] This embodiment of the present invention provides an inverse - nearest - neighbor linear discriminant analysis device based on feature spectrum regularization, as shown in Figure 3 . It includes: a memory 30, a processor 32, and a computer program stored on the memory 30 and executable on the processor 32. When the computer program is executed by the processor, the steps in the above - mentioned method embodiment are implemented.
[0101] Device Embodiment 2
[0102] This embodiment of the present invention provides a computer - readable storage medium, on which
[0103] is stored an implementation program for information transmission. When the program is executed by the processor 32, the steps in the above - mentioned method embodiment are implemented.
[0104] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the technical solutions of the various embodiments of the present invention to deviate from the scope of the present solution.
Claims
1. An inverse nearest neighbor linear discriminant analysis method based on feature spectrum regularization, characterized in that including S1. Obtain a classified training image set; S2. Calculate the within-class scatter matrix based on the training image set, and perform eigen-decomposition on the within-class scatter matrix to obtain eigenvectors and eigenvalues; S3. Regularize the eigenvalues of the within-class scatter matrix to form multiple weighting functions, select one of the multiple weighting functions to perform weighting processing on the eigenvectors to obtain weighted eigenvectors, and use the weighted eigenvectors to project the pixel values of each image in the training image set to obtain the characteristics of the new training image set. Specifically, it includes: regularizing the eigenvalues of the within-class scatter matrix through the ERE, CDEFE, and DVPE models to form multiple weighting functions, selecting one of the multiple weighting functions to perform weighting processing on the eigenvectors to obtain weighted eigenvectors, and using the weighted eigenvectors to project the pixel values of each image in the training image set to obtain the characteristics of the new training image set; S4. Calculate the total scatter matrix based on the characteristics of the new training image set. Specifically, it includes: Calculate the total scatter matrix based on the characteristics of the new training image set. The formula is as follows: Among them, , , represents the overall mean of the new image set features, represents the number of classes, is the number of the -th class; S5. Perform eigen-decomposition on the total scatter matrix to obtain total eigenvectors and total eigenvalues, sort the total eigenvectors in descending order according to the corresponding total eigenvalues, retain the first several eigenvectors to obtain the dimensionality reduction matrix; S6. Construct the total projection matrix based on the weighted eigenvectors and the dimensionality reduction matrix, and project the training image set according to the total projection matrix to obtain the dimensionality-reduced image characteristics; S7. Input the image to be classified, project the image to be classified according to the total projection matrix to obtain the characteristics of the image to be classified, measure the closest distance between the characteristics of the image to be classified and the dimensionality-reduced image characteristics, and obtain the category of the image to be classified according to the closest distance.
2. The method according to claim 1, wherein The specific content of S2 includes: Calculate the within-class scatter matrix based on the training image set. The formula is as follows: Among them, represents the number of classes, is the number of the th class, refers to that the number of inverse nearest neighbors of the images belonging to this class should be greater than or equal to , means is the image belongs to the images of this class the inverse nearest neighbor, while , represents the number of inverse neighbors of the images belonging to this class ; Then, for the eigenvectors obtained by performing eigen - decomposition and eigenvalues , the eigenvectors are arranged in descending order of the eigenvalues, which is the dimension of the image.
3. An inverse nearest neighbor linear discriminant analysis device based on feature spectrum regularization, characterized in that, including An acquisition module for obtaining a classified training image set; A calculation and decomposition module for calculating the within-class scatter matrix based on the training image set, and performing eigen-decomposition on the within-class scatter matrix to obtain eigenvectors and eigenvalues; A weighting module for regularizing the eigenvalues of the within-class scatter matrix to form multiple weighting functions, selecting one of the multiple weighting functions to perform weighting processing on the eigenvectors to obtain weighted eigenvectors, and using the weighted eigenvectors to project the pixel values of each image in the training image set to obtain the characteristics of the new training image set. Specifically, it is used to: regularize the eigenvalues of the within-class scatter matrix through the ERE, CDEFE, and DVPE models to form multiple weighting functions, select one of the multiple weighting functions to perform weighting processing on the eigenvectors to obtain weighted eigenvectors, and use the weighted eigenvectors to project the pixel values of each image in the training image set to obtain the characteristics of the new training image set; A calculation module for calculating the total scatter matrix based on the characteristics of the new training image set. Specifically, it is used to: Calculate the total scatter matrix based on the characteristics of the new training image set. The formula is as follows: Among them, , , represents the overall mean of the new image set features, represents the number of classes, is the number of the th class; A dimensionality reduction module, which is used to perform eigen - decomposition on the overall divergence matrix to obtain the overall eigen - vectors and overall eigenvalues, arrange the overall eigen - vectors in descending order according to the corresponding overall eigenvalues, retain the first several eigen - vectors, and obtain a dimensionality reduction matrix; A projection module, which is used to construct an overall projection matrix according to the weighted eigen - vectors and the dimensionality reduction matrix, and project the training image set according to the overall projection matrix to obtain the dimensionality - reduced image features; A classification module, which is used to input an image to be classified, project the image to be classified according to the overall projection matrix to obtain the features of the image to be classified, measure the nearest distance between the features of the image to be classified and the dimensionality - reduced image features, and obtain the category of the image to be classified according to the nearest distance.
4. The device according to claim 3, characterized in that, The calculation and decomposition module is specifically used for: Calculating the within - neighborhood divergence matrix according to the training image set, and the formula is as follows: Among them, represents the number of classes, is the number of the th class, refers to that the number of inverse nearest neighbors of the images belonging to this class is greater than or equal to , means is the image belongs to the images of this class is the inverse nearest neighbor, while , represents the number of inverse neighbors of the images belonging to this class ; Then, for the eigenvectors obtained by performing eigen decomposition and the eigenvalues , the eigenvectors are arranged in descending order of the eigenvalues, which is the dimension of the image.
5. An electronic device, characterized in that, Including: A memory, a processor, and a computer program stored on the memory and executable on the processor, where when the computer program is executed by the processor, the steps of the inverse nearest - neighbor linear discriminant analysis method based on feature spectrum regularization as described in any one of claims 1 to 2 are implemented.
6. A computer-readable storage medium, characterized in that, An implementation program is stored on the computer - readable storage medium, and when the program is executed by the processor, the steps of the inverse nearest - neighbor linear discriminant analysis method based on feature spectrum regularization as described in any one of claims 1 to 2 are implemented.
Citation Information
Patent Citations
Face recognition method
CN102254166A
KR20210069655A