An improved density peak based image clustering method and system
By improving the density peak clustering algorithm and utilizing k-nearest neighbors and hierarchical clustering, the clustering problem on image datasets with uneven density is solved, and more accurate and stable image clustering results are achieved.
Patent Information
- Application Number
- CN202311081239.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-25
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2043-08-25
AI Technical Summary
Existing density peak clustering algorithms perform poorly on image datasets with uneven density and require manual selection of cluster centers, which can easily lead to a chain reaction of incorrect assignments.
By redefining local density and distance, and utilizing k-nearest neighbor sets and hierarchical clustering algorithms, cluster centers are automatically selected and clusters are merged, reducing manual intervention and avoiding incorrect allocation.
It improves the accuracy and stability of image clustering, reduces the cascading effect of misassignment, and enhances the clustering effect on datasets with uneven density.
Smart Images

Figure CN117115492B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image data processing, and particularly relates to an image clustering method and system based on improved density peaks. BACKGROUND
[0002] The clustering analysis method is an unsupervised learning method, and is one of important research directions in the fields of machine learning and data mining. In recent years, the clustering analysis method has been successfully applied to the field of image processing, such as image segmentation, image recognition, image denoising, and the key point of realizing the above image processing functions lies in clustering image data.
[0003] In the prior art, when clustering image data, the clustering result usually depends on the selection of the initial clustering center, and different initial clustering centers will produce different clustering results. The density peak clustering is a density-based clustering method, which can solve the above problems.
[0004] However, the density peak clustering algorithm has some defects:
[0005] Firstly, the clustering effect of the algorithm is poor on the data set with uneven density;
[0006] Secondly, the selection of the clustering center in the decision graph needs human participation, which increases the subjectivity of the algorithm:
[0007] In addition, the point-by-point assignment strategy is easy to cause a sample point to be wrongly assigned, which may lead to a chain reaction similar to the "domino effect" of a large number of sample points being wrongly assigned;
[0008] These defects make it difficult for the density peak clustering algorithm to play a good role in actual production. SUMMARY
[0009] The present application realizes a method for image processing using the density peak clustering algorithm, and overcomes the problems of poor clustering effect of the density peak clustering algorithm on the data set with uneven density, the need for human participation and the error-prone assignment strategy.
[0010] In order to achieve the above purpose, the technical scheme adopted by the present application is as follows: an image clustering method based on improved density peaks, comprising the following steps:
[0011] Step 1, obtaining image data to be clustered;
[0012] Step 2, calculating the local density and distance of each image data;
[0013] Step 3, dividing the image into several clusters according to the local density and distance;
[0014] Step 4, merging the clusters by using hierarchical clustering to obtain the final image clustering result.
[0015] In step 1, assuming that all pixels of the images are GxM, the first image is processed to form a GxM matrix X1=(x1,x2,...,x M ), and the remaining N-1 images are processed to form an NxM image sample set X={X1,X2,...,X N}, X1,X2,...,X N represent sample points.
[0016] In step 2, according to the image sample set X obtained in step 1, first, the k-neighbor set of each sample point is calculated, and then the k mutual neighbor set and the non-k mutual neighbor set of each sample are obtained, and the local density and distance are calculated according to the k mutual neighbor set and the non-k mutual neighbor set of each sample point.
[0017] Step 2 includes the following steps:
[0018] Step 2.1: For the NxM image sample set, denoted as X={X1,X2,...,X N}, the Euclidean distance between any two sample points X i and X j is calculated:
[0019]
[0020] Step 2.2: According to the Euclidean distance value calculated in step 2.1, the k-neighbor set of each sample point is calculated, and the definition of the k-neighbor set is as follows:
[0021] KNN(X i )={x j ∈X|d(X i ,X j )≤d(X i ,X k )}
[0022] Where X k is the kth nearest sample point of X i .
[0023] Step 2.3: According to the k-neighbor set, the k mutual neighbor set and the non-k mutual neighbor set of each sample point are calculated, and the k mutual neighbor set MNN(X i ) of the sample point X i is defined as:
[0024] MNN(X i )={X j |X j ∈KNN(X i ),X i ∈KNN(Xj )}
[0025] sample point X i The non-k mutual neighbor set NMNN(X i ) is defined as:
[0026]
[0027] Step 2.4: Calculate the local density of each sample point according to the k mutual neighbor set and the non-k mutual neighbor set, the local density of sample point X i is defined as:
[0028]
[0029] Step 2.5: Calculate the distance of each sample point according to the k mutual neighbor set and the non-k mutual neighbor set, the distance of sample point X i is defined as:
[0030]
[0031] wherein,
[0032]
[0033] In step 3, the decision value is calculated according to the local density and the distance obtained in step 2, and the sample points with non-zero decision value are defined as cluster centers, and the remaining sample points are assigned.
[0034] The step 3 includes the following steps:
[0035] Step 3.1: Calculate the decision value of each sample point according to the local density and the distance obtained in step 1, the decision value of sample point X i is defined as:
[0036] γ i = ρ i δ i
[0037] Step 3.2: Record the sample points with non-zero decision value γ i as cluster centers, and assume the number of cluster centers is m, wherein m>c, c is the number of categories of samples, and the cluster centers are recorded as CL={cl1, cl2, …, cl m}
[0038] Step 3.3: According to the cluster centers CL={cl1, cl2, …, cl m}, according to the allocation strategy of the original density peak clustering algorithm, the remaining sample points are allocated to the cluster where the nearest sample point is greater than the local density, and m clusters are obtained, denoted as cluster = {cluster1, cluster2, …, cluster m}.
[0039] In step 4, the m cluster centers obtained in step 3 are clustered by using a hierarchical clustering algorithm, and the clusters are merged to obtain the final clustering result.
[0040] Step 4 includes the following steps:
[0041] Step 4.1: According to the cluster centers CL = {cl1, cl2, …, cl m} obtained in step 3, initialize, let D i = {cl i} ;
[0042] Step 4.2: Calculate the similarity between D i and D j :
[0043]
[0044] Where p represents the number of elements in the D i set, and q represents the number of elements in the D j set;
[0045] Step 4.3: Assume that S ij is the element with the largest value in S, merge the cluster centers cl i and cl j corresponding to the clusters cluster i and cluster j , and D i = {cl i , cl j}, and the number of clusters is reduced to m-1.
[0046] Step 4.4: Repeat steps 4.2 and 4.3 until the number of clusters is reduced to c, and obtain the final image clustering result.
[0047] An image clustering system based on an improved density peak includes a processor and a memory, the memory stores computer readable instructions of the image clustering method based on the improved density peak, and the processor is connected to the processor and executes the computer readable instructions.
[0048] The application is based on an improved density peak image clustering method, which includes redefining local density and distance based on k mutual neighbors, enhancing clustering effect of the algorithm on density uneven data sets, avoiding selection of clustering center points and chain reaction of similar "domino effect" by using hierarchical clustering, and overcoming main defects of the density peak clustering algorithm, including poor clustering effect of the algorithm on density uneven data sets, need of manual participation in selection of clustering centers in decision graph, and chain reaction of a sample point being wrongly distributed possibly leading to a large number of sample points being wrongly distributed. BRIEF DESCRIPTION OF DRAWINGS
[0049] The following is a brief description of the content expressed in each drawing in the specification of the application:
[0050] Figure 1 It is a principle diagram of the improved density peak-based image clustering method;
[0051] Figure 2 It is a flowchart of the improved density peak-based image clustering method. DETAILED DESCRIPTION
[0052] The following is a further detailed description of the specific embodiments of the application, such as shapes, structures, mutual positions and connection relationships between parts, functions and working principles of each component involved, manufacturing processes and operation and use methods, by comparing the drawings and describing the embodiments, to help those skilled in the art have a more complete, accurate and in-depth understanding of the inventive concept and technical solution of the application.
[0053] The improved density peak-based image clustering method includes the following four steps as shown in Figure 1 .
[0054] Step 1, obtaining image data to be clustered;
[0055] Suppose that all pixels of the images are GxM, the first image is subjected to grayscale processing to form a GxM matrix X1=(x1,x2,...,x M ). The remaining N-1 images are subjected to the same processing to form an NxM image sample set X={X1,X2,...,X N}, X1,X2,...,X N represent sample points;
[0056] Step 2, calculating local density and distance of each image data;
[0057] Based on the image sample set X obtained in step 1, the k-nearest neighbor set of each sample point is first calculated, and then the k-mutual nearest neighbor set and non-k-mutual nearest neighbor set of each sample are obtained. Local density and distance are then calculated based on the k-mutual nearest neighbor set and non-k-mutual nearest neighbor set of each sample point, specifically including:
[0058] Step 2.1: For a sample set of size N×M, denoted as X={X1,X2,…,X…} N}, calculate any two sample points X i and X j Euclidean distance between:
[0059]
[0060] Step 2.2: Based on the Euclidean distance value calculated in Step 2.1, calculate the k-nearest neighbor set for each sample point. The definition of the k-nearest neighbor set is as follows:
[0061] KNN(X i )={x j ∈X|d(X i ,X j )≤d(X i ,X k )}
[0062] Among them, X k It is X i The kth nearest sample point.
[0063] Step 2.3: Calculate the k-nearest neighbor set and non-k-nearest neighbor set for each sample point based on the k-nearest neighbor set. Sample point X i k-nearest neighbor set MNN(X) i ) is defined as:
[0064] MNN(X i )={X j |X j ∈KNN(X i ),X i ∈KNN(X j )}
[0065] Sample point X i Non-k mutual nearest neighbor sets NMNN(X) i ) is defined as:
[0066]
[0067] Step 2.4: Calculate the local density of each sample point based on the k-nearest neighbors and non-k-nearest neighbors, sample point X. i The local density is defined as:
[0068]
[0069] Step 2.5: Calculate the distance of each sample point according to the k- mutual neighborhood set and the non-k-mutual neighborhood set, sample point X i The distance of X i is defined as:
[0070]
[0071] where,
[0072]
[0073] Step 3, divide the image into several clusters according to the local density and the distance;
[0074] According to the local density and the distance obtained in step 2, calculate the decision value, define the sample points with non-zero decision value as cluster centers, and then distribute the remaining sample points. Specifically, it includes:
[0075] Step 3.1: Calculate the decision value of each sample point according to the local density and the distance obtained in step 1, sample point X i The decision value of X i is defined as:
[0076] γ i = ρ i δ i
[0077] Step 3.2: Record the sample points with non-zero decision value γ i as cluster centers, assuming the number of cluster centers is m, where m > c, c is the number of categories of samples. The cluster centers are recorded as CL = {cl1, cl2, …, cl m}
[0078] Step 3.3: According to the cluster centers CL = {cl1, cl2, …, cl m} obtained in step 3.2, according to the distribution strategy of the original density peak clustering algorithm, distribute the remaining sample points to the cluster where the nearest sample point has a larger local density, obtain m clusters, recorded as cluster = {cluster1, cluster2, …, cluster m};
[0079] Step 4, merge clusters using hierarchical clustering to obtain image clustering results;
[0080] Use the hierarchical clustering algorithm to cluster the m cluster centers obtained in step 3, and merge the clusters to obtain the final clustering results, which specifically includes:
[0081] Step 4.1: According to the cluster centers CL = {cl1, cl2, …, cl m} obtained in step 3, initialize, let D i = {cl i}
[0082] Step 4.2: Calculate D i and D j Similarity between
[0083]
[0084] Wherein, p represents the number of elements of D i , q represents the number of elements of D j .
[0085] Step 4.3: Assume S ij is the element with the largest value in S, merge the cluster centers cl i and cl j corresponding to the clusters cluster i and cluster j , and D i ={cl i ,cl j}, the number of clusters is reduced to m-1.
[0086] Step 4.4: Repeat steps 4.2 and 4.3 until the number of clusters is reduced to c, and obtain the final image clustering result.
[0087] The improved density peak-based image clustering system comprises a processor and a memory, wherein the memory stores computer readable instructions, and the computer readable instructions are executed by the processor to implement the improved density peak-based image clustering method of the first aspect.
[0088] The present application aims at the problem that different initial clustering centers will produce different clustering results in the prior art when clustering image data, introduces the density peak clustering algorithm, and then redefines the local density by using the concept of k mutual neighbors in view of the phenomenon that the density peak clustering algorithm has poor clustering effect on the data set with uneven density; in view of the problems that the density peak clustering algorithm has strong subjectivity in selecting the clustering center and the defect that only relying on the local density to assign the remaining samples is easy to form a similar "domino effect", the remaining sample points are assigned by using hierarchical clustering, and a better image clustering result is obtained.
[0089] The present application has been described above in conjunction with the accompanying drawings, and it is obvious that the specific implementation of the present application is not limited by the above manner, as long as various non-essential improvements are made by using the method concept and technical solution of the present application, or the concept and technical solution of the present application are directly applied to other occasions without improvement, all of which are within the protection scope of the present application.
Claims
1. An image clustering method based on improved density peaks, characterized in that, Includes the following steps: Step 1: Obtain the image data to be clustered; Step 2: Calculate the local density and distance for each image data point; Step 3: Divide the image into several clusters based on local density and distance; Step 4: Merge clusters using hierarchical clustering to obtain the final image clustering result; In step 1, assuming all images have a pixel size of G×M, the first image is converted to grayscale to form a matrix X1 = (x1, x2, ..., xm) of size G×M. M The same process is applied to the remaining N-1 images to form an image sample set X = {X1, X2, ..., X...} of size N×M. N },X1,X2,…,X N Indicates sample points; In step 2, based on the image sample set X obtained in step 1, the k nearest neighbor set of each sample point is first calculated, and then the k mutual nearest neighbor set and non-k mutual nearest neighbor set of each sample are obtained. The local density and distance are calculated based on the k mutual nearest neighbor set and non-k mutual nearest neighbor set of each sample point. Step 2 includes the following steps: Step 2.1: For an image sample set of size N×M, denoted as X={X1,X2,…,X…} N }, calculate any two sample points X i and X j Euclidean distance between: Step 2.2: Based on the Euclidean distance value calculated in Step 2.1, calculate the k-nearest neighbor set for each sample point. The definition of the k-nearest neighbor set is as follows: KNN(X i )={x j ∈X|d(X i ,X j )≤d(X i ,X k )}; Among them, X k It is X i The k-th nearest sample point; Step 2.3: Calculate the k-nearest neighbor set and non-k-nearest neighbor set for each sample point based on the k-nearest neighbor set. Sample point X i k-nearest neighbor set MNN(X) i ) is defined as: MNN(X i )={X j |X j ∈KNN(X i ),X i ∈KNN(X j )}; Sample point X i Non-k mutual nearest neighbor sets NMNN(X) i ) is defined as: Step 2.4: Calculate the local density of each sample point based on the k-nearest neighbors and non-k-nearest neighbors, sample point X. i The local density is defined as: Step 2.5: Calculate the distance to each sample point based on the k-nearest neighbor set and non-k-nearest neighbor sets, where sample point X... i The distance is defined as: in, 2. The image clustering method based on improved density peaks according to claim 1, characterized in that: In step 3, the decision value is calculated based on the local density and distance obtained in step 2. The sample points with non-zero decision values are defined as cluster centers, and the remaining sample points are then assigned.
3. The image clustering method based on improved density peaks according to claim 2, characterized in that: Step 3 includes the following steps: Step 3.1: Calculate the decision value for each sample point X based on the local density and distance obtained in Step 1. i The decision value is defined as: c i =ρ i d i ; Step 3.2: Set the decision value γ i Non-zero sample points are denoted as cluster centers. Assume there are m cluster centers, where m > c, and c is the number of sample classes. The cluster centers are denoted as CL = {cl1, cl2, ..., cl...}. m } Step 3.3: Based on the cluster centers CL = {cl1, cl2, ..., cl...} obtained in Step 3.2 m Following the allocation strategy of the original density peak clustering algorithm, the remaining sample points are assigned to the clusters containing the nearest sample points with higher local density, resulting in m clusters, denoted as cluster = {cluster1, cluster2, ..., cluster...}. m } 4. The image clustering method based on improved density peaks according to claim 3, characterized in that: In step 4, the hierarchical clustering algorithm is used to cluster the m cluster centers obtained in step 3, and the clusters are merged to obtain the final clustering result.
5. The image clustering method based on improved density peaks according to claim 4, characterized in that: Step 4 includes the following steps: Step 4.1: Based on the cluster centers CL = {cl1, cl2, ..., cl3} obtained in Step 3, m }, Initialize, let D i ={cl i }; Step 4.2: Calculate D i and D j Similarity between: Where p represents D i The number of elements in the set, q represents D. j The number of elements in the set; Step 4.3: Assume S ij The element with the largest value in S is the cluster center cl. i and cl j corresponding cluster i and cluster j Meanwhile, D i ={cl i ,cl j The number of clusters is reduced to m-1; Step 4.4: Repeat steps 4.2 and 4.3 until the number of clusters is reduced to c, and obtain the final image clustering result.
6. An image clustering system based on improved density peaks, characterized in that: It includes a processor and a memory, wherein the memory stores computer-readable instructions for the image clustering method based on the improved density peak as described in claims 1-5, and the processor is connected to the processor and executes the computer-readable instructions.
Citation Information
Patent Citations
Data processing method and system based on semi-supervised learning image clustering
CN111639674A