An image classification method

By using the balanced K-means method with variable anchor points and similarity self-learning in image classification, the label matrix is ​​directly solved, which solves the problem of high computational complexity of the spectral clustering algorithm and achieves high efficiency on large-scale data. Image classification.

CN114821181BActive Publication Date: 2024-10-01NORTHWESTERN POLYTECHNICAL UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202210493913.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-28
Publication Date
2024-10-01
Estimated Expiration
2042-04-28

AI Technical Summary

Technical Problem

Existing spectral clustering algorithms have high computational complexity in image classification, and cannot directly obtain the category indicator matrix, making it difficult to calculate and expand on large-scale data.

Method used

The balanced K-means method with a variable number of anchor points is used to generate representative anchor points. The correlation matrix between data points and anchor points is constructed through similarity self-learning. The coordinate ascending method is used to directly solve the label matrix and reduce the calculation of the nearest neighbor graph. quantize and speed up the image classification process.

Benefits of technology

The computational complexity of image classification is reduced, making the method suitable for large-scale data, increasing the calculation speed and improving the clustering accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114821181B_ABST
    Figure CN114821181B_ABST
Patent Text Reader

Abstract

The present invention relates to an image classification method. First, feature extraction is performed on original image data to obtain feature data of the original image, and a K-Means algorithm is used to generate representative anchor points in the feature data; secondly, a correlation matrix between anchor points and data points is established by a method based on probabilistic nearest neighbors, and a similarity matrix between data points is obtained; finally, a coordinate ascent method is used to obtain a discrete category indicator matrix according to the correspondence between a nearest neighbor graph and a category indicator matrix. The present invention constructs a nearest neighbor graph between sample points by selecting representative anchor points and constructing a two-step graph between anchor points and sample points, thereby reducing the amount of calculation for mining the nearest neighbor relationship between images. The coordinate ascent method is used to directly solve the label matrix in the clustering algorithm to directly obtain the image classification result, thereby accelerating the calculation speed of image classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of image classification and machine learning, and specifically relates to an image classification method. Background Art

[0002] Clustering algorithm is one of the important research topics in the field of machine learning and has been widely used in pattern recognition, data analysis, image processing and other fields. In image classification, the image data is firstly extracted for features. Common image features include color features, shape features, texture features, edge features and features obtained through neural networks. With the development of acquisition equipment, more and more data are collected, making data labeling difficult and costly. Clustering algorithm reveals the intrinsic properties and laws of data by learning unlabeled data and divides the data into different clusters, making the same type as similar as possible and the different types as different as possible. Taking advantage of the fact that no labels are required, clustering algorithm is widely used in image classification. Spectral clustering is a typical clustering algorithm, which mainly includes two steps. First, a neighbor graph is established according to the distance between data, and the Laplace matrix based on the neighbor graph is decomposed by eigenvalue to obtain a low-dimensional indicator matrix. Since the low-dimensional indicator matrix may contain negative values ​​and cannot represent the sample category, it is necessary to perform K-Means clustering or spectral rotation on the low-dimensional indicator matrix again to obtain the final discrete category indicator matrix. However, the computational complexity is high when performing feature decomposition, and performing K-Means clustering on the low-dimensional indicator matrix again may also affect the true category of the sample points and increase the computational complexity, making it difficult to calculate and expand on large-scale data.

[0003] In response to the above two problems, Ni Zhongyuan and Liu Jinglei (Ni Zhongyuan, Liu Jinglei. Fast spectral clustering based on graph filtering [J / OL]. Journal of Shanxi University (Natural Science Edition): 1-14 [2022-01-22]. DOI: 10.13451 / j.sxu.ns.2021058.) proposed a fast spectral clustering algorithm based on graph filtering. This algorithm overcomes the difficulty of eigendecomposition of the Laplacian matrix by generating pseudo-eigenvectors, and reduces the data size by sampling, speeding up the subsequent K-Means clustering calculation process. Although the time complexity of spectral clustering is improved and the error is reduced by the optimization process, it still maintains the main calculation process of spectral clustering, but only optimizes the relevant steps, and the sampling method is used to reduce the data size, which may cause the original structure of the data to change. Summary of the invention

