A method, device and apparatus for image classification
By designing sub-dictionaries for each type of image and optimizing the discrimination fidelity items and enhanced discrimination items, the problem of reduced classification effect when there are fewer training samples is solved, and the accuracy and discriminability of image classification are improved.
Patent Information
- Application Number
- CN202211644751.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-20
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-12-20
AI Technical Summary
In the existing technology, because all training samples use the same sub-dictionary, when there are fewer training samples used to train each sub-dictionary, the classification effect will be significantly reduced.
By designing a sub-dictionary for each type of image, an optimization function is established with the goal of minimizing the sum of the discriminant fidelity term and the enhanced discriminant term. The alternating update method is used to solve the sub-dictionary and the representation coefficient matrix, thereby reducing the gap between any two types of data. Correlation, improve the representation ability and discriminability of the dictionary.
The accuracy of image classification is improved, so that each sub-dictionary has excellent ability to reconstruct training samples and strong discriminability, can effectively distinguish different categories, and can obtain higher classification accuracy even with fewer training samples. .
Smart Images

Figure CN116740403B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and in particular to a method, device and equipment for image classification. Background Art
[0002] Image classification is an image processing technology that distinguishes images of different categories based on the different features reflected in the image itself. Its core is to assign a label to an image from a given classification set.
[0003] In recent decades, various image classification algorithms have been proposed, among which the image classification algorithm based on dictionary learning is one of the classic classification algorithms. Dictionary learning was originally intended to find a set of original sparse signals from the original data. This set of sparse signals represents all the original signals as linearly as possible, and is widely used in image classification. When we learn a sufficiently good dictionary, we can calculate the sparse matrix of the test sample for the dictionary, and finally calculate the residual between the test sample and the sparse representation to determine which category the test sample belongs to. The K-SVD algorithm is a classic dictionary learning method. It continuously updates the dictionary atoms based on the current dictionary to better fit the data, but K-SVD does not consider the differences between different categories, so it is not suitable for classification tasks. To this end, Zhang et al. proposed the discriminant K-SVD algorithm, which incorporates the classification error into the objective function to expand the K-SVD algorithm, so that it considers the gap between categories and is suitable for classification tasks; but the D-KSVD algorithm only adds the classification error term on the basis of K-SVD, which makes its classification performance not very satisfactory. To this end, Jiang et al. introduced a new label consistency constraint (discriminant sparse code error) based on D-KSVD, which greatly improved the classification performance of the algorithm. The above algorithms are all committed to learning a shared dictionary to help classification. Yang et al. proposed a novel dictionary learning method - Fisher discriminant dictionary learning; although the algorithm learns a structured dictionary so that the dictionary atoms have a corresponding relationship with the class labels and can well use the reconstruction error of sparse coding for pattern classification, when the training samples used to train each sub-dictionary are small, the classification effect of Fisher discriminant dictionary learning will be significantly reduced.
[0004] From the above, it can be seen that how to ensure the accuracy of image classification is a problem that needs to be solved. Summary of the invention
[0005] Therefore, the technical problem to be solved by the present invention is to overcome the problem in the prior art that, because all training samples use the same sub-dictionary, when the number of training samples used to train each sub-dictionary is small, the classification effect will be significantly reduced.
[0006] In order to solve the above technical problems, the present invention provides an image classification method, which is characterized by comprising:
[0007] Preprocessing the acquired image dataset, wherein each sample in the image dataset has a corresponding category label, and integrating training samples of the same category into the same matrix;
[0008] Let the k-th sub-dictionary be D k ∈R m×r , k = 1, ..., C, r represents the number of dictionary atoms, wherein the dictionary D k is a block in dictionary D, D = [d1, d2, ... d (C×r) ], C×r represents the number of dictionary atoms; dictionary D k satisfy That is, sample y i It is represented linearly by all sub-dictionaries, where is the kth sub-dictionary pair y i The coefficient subvectors of ; these subvectors are combined on the columns to represent the coefficient vector x i ,
[0009] An optimization function is established with the goal of minimizing the sum of the discriminant fidelity term and the enhanced discriminant term, and an alternating update method is used to solve the sub-dictionary and representation coefficient matrix when the sum of the discriminant fidelity term and the enhanced discriminant term corresponding to the k-th label is minimized; wherein the discriminant fidelity term is the sum of the residual of the training sample represented by the entire dictionary, the residual of the training sample represented by the k-th sub-dictionary, and the sum of the representation contribution of the remaining sub-dictionaries, so that the learned dictionary can represent the sample to a certain extent; the enhanced discriminant term is the sum of the sum of the representation of the k-th dictionary and the representation of the remaining non-k-th sub-dictionaries, so as to reduce the correlation between any two types of data;
[0010] According to the obtained sub-dictionary and representation coefficient matrix, the optimal representation coefficient vector of the received sample to be predicted is solved, the residual of the sample to be predicted is obtained according to the optimal representation coefficient vector, and the corresponding label of the sample to be predicted is determined according to the residual.
[0011] In one embodiment of the present invention, the preprocessing of the acquired image data set includes:
[0012] Any image in the acquired image set can be stored in a two-dimensional matrix, and the vector formed by straightening the rows is used as a sample to form a corresponding image data set, that is, the acquired image data set is Among them, the i-th sample is the vector formed by the corresponding image being straightened, n is the number of samples in the image dataset, and m is the dimension of the vector; the category label corresponding to the sample in the image dataset is Among them, L i ∈{1,…,C}, C is the total number of categories;
[0013] After standardizing the image data set, we get the sample matrix Y = [y1, y2, ..., y n ]∈R m×n , and integrate all training samples of the kth class into Y k In the matrix, k=1,…,C.
[0014] In one embodiment of the present invention, establishing an optimization function with the goal of minimizing the sum of the discriminant fidelity term and the enhanced discriminant term includes:
[0015] In order to obtain C sub-dictionaries, an optimization function is established:
[0016] f (D,X) =argmin D,X {r(Y,D,X)+g(D,X)}
[0017] Where Y represents the training sample matrix, D represents the dictionary; X = [x1, x2, ..., x n ]∈R (C×r)×n is a representation coefficient matrix; wherein the discriminant fidelity term r(Y, D, X) is the sum of the residual of the training sample represented by the entire dictionary, the residual of the training sample represented by the k-th sub-dictionary, and the sum of the representation contribution of the remaining sub-dictionaries; the enhanced discriminant term g(D, X) is the sum of the sum of the representation of the k-th dictionary and the representation of the remaining non-k-th sub-dictionaries.
[0018] In one embodiment of the present invention, the formula for determining the fidelity term is as follows:
[0019]
[0020] Among them, ||Y k -DX k || 2 represents the residual when the entire dictionary is used to represent the training sample, Indicates that the residual of the training sample is represented by the k-th sub-dictionary, Y represents the contribution of the remaining sub-dictionaries; k Represents the matrix of all training samples of the kth class, D k represents the dictionary of the kth category, k = 1, ..., C, X k Represents the coefficient matrix corresponding to the k-th class sample matrix; Indicates the k-th type coefficient matrix and D k The corresponding part of the block matrix; D j represents the dictionary of the jth class, j = 1, ..., C and j ≠ k; Indicates the k-th type coefficient matrix and D j The corresponding part of the block matrix.
[0021] In one embodiment of the present invention, the formula of the reinforcement discriminant term is as follows:
[0022]
[0023] in, A dictionary representing different classes, represents the dictionary representation of the k-th category, Denotes the dictionary representation of the j-th class.
[0024] In one embodiment of the present invention, the sub-dictionary and representation coefficient matrix in which the sum of the discriminant fidelity term and the enhanced discriminant term corresponding to the kth label is minimized by using the alternating update method comprises:
[0025] To solve the sub-dictionary D with the minimum sum of the k-th discriminant fidelity term and the enhanced discriminant term k and represents the coefficient matrix X k , that is, when the partial derivative of the discriminant fidelity term and the enhanced discriminant term is set to 0, the obtained sub-dictionary D k and represents the coefficient matrix X k The value of; using the alternating update method, first fix the sub-dictionary D k , then solve for the coefficient matrix X k ; Solve the representation coefficient matrix X k After that, bring it into the solution sub-dictionary D k , after repeated iterations, we can get the sub-dictionary D that minimizes the expression and k and represents the coefficient matrix X k .
[0026] In one embodiment of the present invention, solving the optimal representation coefficient vector of the received sample to be predicted includes:
[0027] After receiving the sample y to be predicted, find the corresponding optimal representation coefficient vector. The calculation formula is as follows:
[0028]
[0029] in, represents the residual, in order to find the coefficient vector x that makes the dictionary representation closest to the sample, λ1 is the weight coefficient, ||x||1 represents the sparse term, in order to make x as sparse as possible; find the partial derivative of x for the calculation formula, then set the partial derivative expression equal to zero, and solve the value of x at this time, which is the optimal representation coefficient vector x * .
[0030] In one embodiment of the present invention, obtaining the residual of the sample to be predicted according to the optimal representation coefficient vector includes:
[0031] After obtaining the optimal representation coefficient vector x * After that, solve the residual representing sample y for the kth class, that is,
[0032]
[0033] in, It means calculating the residual of the k-th sub-dictionary when representing the test sample. represents the residual between the calculated coefficient vector and the mean vector of the k-th class coefficient vector; x *k Represents x * The kth block in m k is the mean vector of the sparse representation matrix corresponding to the k-th class of samples, and ω is the weight coefficient;
[0034] According to the minimum residual e j To determine the corresponding label j of the sample to be predicted,
[0035] e j =min{e1,e2,...,e C}.
[0036] In one embodiment of the present invention, a device for image classification is provided, comprising:
[0037] A data preprocessing module preprocesses the acquired image data set, wherein each sample in the image data set has a corresponding category label, and training samples of the same category are integrated into the same matrix;
[0038] Dictionary training module, let the k-th sub-dictionary be D k ∈R m×r , k = 1, ..., C, r represents the number of dictionary atoms, wherein the dictionary D k is a block in dictionary D, D = [d1, d2, ... d m ], m represents the number of dictionary atoms; dictionary D k satisfy That is, sample y i It is represented linearly by all sub-dictionaries, where is the kth sub-dictionary pair y i The coefficient subvectors of ; these subvectors are combined on the columns to represent the coefficient vector x i ,
[0039] An optimization function is established with the goal of minimizing the sum of the discriminant fidelity term and the enhanced discriminant term, and an alternating update method is used to solve the sub-dictionary and representation coefficient matrix when the sum of the discriminant fidelity term and the enhanced discriminant term corresponding to the k-th label is minimized; wherein the discriminant fidelity term is the sum of the residual of the training sample represented by the entire dictionary, the residual of the training sample represented by the k-th sub-dictionary, and the sum of the representation contribution of the remaining sub-dictionaries; the enhanced discriminant term is the sum of the sum of the representation of the k-th dictionary and the representation of the remaining non-k-th sub-dictionaries;
[0040] The residual classification module solves the optimal representation coefficient vector of the received sample to be predicted, obtains the residual of the sample to be predicted based on the optimal representation coefficient vector, and determines the corresponding label of the sample to be predicted based on the residual.
[0041] In one embodiment of the present invention, there is also provided an image classification device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any one of the image classification methods when executing the computer program.
[0042] The above technical solution of the present invention has the following advantages compared with the prior art:
[0043] The image classification method described in the present invention aims at the problem that in the prior art, all training samples use the same sub-dictionary. When the number of training samples for each sub-dictionary is small, the classification effect is poor. When establishing the optimization function, a sub-dictionary is designed for each type of image label, that is, a reinforced discriminant term is added on the basis of the prior art. By minimizing the sum of the discriminant fidelity term and the reinforced discriminant term, the learned dictionary can represent the sample to a certain extent, and at the same time reduce the correlation between any two types of data, so that the correlation between the dictionary representations of different classes is reduced, and the classification errors caused by the two types of dictionary representations being too close are reduced, so that each sub-dictionary has excellent training sample reconstruction ability and strong discriminability, can obtain and effectively distinguish different categories through fewer training samples, and greatly improves the accuracy of image classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein
[0045] Figure 1 A flowchart of a first specific embodiment of the image classification method provided by the present invention;
[0046] Figure 2 A structural block diagram of an image classification device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0048] Example 1
[0049] Reference Figure 1 As shown, a flowchart of a first specific embodiment of the image classification method provided by the present invention; the specific operation steps are as follows:
[0050] Step S101: Data preprocessing
[0051] The acquired image dataset is preprocessed, where each sample in the image dataset has a corresponding category label, and the training samples of the same category are integrated into the same matrix, that is,
[0052] The image dataset that has been acquired is Among them, the i-th sample is the vector formed by the corresponding image being straightened, n is the number of samples in the image dataset, and m is the dimension of the vector; the category label corresponding to the sample in the image dataset is Among them, L i ∈{1,…,C}, C is the total number of categories;
[0053] After standardizing the image data set, we get the sample matrix Y = [y1, y2, ..., y n ]∈R m×n , and integrate all training samples of the kth class into Y k In the matrix, k=1,…,C.
[0054] Step S102: Structured dictionary training
[0055] Let the k-th sub-dictionary be D k ∈R m×r , k = 1, ..., C, r represents the number of dictionary atoms, wherein the dictionary D k is a block in dictionary D, D = [d1, d2, ... d (C×r) ], C×r represents the number of dictionary atoms; assuming that sample y i It can be linearly represented by all sub-dictionaries, that is, dictionary D k satisfy in, is the kth sub-dictionary pair y i The coefficient subvectors of ; these subvectors are combined on the columns to represent the coefficient vector x i ,
[0056] In order to obtain C sub-dictionaries, an optimization function is established:
[0057] f (D,X) =argmin D,X {r(Y,D,X)+g(D,X)}
[0058] Where Y represents the training sample matrix, D represents the dictionary; X = [x1, x2, ..., x n ]∈R (C×r)×n is the coefficient matrix;
[0059] The formula for the first discriminant fidelity term r(Y,D,X) is:
[0060]
[0061] Among them, ||Y k -DX k || 2 represents the residual when the entire dictionary is used to represent the training sample, Indicates that the residual of the training sample is represented by the k-th sub-dictionary, Y represents the contribution of the remaining sub-dictionaries; k represents the matrix of all training samples of the kth class, D k represents the dictionary of the kth category, k = 1, ..., C, X k Represents the coefficient matrix corresponding to the k-th class sample matrix; Indicates the k-th type coefficient matrix and D k The corresponding part of the block matrix; D j represents the dictionary of the jth class, j = 1, ..., C and j ≠ k; Indicates the k-th type coefficient matrix and D j The corresponding part of the block matrix is used to make the learned dictionary represent the sample to a certain extent;
[0062] The formula of the second enhanced discriminant g(D,X) is as follows:
[0063]
[0064] in, A dictionary representing different classes, represents the dictionary representation of the k-th category, Represents the dictionary representation of the jth category; used to reduce the correlation between any two categories of data;
[0065] To solve the sub-dictionary D with the minimum sum of the k-th discriminant fidelity term and the enhanced discriminant term k and represents the coefficient matrix X k , that is, when the partial derivative of the discriminant fidelity term and the enhanced discriminant term is set to 0, the obtained sub-dictionary D k and represents the coefficient matrix X k The value of; using the alternating update method, first fix the sub-dictionary D k , then solve for the coefficient matrix X k ; Solve the representation coefficient matrix X k After that, bring it into the solution sub-dictionary D k , after repeated iterations, we can get the sub-dictionary D that minimizes the expression and k and represents the coefficient matrix X k .
[0066] Step S103: Solve the optimal representation coefficient vector of the received sample to be predicted, obtain the residual of the sample to be predicted according to the optimal representation coefficient vector, and determine the corresponding label of the sample to be predicted according to the residual, that is,
[0067] After receiving the sample y to be predicted, find the corresponding optimal representation coefficient vector. The calculation formula is as follows:
[0068]
[0069] in, represents the residual, in order to find the coefficient vector x that makes the dictionary representation closest to the sample, λ1 is the weight coefficient, ||x||1 represents the sparse term, in order to make x as sparse as possible; find the partial derivative of x for the calculation formula, then set the partial derivative expression equal to zero, and solve the value of x at this time, which is the optimal representation coefficient vector x * .
[0070] After obtaining the optimal representation coefficient vector x * After that, solve the residual representing sample y for the kth class, that is,
[0071]
[0072] in, It means calculating the residual of the k-th sub-dictionary when representing the test sample. represents the residual between the calculated coefficient vector and the mean vector of the k-th class coefficient vector; x *k Represents x * The kth block in m kis the mean vector of the sparse representation matrix corresponding to the k-th class of samples, and ω is the weight coefficient;
[0073] According to the residual error obtained above, the corresponding label of the sample to be predicted is determined; if e j The minimum residual we found is e j =min{e1,e2,...,e C}, then the label of the test sample is j.
[0074] Example 2
[0075] Based on the above embodiments, the present embodiment is tested on the ORL face dataset, which was created by the Olivetti Laboratory in Cambridge, England between April 1992 and April 1994, and contains 400 images of 40 different people, 10 images per person, and these images are collected at different times, under different lighting conditions, and in different facial expression environments.
[0076] Based on the above embodiments, in this example, assuming that the image is composed of 64*64 pixels, any image can be stored in a two-dimensional matrix with a matrix size of 64*64. There are 4096 pixels in total. Straightening the rows is to store the matrix column by column to form a 4096*1-dimensional column vector, then m=4096; n=400, C=40.
[0077] The present invention conducts experiments on the ORL dataset, randomly divides the dataset 50 times, and generates three datasets; the first dataset is called 8Train, and 8 face images of each person are taken as training samples and 2 face images are taken as test samples each time; the second dataset is called 6Train, and 6 face images of each person are taken as training samples and 4 face images are taken as test samples each time; the third dataset is called 4Train, and 4 face images of each person are taken as training samples and 6 face images are taken as test samples each time; then the average value of the experimental results of 50 divisions of each dataset is taken as the result. The classification accuracy of the present invention on the ORL dataset is compared with the classification accuracy of other algorithms on the ORL dataset, and the specific results are shown in Table 1.
[0078] Table 1. Classification accuracy of different classification models for ORL dataset
[0079] KSV DKSV FDDL LCKSVD The present invention 8Train 0.9419 0.7272 0.8290 0.9402 0.9652 6Train 0.9255 0.5673 0.8052 0.9224 0.9528 4Train 0.8814 0.5558 0.7816 0.8776 0.9190
[0080] Therefore, when establishing the optimization function, the present invention considers designing a sub-dictionary for each type of image label, that is, adding an enhanced discriminant term on the basis of the prior art, and by minimizing the sum of the discriminant fidelity term and the enhanced discriminant term, the learned dictionary can represent the sample to a certain extent, and at the same time reduce the correlation between any two types of data, so that the correlation between the dictionary representations of different classes is reduced, and the classification errors caused by the two types of dictionary representations being too close are reduced, so that each sub-dictionary has excellent reconstruction training sample capabilities and strong discriminability, and can obtain and effectively distinguish different categories through fewer training samples, greatly improving the accuracy of image classification; It can be seen from Table 1 that compared with other algorithms through three different data sets, the present invention has a higher accuracy rate in classification performance and can better classify images.
[0081] Example 3
[0082] Please refer to Figure 2 , Figure 2 A structural block diagram of an image classification device provided by an embodiment of the present invention; the specific device may include:
[0083] A data preprocessing module preprocesses the acquired image data set, wherein each sample in the image data set has a corresponding category label, and training samples of the same category are integrated into the same matrix;
[0084] Dictionary training module, let the k-th sub-dictionary be D k ∈R m×r , k = 1, ..., C, r represents the number of dictionary atoms, wherein the dictionary D k is a block in dictionary D, D = [d1, d2, ... d (C×r) ], C×r represents the number of dictionary atoms; dictionary D k satisfy That is, sample y i It is represented linearly by all sub-dictionaries, where is the kth sub-dictionary pair y i The coefficient subvectors of ; these subvectors are combined on the columns to represent the coefficient vector x i ,
[0085] An optimization function is established with the goal of minimizing the sum of the discriminant fidelity term and the enhanced discriminant term, and an alternating update method is used to solve the sub-dictionary and representation coefficient matrix when the sum of the discriminant fidelity term and the enhanced discriminant term corresponding to the k-th label is minimized; wherein the discriminant fidelity term is the sum of the residual of the training sample represented by the entire dictionary, the residual of the training sample represented by the k-th sub-dictionary, and the sum of the representation contribution of the remaining sub-dictionaries; the enhanced discriminant term is the sum of the sum of the representation of the k-th dictionary and the representation of the remaining non-k-th sub-dictionaries;
[0086] The residual classification module solves the optimal representation coefficient vector of the received sample to be predicted, obtains the residual of the sample to be predicted based on the optimal representation coefficient vector, and determines the corresponding label of the sample to be predicted based on the residual.
[0087] The device of this embodiment is used to implement the aforementioned image classification method. Therefore, the specific implementation method of the radar echo signal analysis device can be seen in the embodiment part of the image classification method in the previous text. For example, the data preprocessing module 100, the dictionary training module 200, and the residual classification module 300 are respectively used to implement steps S101, S102, and S103 in the above-mentioned radar echo signal feature selection method. Therefore, its specific implementation method can refer to the description of the corresponding various parts of the embodiment, which will not be repeated here.
[0088] Example 4
[0089] A specific embodiment of the present invention further provides an image classification device, comprising: a memory for storing a computer program; and a processor for implementing the steps of the above-mentioned image classification method when executing the computer program.
[0090] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0091] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0092] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0093] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0094] Obviously, the above embodiments are merely examples for clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived from these are still within the protection scope of the invention.
Claims
1. A method for image classification, It is characterized in that include: Preprocessing the acquired image dataset, wherein each sample in the image dataset has a corresponding category label, and integrating training samples of the same category into the same matrix; Let the k-th sub-dictionary be D k ∈R m×r , k = 1, ..., C, m represents the dimension of the vector, C represents the total number of categories, r represents the number of sub-dictionary atoms, wherein the sub-dictionary D k is a block in dictionary D, D = [d 1 ,d 2 ,…d (C×r) ], C×r represents the number of dictionary atoms; sub-dictionary D k satisfy That is, sample y i It is represented linearly by all sub-dictionaries, where is the kth sub-dictionary pair y i The coefficient subvectors of ; these subvectors are combined on the columns to represent the coefficient vector x i , The optimization function is established with the goal of minimizing the sum of the discriminant fidelity term and the enhanced discriminant term, and the alternating update method is used to solve the sub-dictionary and representation coefficient matrix corresponding to the k-th label when the sum of the discriminant fidelity term and the enhanced discriminant term is minimized, including: when the partial derivative of the sum of the discriminant fidelity term and the enhanced discriminant term is taken and set to 0, the obtained sub-dictionary D k and represents the coefficient matrix X k The value of; using the alternating update method, first fix the sub-dictionary D k , then solve for the coefficient matrix X k ; Solve the representation coefficient matrix X k After that, bring it into the solution sub-dictionary D k , after repeated iterations, we can get the sub-dictionary D that minimizes the expression and k and represents the coefficient matrix X k ; The discriminant fidelity term is the sum of the residual of the training sample represented by the entire dictionary, the residual of the training sample represented by the k-th sub-dictionary, and the sum of the representation contribution of the remaining sub-dictionaries; the enhanced discriminant term is the sum of the sum of the representation of the k-th dictionary and the representation of the remaining non-k-th sub-dictionaries; Solving the optimal representation coefficient vector of the received sample to be predicted according to the obtained sub-dictionary and the representation coefficient matrix, obtaining the residual of the sample to be predicted according to the optimal representation coefficient vector, and determining the corresponding label of the sample to be predicted according to the residual, including: After receiving the sample y to be predicted, find the corresponding optimal representation coefficient vector. The calculation formula is as follows: in, Represents the residual, in order to find the coefficient vector x that makes the dictionary representation closest to the sample, λ 1 is the weight coefficient, ||x|| 1 represents the sparse term; find the partial derivative of x for the calculation formula, then set the partial derivative expression equal to zero, and solve the value of x at this time, which is the optimal representation coefficient vector x * ; After obtaining the optimal representation coefficient vector x * After that, solve the residual representing sample y for the kth class, that is, in, It means calculating the residual of the k-th sub-dictionary when representing the test sample. represents the residual between the calculated coefficient vector and the mean vector of the k-th class coefficient vector; Represents x * The kth block in m , k is the mean vector of the sparse representation matrix corresponding to the k-th class of samples, and ω is the weight coefficient; According to the minimum residual e j To determine the corresponding label j of the sample to be predicted, where e j =min{e 1 ,e 2 ,...,e C }.
2. The method for image classification according to claim 1, It is characterized in that The preprocessing of the acquired image data set includes: Any image in the acquired image set can be stored in a two-dimensional matrix, and the vector formed by straightening the rows is used as a sample to form a corresponding image data set, that is, the acquired image data set is Among them, the i-th sample is the vector formed by the corresponding image being straightened, n is the number of samples in the image dataset, and m is the dimension of the vector; the category label corresponding to the sample in the image dataset is Among them, L i ∈{1,…,C}, C is the total number of categories; After standardizing the image data set, we get the sample matrix Y = [y 1 ,y 2 ,…,y n ]∈R m×n , and integrate all training samples of the kth class into Y k In the matrix, k=1,…,C.
3. The method for image classification according to claim 1, It is characterized in that The optimization function established with the goal of minimizing the sum of the discriminant fidelity term and the enhanced discriminant term includes: In order to obtain C sub-dictionaries, an optimization function is established: f (D,X) =argmin D,X {r(Y,D,X)+g(D,X)} Where Y represents the training sample matrix, D represents the dictionary; X = [x 1 ,x 2 ,…,x n ]∈R (C×r)×n is a representation coefficient matrix; wherein the discriminant fidelity term r(Y, D, X) is the sum of the residual of the training sample represented by the entire dictionary, the residual of the training sample represented by the k-th sub-dictionary, and the sum of the representation contribution of the remaining sub-dictionaries; the enhanced discriminant term g(D, X) is the sum of the sum of the representation of the k-th dictionary and the representation of the remaining non-k-th sub-dictionaries.
4. The method for image classification according to claim 3, It is characterized in that The formula for the discriminant fidelity term is as follows: Among them, ||Y k -DX k || 2 represents the residual when the entire dictionary is used to represent the training sample, Indicates that the residual of the training sample is represented by the k-th sub-dictionary, Y represents the contribution of the remaining sub-dictionaries; k Represents the matrix of all training samples of the kth class, D k represents the dictionary of the kth category, k = 1, ..., C, X k Represents the coefficient matrix corresponding to the k-th class sample matrix; Indicates the k-th type coefficient matrix and D k The corresponding part of the block matrix; D j represents the dictionary of the jth class, j = 1, ..., C and j ≠ k; Indicates the k-th type coefficient matrix and D j The corresponding part of the block matrix.
5. The method for image classification according to claim 3, It is characterized in that The formula of the reinforcement discriminant is as follows: in, A dictionary representing different classes, represents the dictionary representation of the k-th category, Denotes the dictionary representation of the j-th class.
6. An image classification device, It is characterized in that include: A data preprocessing module preprocesses the acquired image data set, wherein each sample in the image data set has a corresponding category label, and training samples of the same category are integrated into the same matrix; Dictionary training module, let the k-th sub-dictionary be D k ∈R m×r , k = 1, ..., C, m represents the dimension of the vector, C represents the total number of categories, r represents the number of sub-dictionary atoms, wherein the sub-dictionary D k is a block in dictionary D, D = [d 1 ,d 2 ,…d (C×r) ], C×r represents the number of dictionary atoms; sub-dictionary D k satisfy That is, sample y i It is represented linearly by all sub-dictionaries, where is the kth sub-dictionary pair y i The coefficient subvectors of ; these subvectors are combined on the columns to represent the coefficient vector x i , The optimization function is established with the goal of minimizing the sum of the discriminant fidelity term and the enhanced discriminant term, and the alternating update method is used to solve the sub-dictionary and representation coefficient matrix corresponding to the k-th label when the sum of the discriminant fidelity term and the enhanced discriminant term is minimized, including: when the partial derivative of the sum of the discriminant fidelity term and the enhanced discriminant term is taken and set to 0, the obtained sub-dictionary D k and represents the coefficient matrix X k The value of; using the alternating update method, first fix the sub-dictionary D k , then solve for the coefficient matrix X k ; Solve the representation coefficient matrix X k After that, bring it into the solution sub-dictionary D k , after repeated iterations, we can get the sub-dictionary D that minimizes the expression and k and represents the coefficient matrix X k ; The discriminant fidelity term is the sum of the residual of the training sample represented by the entire dictionary, the residual of the training sample represented by the k-th sub-dictionary, and the sum of the representation contribution of the remaining sub-dictionaries; the enhanced discriminant term is the sum of the sum of the representation of the k-th dictionary and the representation of the remaining non-k-th sub-dictionaries; The residual classification module solves the optimal representation coefficient vector of the received sample to be predicted according to the obtained sub-dictionary and the representation coefficient matrix, obtains the residual of the sample to be predicted according to the optimal representation coefficient vector, and determines the corresponding label of the sample to be predicted according to the residual, including: After receiving the sample y to be predicted, find the corresponding optimal representation coefficient vector. The calculation formula is as follows: in, Represents the residual, in order to find the coefficient vector x that makes the dictionary representation closest to the sample, λ 1 is the weight coefficient, ||x|| 1 represents the sparse term; find the partial derivative of x for the calculation formula, then set the partial derivative expression equal to zero, and solve the value of x at this time, which is the optimal representation coefficient vector x * ; After obtaining the optimal representation coefficient vector x * After that, solve the residual representing sample y for the kth class, that is, in, It means calculating the residual of the k-th sub-dictionary when representing the test sample. represents the residual between the calculated coefficient vector and the mean vector of the k-th class coefficient vector; Represents x * The kth block in m , k is the mean vector of the sparse representation matrix corresponding to the k-th class of samples, and ω is the weight coefficient; According to the minimum residual e j To determine the corresponding label j of the sample to be predicted, where e j =min{e 1 ,e 2 ,...,e C }.
7. A device for image classification, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the method for image classification as claimed in any one of claims 1 to 5 when executing the computer program.