[0004] Technical issues to be solved

[0005] In view of the fact that the eigenvalue decomposition in the current spectral clustering algorithm has too much computational complexity and cannot directly obtain the category indicator matrix and cannot be better applied in image classification, the present invention provides an image classification method that can solve the problem of high computational complexity when the existing unsupervised learning method is applied to image classification tasks.

[0006] Technical Solution

[0007] An image classification method, characterized by the following steps:

[0008] S1: input classification image;

[0009] S2: Extract image features and obtain feature data Among them, x i is the i-th data point, d is the dimension of the feature, and n is the number of image data points;

[0010] S3: Select m anchor points using the balanced K-means method with a variable number of anchor points to obtain the anchor point set U;

[0011] S4: construct a similarity matrix A between data points based on anchor points;

[0012] S5: Build a model based on the similarity matrix A and label relationship;

[0013] S6: Use the coordinate ascent method to solve the model, obtain the label of the feature data, and complete the image classification.

[0014] A further technical solution of the present invention: S4 is divided into the following two steps:

[0015] S41: constructing a correlation matrix B between data points and anchor points using a similarity self-learning method;

[0016] S42: Calculate the sample neighbor graph A and the similarity matrix A according to the correlation matrix B.

[0017] A further technical solution of the present invention is to construct a correlation matrix between data points and anchor points using a similarity self-learning method as follows:

[0018] The correlation matrix B between the data point X and the anchor point U is obtained through the similarity self-learning method. is the correlation matrix between sample points and anchor points; for the i-th sample point, the model is as follows:

[0019]

[0020] Among them, b ij is the i-th row and j-th column element in B, is the i-th row in B, and γ is the regularization coefficient. is the Euclidean distance between the i-th sample point and the j-th anchor point, is a vector whose jth element is k ij , then the above optimization problem can be written in the following vector form

[0021]

[0022] Assumption b i There are l (l≤m) non-zero elements in k i Rearrange and assume The corresponding b i for but The expression is

[0023]

[0024] A further technical solution of the present invention is: the sample neighbor graph A and the similarity matrix A are calculated based on the correlation matrix B as follows:

[0025] After obtaining B, the similarity between sample points is constructed by the similarity between sample points and anchor points

[0026] A=BΔ -1 B T

[0027] in, is a diagonal matrix, and the calculation of its i-th element is

[0028] make at this time

[0029] A computer system, characterized in that it comprises: one or more processors, and a computer-readable storage medium for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned method.

[0030] A computer-readable storage medium, characterized in that it stores computer-executable instructions, which are used to implement the above method when executed.

[0031] A computer program, characterized by comprising computer executable instructions, which are used to implement the above method when executed.

[0032] Beneficial Effects

[0033] The present invention proposes an image classification method. First, feature extraction is performed on original image data to obtain feature data of the original image, and a balanced K-means method with a variable number of anchor points is used to generate representative anchor points in the feature data; secondly, a correlation matrix between anchor points and data points is established by a probabilistic nearest neighbor method, and a similarity matrix between data points is obtained; finally, a coordinate ascent method is used to obtain a discrete category indicator matrix according to the correspondence between a nearest neighbor graph and a category indicator matrix.

[0034] Compared with the prior art, the present invention has the following beneficial effects:

[0035] (1) By selecting representative anchor points and constructing a two-step graph between anchor points and sample points, a neighbor graph between sample points is constructed, thereby reducing the amount of computation required to mine the neighbor relationships between images.

[0036] (2) The coordinate ascent method is used to directly solve the label matrix in the clustering algorithm to directly obtain the image classification result, thereby speeding up the calculation speed of image classification.

[0037] (3) The computational complexity of this method is linearly related to the number of samples and is suitable for classification problems of large-scale image data. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like components throughout the drawings.

[0039] Figure 1 Flowchart of the present invention. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0041] The present invention is an image classification method, and its basic flow chart is as follows: Figure 1 , the specific steps are as follows:

[0042] Step 1: Generate representative anchor points

[0043] Assume that the feature data corresponding to the image is Among them, x i is the i-th data point, d is the dimension of the feature, and n is the number of image data points. The balanced K-means method with a variable number of anchor points is used to generate m representative anchor points from the original n data to obtain the anchor point matrix where u i is the i-th anchor point, and m is the number of anchor points. The traditional balanced K-means algorithm uses K-means to continuously divide the data into two parts. Assuming that the number of binary divisions is q, the number of anchor points obtained is 2. q The disadvantage is that the number of anchor points can only be a power of 2, while the balanced K-means method with a variable number of anchor points can select any number of anchor points. The specific steps are as follows. Suppose that m anchor points need to be selected, and m cannot be expressed as 2 q , then first calculate q min and q max , both satisfy Select first anchor points, and then sort the clusters where the anchor points are located according to the size of the variance, and take the top The cluster with the largest variance is selected and divided into two parts, then m anchor points can be obtained.

[0044] Step 2: Construct an adaptive neighbor graph based on representative anchor points

[0045] Step 2.1: Construct a correlation matrix between representative anchor points and data points

[0046] The correlation matrix B between the data point X and the anchor point U is obtained through the similarity self-learning method. is the correlation matrix between sample points and anchor points. For the i-th sample point, the model is as follows:

[0047]

[0048] Among them, b ij is the i-th row and j-th column element in B, is the i-th row in B, and γ is the regularization coefficient. is the Euclidean distance between the i-th sample point and the j-th anchor point, is a vector whose jth element is k ij , then the above optimization problem can be written in the following vector form

[0049]

[0050] Assumption b i There are l (l≤m) non-zero elements in k. i Rearrange and assume The corresponding b i for but The expression is

[0051]

[0052] Step 2.2: Construct a similarity matrix between samples

[0053] After obtaining B, the similarity between sample points is constructed by the similarity between sample points and anchor points

[0054] A=BΔ -1 B T

[0055] in, is a diagonal matrix, and the calculation of its i-th element is

[0056] In order to express A more concisely, let at this time

[0057] Step 3: Solving the optimization problem

[0058] The present invention minimizes A and FF T The distance between them is used to solve the label matrix. Considering that the two matrices may have scale differences, the matrix S is added to balance the difference. The general optimization problem is as follows

[0059]

[0060] Ind indicates that the matrix F is a discrete value, and S can be a scalar, a diagonal matrix, or a symmetric matrix. The following discusses the solution to this problem in three cases.

[0061] Case 1: When s is a numerical value

[0062] The optimization problem can be transformed, and the transformation process is as follows:

[0063]

[0064] The objective function contains two variables, F and s. There is no constraint on s. We can directly derive s and let J 1 =2sTr(F T AF)-s 2 Tr(FF T FF T ), we can get

[0065]

[0066] Substituting the expression of s into the original optimization problem, the optimization problem can be transformed into

[0067]

[0068] in,

[0069] Assume that F is the matrix obtained in the previous step, and its lth column is The element in row i and column l is When updating the i-th row and l-th column of F, the change in the objective function is calculated as follows

[0070]

[0071] where g il is the element in the i-th row and l-th column of the matrix G, then the optimal f i for

[0072]

[0073] Among them, <·> means that if the parameter is true, its value is 1, if it is false, its value is 0.

[0074] Case 2: When S is a diagonal matrix

[0075] When S is a diagonal matrix, the original problem is

[0076]

[0077] At this time, the optimization problem is written in the form of summation

[0078]

[0079] The optimization problem is to solve the problem of jj are independent, so s can be solved separately jj , for jj Find the partial derivative and set it to 0, and you can get s jj The solution is

[0080]

[0081] Put jj Substitute the expression into the original optimization problem, and the optimization problem becomes

[0082]

[0083] Use the coordinate ascent method to update F row by row, that is, when updating a row, the other rows are fixed. Assuming the optimal When updating the i-th row, when the l-th element of the i-th row changes from 0 to 1, the increment of the objective function can be calculated as

[0084]

[0085] but

[0086]

[0087] The <> operation indicates that the value is 1 if the value is true, otherwise it is 0.

[0088] Case 3: When S is a symmetric matrix

[0089] The objective function is

[0090]

[0091] Let J = 2Tr(F T AFS)-Tr(FSF T FSF T ), since there is no constraint on S, taking the partial derivative of S and setting the derivative value to 0 gives

[0092] F T AF=F T FSF T F

[0093] Can be launched

[0094] S=(F T F) -1 F T AF(F T F) -1

[0095] Substituting the above formula into the expression of J, we can get

[0096] J=Tr(F T AFS

[0097] =Tr(F T AF(F T F) -1 F T AF(F T F) -1 )

[0098] After the objective function is derived with respect to S, it is substituted into the original objective function to obtain:

[0099] J=Tr(F T AF(F T F) -1 F T AF(F T F) -1 )

[0100] Let P = F T AF(F T F) -1 , the objective function becomes:

[0101]

[0102] in, Substituting into

[0103]

[0104] Use the coordinate descent method to update F. When updating the i-th row and l-th column of F, f il changes, J and f il Related partsJ 1 For the following expression

[0105]

[0106] Assume A=[a 1 ,a 2 ,...,a i ,...,a n ], where a i is the i-th row of A, a j is the jth row of A. Then, when the coordinate ascent method is used, when updating the i-th row and l-th column of F, the optimal f i for

[0107]

[0108] The <> operation indicates that the value is 1 if it is true, otherwise it is 0. il The expression is

[0109]

[0110] Embodiment 1:

[0111] The following takes the clustering of the Yale image dataset for face recognition as an example. The Yale image dataset has a total of 165 images. The length and width of each image are 32 pixels. There are 15 categories in total, each category has 11 sample points, and the number of anchor points selected is 64. The specific implementation method includes the following steps.

[0112] Step 1: Generate representative anchor points

[0113] Here, the grayscale feature of the image is used as the data feature of the image. The pixel grayscale value of each image is straightened into a vector. The dimension of the vector is 1024, and the feature data corresponding to the image is Among them, x i is the i-th data point, d = 1024 is the feature dimension, and n = 165 is the number of image data points. The balanced K-means method with a variable number of anchor points is used to generate 64 representative anchor points from 165 data to obtain the anchor matrix where u i is the i-th anchor point, and m=64 is the number of anchor points.

[0114] Step 2: Construct an adaptive neighbor graph based on representative anchor points

[0115] Step 2.1: Construct a correlation matrix between representative anchor points and data points

[0116] The correlation matrix B between the data point X and the anchor point U is obtained through the similarity self-learning method. is the correlation matrix between sample points and anchor points. For the i-th sample point, the model is as follows:

[0117]

[0118] Among them, b ij is the i-th row and j-th column element in B, is the i-th row in B, and γ is the regularization coefficient. is the Euclidean distance between the i-th sample point and the j-th anchor point, is a vector whose jth element is k ij , then the above optimization problem can be written in the following vector form

[0119]

[0120] Assumption b i There are l (l≤m) non-zero elements in k. i Rearrange and assume The corresponding b i for but The expression is

[0121]

[0122] Step 2.2: Construct a similarity matrix between samples

[0123] After obtaining B, the similarity between sample points is constructed by the similarity between sample points and anchor points

[0124] A=BΔ -1 B T

[0125] in, is a diagonal matrix, and the calculation of its i-th element is

[0126] In order to express A more concisely, let at this time

[0127] Step 3: Solving the optimization problem

[0128] Here, we take s as an example to introduce the method proposed by the present invention. At this time, the optimization problem is

[0129]

[0130] The objective function contains two variables, F and s. There is no constraint on s. We can directly derive s and let J 1 =2sTr(F T AF)-s 2 Tr(FF T FF T ), we can get

[0131]

[0132] Substituting the expression of s into the original optimization problem, the optimization problem can be transformed into

[0133]

[0134] in,

[0135] When updating the i-th row and l-th column of F, the change in the objective function is as follows

[0136]

[0137] where g il is the element in the i-th row and l-th column of the matrix G, then the optimal f i for

[0138]

[0139] Among them, <·> means that if the parameter is true, its value is 1, if it is false, its value is 0.

[0140] The optimal discrete label matrix can be iteratively calculated. By comparing the calculated label matrix with the true label of the sample, the clustering accuracy can be obtained to be 43.64%, which is 11.52% higher than spectral clustering in accuracy and 0.0026s less in time than spectral clustering, indicating that the present invention has advantages in image classification tasks.

[0141] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should be included in the protection scope of the present invention.

Claims

1. An image classification method, characterized in that Here are the steps: S1: input classification image; S2: Extract image features and obtain feature data Among them, x i is the i-th data point, d is the dimension of the feature, and n is the number of image data points; S3: Select m anchor points using the balanced K-means method with a variable number of anchor points to obtain the anchor point set U; S4: construct a similarity matrix A between data points based on anchor points; S5: Build a model based on the similarity matrix A and label relationship; S6: Use the coordinate ascent method to solve the model, obtain the labels of the feature data, and complete the image classification; The solution is as follows: By minimizing A and FF T The distance between them is used to solve the label matrix. Considering that the two matrices may have scale differences, the matrix S is added to balance the difference. The general optimization problem is as follows Where Ind indicates that the matrix F is a discrete value, and S can be a scalar, a diagonal matrix, or a symmetric matrix; When s is a scalar, the optimization problem can be transformed. The transformation process is as follows: The objective function contains two variables, F and s. There is no constraint on s. We can directly derive s and set J1 = 2sTr(F T AF)-s 2 Tr(FF T FF T ),get Substituting the expression of s into the original optimization problem, the optimization problem can be transformed into in, Assumptions is the matrix obtained in the previous step, and its lth column is The element in row i and column l is When updating the i-th row and l-th column of F, the change in the objective function is calculated as follows: where g il is the element in the i-th row and l-th column of the matrix G, then the optimal f i for Among them, <·> means that if the parameter is true, its value is 1, if it is false, its value is 0.

2. An image classification method according to claim 1, characterized in that The S4 is divided into the following two steps: S41: constructing a correlation matrix B between data points and anchor points using a similarity self-learning method; S42: Calculate the sample neighbor graph A and the similarity matrix A according to the correlation matrix B.

3. An image classification method according to claim 2, characterized in that: The similarity self-learning method is used to construct the correlation matrix between data points and anchor points as follows: The correlation matrix B between the data point X and the anchor point U is obtained through the similarity self-learning method. is the correlation matrix between sample points and anchor points; for the i-th sample point, the model is as follows: Among them, b ij is the i-th row and j-th column element in B, is the i-th row in B, and γ is the regularization coefficient. is the Euclidean distance between the i-th sample point and the j-th anchor point, is a vector whose jth element is k ij , then the above optimization problem can be written in the following vector form Assumption b i There are l (l≤m) non-zero elements in k i Rearrange and assume The corresponding b i for but The expression is 4. The image classification method according to claim 3, characterized in that: According to the correlation matrix B, the sample neighbor graph A and the similarity matrix A are calculated as follows: After obtaining B, the similarity between sample points is constructed by the similarity between sample points and anchor points A=BΔ -1 B T in, is a diagonal matrix, and the calculation of its i-th element is make at this time 5. A computer system, characterized in that include: One or more processors, and a computer-readable storage medium for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of claims 1-4.

6. A computer-readable storage medium, characterized in that Computer executable instructions are stored, and when the instructions are executed, they are used to implement the method described in any one of claims 1 to 4.

7. A computer program product, characterized in that The method comprises computer executable instructions, which are used to implement the method according to any one of claims 1 to 4 when executed.

Citation Information

Cited By

  • Semi-supervised image classification method based on category prototype

    CN117422928A

  • A semi-supervised image classification method based on category prototypes

    CN117422928B