Face recognition method and system based on weighted inverse neighbor density rapid clustering
By using a weighted inverse nearest neighbor density fast clustering method, the problem of selecting incorrect cluster centers and chain reactions in face recognition by the traditional density peak clustering algorithm is solved, and higher clustering accuracy and recognition precision are achieved.
Patent Information
- Application Number
- CN202511753057.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-02-06
AI Technical Summary
Traditional density peak clustering algorithms fail to effectively balance the density differences between dense and sparse clusters in face recognition, leading to incorrect cluster center selection and chain reactions that affect the clustering results.
A fast clustering method based on weighted inverse nearest neighbor density is adopted. By redefining local density and relative distance, and combining inverse nearest neighbor sets and weighting factors, cluster centers are automatically identified, avoiding manual selection and improving clustering accuracy.
It significantly improves the accuracy of cluster center identification, suppresses density bias, eliminates chain reactions, and enhances the accuracy of face recognition and clustering precision.
Smart Images

Figure CN121482846A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of face image processing, specifically to a face recognition method and system based on weighted inverse nearest neighbor density fast clustering. Background Technology
[0002] With the rapid development of information technology, facial recognition technology has gradually become a focus of research and application. The application of clustering technology in facial recognition can better manage and analyze large amounts of facial data. For example, in security monitoring, by clustering facial images from massive amounts of surveillance video, different images of the same person can be quickly categorized, facilitating subsequent querying and analysis. In intelligent photo album management, clustering technology can automatically group photos of the same person together, providing users with a more convenient photo management and browsing experience. However, existing clustering methods still have some limitations in facial recognition applications.
[0003] Clustering is an unsupervised learning method and one of the earliest methods applied to data mining. Traditional clustering algorithms can be broadly categorized into partitioning clustering, hierarchical clustering, density clustering, grid clustering, and model clustering. In recent years, quantum clustering, spectral clustering, granular clustering, and synchronous clustering have also become popular. Partitioning-based clustering methods optimize the objective function through an iterative process. When the objective function is minimized, disjoint subsets are obtained, and each subset can be considered a cluster. Hierarchical clustering methods are typically divided into two types: one involves bottom-up merging operations to obtain a hierarchical tree, and the other involves top-down splitting of clusters, also resulting in a hierarchical tree representing the clustering structure of the dataset. Density-based clustering methods are more suitable for discovering convex clusters, using sparse regions to divide high-density regions to identify obvious clusters and isolated sample points. Density peak clustering is an example of a density-based clustering algorithm. Although the DPC algorithm is simple and efficient, it has a flaw in selecting cluster centers: the local density definition cannot balance the density difference between dense and sparse clusters, causing the algorithm to tend to select multiple cluster centers in dense clusters.
[0004] Density Peak Clustering (DPC) is a density-based clustering algorithm that has attracted significant research interest since its inception in 2014 by Rodriguez et al. This algorithm introduces concepts such as cutoff distance, relative distance, and local density. First, it manually defines which sample points fall within a given cutoff distance. Then, it calculates the local density and relative distance of each sample point using these defined points. Next, it uses the calculated local density and relative distance to construct a decision graph. Based on this graph, it manually selects cluster centers with both high local density and high relative distance. Finally, it assigns all other sample points (excluding the cluster centers) to their respective clusters, thus achieving clustering. DPC is simple to implement, highly efficient, does not require specifying the number of cluster centers, and has wide applicability.
[0005] The basic idea of the DPC algorithm is as follows: 1) The local density of a density peak is relatively large and it is surrounded by its nearest neighbors, whose densities do not exceed its own; 2) The distance between each density peak is relatively large. Therefore, the DPC algorithm introduces two key concepts: local density. and relative distance Local density It quantifies the density around the sample point, while the relative distance This measures the distance between a sample point and its nearest neighbor with higher local density. These two metrics are used together to identify cluster centers in the dataset and to guide the allocation of the remaining sample points. The formula for calculating local density is:
[0006]
[0007] in, For sample points and The Euclidean distance between them It is the only input parameter, representing the cutoff distance. When The result is ,otherwise .
[0008] From sample points The distance between sample points with greater local density in the vicinity is used The calculation method is as follows:
[0009]
[0010] The DPC algorithm draws a map... x-axis The decision graph with the ordinate is used to select density peaks. To improve the ability to identify density peaks, the DPC algorithm introduces a decision parameter. Its definition is:
[0011]
[0012] In the DPC algorithm, the density peak is defined as having a large Value and The sample points, among which have higher The sample points with the highest values are identified as density peaks. Once a density peak is detected, the remaining sample points are then assigned to the nearest cluster with the highest local density.
[0013] While the DPC algorithm can discover clusters with relatively few parameters and does not require pre-specifying the number of clusters, it also has its shortcomings. These primarily include: the inability to balance density differences between dense and sparse clusters in the local density definition, leading the algorithm to tend to select multiple cluster centers within dense clusters, thus severely impacting the clustering results and resulting in unsatisfactory clustering outcomes. Therefore, it cannot identify correct cluster centers in clusters with large density differences, potentially leading to the selection of incorrect face images as representatives during face recognition. Secondly, the assignment of non-center points can easily trigger a chain reaction, resulting in a large number of consecutive incorrect clusterings of face images.
[0014] To address this, a fast clustering method and system based on weighted inverse nearest neighbor density is proposed. Summary of the Invention
[0015] The technical problem to be solved by this invention is: how to solve the defect that traditional density peak clustering (DPC) does not consider the overall distribution characteristics of samples when defining local density in face recognition, which may lead to the selection of incorrect face images and a chain reaction, resulting in a large number of consecutive incorrect clustering of face images. This invention provides a face recognition method based on weighted inverse nearest neighbor density fast clustering.
[0016] The present invention solves the above-mentioned technical problems through the following technical solution, and the present invention includes the following steps:
[0017] S1: Input face image dataset And preprocessing is performed, where n represents the total number of face images in the face image dataset. This represents the number of feature points contained in each face image; that is, for any k-th face image, it is represented by... The coordinates of each feature point are used to describe this. Let k represent the set of feature points of the k-th face image, where the maximum value of k is n, and each feature point represents a feature point of the k-th face image. Includes The coordinates of feature points in a personal face image are denoted as... ;
[0018] S2: Calculate the Euclidean distance between any two sample points in the face image dataset. ;
[0019] S3: For each sample point Obtain its inverse nearest neighbor set. ;
[0020] S4: Calculate the value for each sample point Corresponding local density and relative distance ;
[0021] S5: Iterate through all sample points, and if the local density of the sample points is... and relative distance All are greater than their corresponding thresholds and If so, then that sample point is selected as the cluster center;
[0022] S6: Starting from the determined cluster centers, assign the remaining sample points to the clusters of the nearest sample points with higher local density, following the order of decreasing local density; repeat the above process until all samples have been assigned, obtaining the final face clustering result CL. ), indicating the category of the face image, if CL( ) = CL( ),express and The two facial images represent the same person;
[0023] S7: Output the face clustering results.
[0024] Furthermore, in step S1, the preprocessing involves performing max-min normalization on each sample point before calculating the Euclidean distance between any two sample points.
[0025] Furthermore, in step S2, for any two sample points and i and j both belong to European distance The calculation formula is:
[0026] .
[0027] Furthermore, in step S3, the inverse nearest neighbor set as follows:
[0028] ;
[0029] in, Indicates distance from sample point The set of the K most recent sample points.
[0030] Furthermore, in step S4, the local density is redefined by combining the inverse nearest neighbor and the weighting function. The definition is as follows:
[0031] ;
[0032] in, For similarity, As a weighting factor, it is used to reflect the sample points The importance of this; the parameter μ is the mean number of inverse nearest neighbors for all sample points;
[0033] Sample points The relative distance to the nearest sample point with a local density higher than itself is used The calculation formula is as follows:
[0034] ;
[0035] in, Represents sample points and European distance, and Represents sample points and The local density.
[0036] Furthermore, weighting factors The calculation formula is as follows:
[0037] ;
[0038] in, Sample points The inverse nearest neighbor set;
[0039] The formula for calculating the parameter μ is as follows:
[0040]
[0041] in, Sample points The number of inverse nearest neighbors.
[0042] Furthermore, similarity For sample points and The similarity metric is calculated using the following formula:
[0043]
[0044] in, For sample points and European distance, For sample points Inverse nearest neighbors and sample points Intersection of inverse nearest neighbors:
[0045] .
[0046] Furthermore, in step S6, the local density and relative distance Corresponding threshold and The formula is as follows:
[0047] ;
[0048] ;
[0049] in, The minimum local density of all sample points. This represents the local density maximum value for all sample points. , The minimum and maximum distances from all sample points to the nearest sample point with a local density higher than its own are given.
[0050] This invention also provides a face recognition system based on weighted inverse nearest neighbor density fast clustering, which uses the above-mentioned method for clustering operations, including:
[0051] The initialization module takes the face image dataset as input and performs preprocessing.
[0052] The Euclidean distance calculation module is used to calculate the Euclidean distance between any two sample points in the dataset. ;
[0053] The reverse nearest neighbor set acquisition module is used to obtain each sample point. inverse nearest neighbor set ;
[0054] The local density and relative distance calculation module is used to calculate the density and relative distance for each sample point. Corresponding local density and relative distance ;
[0055] The clustering operation module is used to traverse all sample points and determine the local density of the sample points. and relative distance All are greater than their corresponding thresholds and If so, then that sample point is selected as the cluster center;
[0056] The reassignment clustering module, starting from the determined cluster centers, assigns the remaining sample points to the nearest cluster with higher local density, following a decreasing local density order. This process is repeated until all samples have been assigned, yielding the final face clustering result CL. ), indicating the category of the face image, if CL( ) = CL( ),express and The two facial images represent the same person;
[0057] The results output module is used to output the face clustering results.
[0058] Compared with existing technologies, this invention has the following advantages: First, the face recognition method and system based on weighted inverse nearest neighbor density fast clustering incorporates weight coefficients into the calculation of local density, redefining local density by combining it with inverse nearest neighbor (RNN), thus enhancing the weight allocation of samples in sparse regions. Second, it introduces the similarity of inverse nearest neighbors between samples into the local density, improving the accuracy of cluster center identification while suppressing density bias and significantly improving the problem of misselected center points. The method of this invention requires no iteration and can automatically and quickly determine cluster centers, eliminating the subjectivity of manual selection of cluster centers. This improved strategy can solve the chain reaction problem when samples are misassigned, preventing a misassigned face image in face image clustering from affecting the assignment of surrounding face images with similar features, thereby improving the accuracy of face recognition. Attached Figure Description
[0059] Figure 1 This is a flowchart illustrating a fast clustering method based on weighted inverse nearest neighbor density in an embodiment of the present invention;
[0060] Figure 2 This is the clustering result of the AutoDPC-WR method on the Ls dataset in this embodiment of the invention;
[0061] Figure 3 This is the clustering result of the DPC algorithm on the Ls dataset in this embodiment of the invention;
[0062] Figure 4 This is the clustering result of the AutoDPC-WR method on the Twomoons dataset in this embodiment of the invention;
[0063] Figure 5 This is the clustering result of the DPC algorithm on the Twomoons dataset in this embodiment of the invention;
[0064] Figure 6 This is the clustering result of the AutoDPC-WR method on the Cth dataset in this embodiment of the invention;
[0065] Figure 7 This is the clustering result of the DPC algorithm on the Cth dataset in this embodiment of the invention. Detailed Implementation
[0066] The embodiments of the present invention are described in detail below. These embodiments are implemented based on the technical solution of the present invention, and provide detailed implementation methods and specific operation processes. However, the scope of protection of the present invention is not limited to the following embodiments.
[0067] Example 1
[0068] In this embodiment, the face image dataset can be multiple face images obtained from different times, locations, and acquisition devices. Each face image is composed of multiple facial feature points. These multiple face images can cover various age groups, genders, skin tones, and facial expressions. Some face images may have been taken in bright indoor environments, clearly showing the details of the face, while others may have been acquired in dim outdoor scenes, potentially leading to a decrease in image quality due to factors such as lighting. It is through the fast clustering method of this embodiment that different face images of the same object with different qualities can be classified, facilitating subsequent querying and analysis.
[0069] like Figure 1 As shown, this embodiment provides a technical solution: a fast clustering method based on weighted inverse nearest neighbor density, applied to face recognition scenarios, including the following steps:
[0070] Step S1: Obtain the face image dataset The data is then normalized, where n represents the total number of face images in the face image dataset. This represents the number of feature points contained in each face image; that is, for any k-th face image, it is represented by... It is described by the coordinates of a feature point (e.g., the corner of the eye, the corner of the mouth, etc.). Let k represent the set of feature points in the k-th face image, where the maximum value of k is n. Includes The coordinates of feature points in a personal face image are denoted as... .
[0071] In this embodiment, each sample point is subjected to max-min normalization, as shown in the following formula:
[0072]
[0073] Where i and j are not equal, i belongs to j belongs to , and This represents the maximum and minimum values of the coordinates of the j-th feature point among all samples (from the 1st to the nth) in the entire dataset. This represents the original coordinates of the j-th feature point of the i-th face image sample in the original dataset. This represents the result of normalizing the coordinates of the j-th feature point of the i-th sample. This normalization method can stabilize face images of different sizes at the same scale, preventing certain features from dominating subsequent face clustering and recognition results due to their large numerical range.
[0074] Step S2: Calculate the Euclidean distance between any two sample points in the normalized face image dataset. .
[0075] In this embodiment, for any two sample points and The Euclidean distance between them The calculation formula is:
[0076]
[0077] Where i and j both belong to .
[0078] Step S3: For each sample point Find its inverse nearest neighbor set. .
[0079] In this embodiment, the inverse nearest neighbor set as follows:
[0080]
[0081] in, Indicates distance from sample point The set of the K most recent sample points.
[0082] Step S4: Calculate each sample point Corresponding local density and relative distance .
[0083] In this embodiment, the local density is redefined by combining inverse nearest neighbor and weighting function, as follows:
[0084]
[0085] in, For similarity, As a weighting factor, used for sample points The importance is defined as follows:
[0086]
[0087] in, Sample points The inverse nearest neighbor set;
[0088] The parameter μ is set using the mean method: let μ be the mean number of inverse nearest neighbors for all sample points.
[0089]
[0090] in, Sample points The number of inverse nearest neighbors.
[0091] In this embodiment, similarity Sample points and The similarity metric is calculated using the following formula:
[0092]
[0093] in, For sample points and European distance, For sample points Inverse nearest neighbors and sample points Intersection of inverse nearest neighbors:
[0094] ;
[0095] Sample points The distance to the nearest sample point with a local density higher than itself is used The calculation formula is as follows:
[0096]
[0097] in, Represents sample points and European distance, and Represents sample points and The local density.
[0098] Step S5: Cluster centers should simultaneously have high local density. and a large relative distance Iterate through all sample points; if the local density of a sample point... and relative distance All are greater than their corresponding thresholds and If a sample point is selected as the cluster center, then that sample point is chosen as the cluster center. The number of cluster centers determines the final number of clusters.
[0099] In this embodiment, local density and relative distance The corresponding threshold formula is as follows:
[0100]
[0101]
[0102] in, The minimum local density of all sample points. For all sample points, the local density maximum is [value]. Similarly, , The minimum and maximum distances from all sample points to the nearest sample point with a local density higher than its own are given.
[0103] Step S6: Assign the remaining unlabeled sample points. Starting from the determined cluster centers, assign the remaining sample points to the clusters of the nearest sample points with higher local density, in descending order of local density; repeat the above process until all samples have been assigned, obtaining the final face clustering result CL( ), indicating the category of the face image, if CL( ) = CL( ),express and The two facial images represent the same person.
[0104] Step S7: Output the face clustering results.
[0105] Example 2
[0106] The dataset used in this embodiment is commonly used in machine learning and is used to replace the face image dataset in Embodiment 1. It is primarily used to test the performance of the weighted inverse nearest neighbor density-based fast clustering method (AutoDPC-WR) in Embodiment 1 when handling non-linearly separable data and complex shape clustering. The dataset is open-source at: https: / / scikit-learn.org / stable / modules / clustering.html.
[0107] Table 1 shows a comparison of the clustering performance of the AutoDPC-WR method with other state-of-the-art algorithms on three large-scale synthetic datasets:
[0108] Table 1 Comparative Experimental Results
[0109]
[0110] Combination Figures 2-6 As shown in Table 1, on the three complex morphological datasets Ls, Twomoons, and Cth, the AutoDPC-WR algorithm achieved perfect scores (1.0) on all three evaluation metrics: Adjusted Mutual Information (AMI), Fowlkes-Mallows Index (FMI), and Adjusted Rand Index (ARI), surpassing the other three existing algorithm models. This demonstrates that the weighted inverse nearest neighbor combined with similarity local density mechanism can effectively identify cluster centers under complex distributions, avoiding the erroneous situation of selecting multiple cluster centers in dense clusters.
[0111] It should be noted that, in Figures 2-6 In the clustering, the hexagon serves as the cluster center, and different classes in the clustering results are distinguished by different colors.
[0112] In summary, the weighted inverse nearest neighbor density-based fast clustering method described above significantly reduces the impact of truncation distance by introducing a weighting mechanism and a similarity metric based on inverse nearest neighbors. This enhances the algorithm's adaptability to different data features while maintaining high computational efficiency, significantly improving clustering accuracy and robustness. Furthermore, by setting a threshold, it automatically identifies cluster centers, eliminating the subjectivity of manual selection. When performing face recognition, it can correctly identify face cluster centers in datasets with large differences in density between clusters and can handle clusters of arbitrary shapes. That is, it selects the more accurate face image as the representative. When assigning non-center points, it also avoids chain reactions, ensuring that face images are clustered in the correct direction, so as to identify the face images of the same object from a large number of face images.
[0113] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A face recognition method based on weighted inverse nearest neighbor density fast clustering, characterized in that, Includes the following steps: S1: Input face image dataset And preprocessing is performed, where n represents the total number of face images in the face image dataset. This represents the number of feature points contained in each face image; that is, for any k-th face image, it is represented by... The coordinates of each feature point are used to describe this. Let k represent the set of feature points of the k-th face image, where the maximum value of k is n, and each feature point represents a feature point of the k-th face image. Includes The coordinates of feature points in a personal face image are denoted as... ; S2: Calculate the Euclidean distance between any two sample points in the face image dataset. ; S3: For each sample point Obtain its inverse nearest neighbor set. ; S4: Calculate the value for each sample point Corresponding local density and relative distance ; S5: Iterate through all sample points, and if the local density of the sample points is... and relative distance All are greater than their corresponding thresholds and If so, then that sample point is selected as the cluster center; S6: Starting from the determined cluster centers, assign the remaining sample points to the clusters of the nearest sample points with higher local density, following the order of decreasing local density; repeat the above process until all samples have been assigned, obtaining the final face clustering result CL. ), indicating the category of the face image, if CL( ) = CL( ),express and The two facial images represent the same person; S7: Output the face clustering results.
2. The face recognition method based on weighted inverse nearest neighbor density fast clustering according to claim 1, characterized in that, In step S1, the preprocessing involves performing max-min normalization on each sample point before calculating the Euclidean distance between any two sample points.
3. The face recognition method based on weighted inverse nearest neighbor density fast clustering according to claim 1, characterized in that, In step S2, for any two sample points and i and j both belong to European distance The calculation formula is: 。 4. The face recognition method based on weighted inverse nearest neighbor density fast clustering according to claim 1, characterized in that, In step S3, the inverse nearest neighbor set as follows: ; in, Indicates distance from sample point The set of the K most recent sample points.
5. The face recognition method based on weighted inverse nearest neighbor density fast clustering according to claim 4, characterized in that, In step S4, the local density is redefined by combining the inverse nearest neighbor and the weighting function. The definition is as follows: ; in, For similarity, As a weighting factor, it is used to reflect the sample points The importance of this; the parameter μ is the mean number of inverse nearest neighbors for all sample points; Sample points The relative distance to the nearest sample point with a local density higher than itself is used The calculation formula is as follows: ; in, Represents sample points and European distance, and Represents sample points and The local density.
6. The face recognition method based on weighted inverse nearest neighbor density fast clustering according to claim 5, characterized in that, Weighting factors The calculation formula is as follows: ; in, Sample points The inverse nearest neighbor set; The formula for calculating the parameter μ is as follows: ; in, Sample points The number of inverse nearest neighbors.
7. A face recognition method based on weighted inverse nearest neighbor density fast clustering according to claim 6, characterized in that, Similarity For sample points and The similarity metric is calculated using the following formula: ; in, For sample points and European distance, For sample points Inverse nearest neighbors and sample points Intersection of inverse nearest neighbors: 。 8. A face recognition method based on weighted inverse nearest neighbor density fast clustering according to claim 7, characterized in that, In step S6, local density and relative distance Corresponding threshold and The formula is as follows: ; ; in, The minimum local density of all sample points. This represents the local density maximum value for all sample points. , The minimum and maximum distances from all sample points to the nearest sample point with a local density higher than its own are given.
9. A face recognition system based on weighted inverse nearest neighbor density fast clustering, characterized in that, Clustering operations are performed using the method described in any one of claims 1 to 8, including: The initialization module takes the face image dataset as input and performs preprocessing. The Euclidean distance calculation module is used to calculate the Euclidean distance between any two sample points in the dataset. ; The reverse nearest neighbor set acquisition module is used to obtain each sample point. inverse nearest neighbor set ; The local density and relative distance calculation module is used to calculate the density and relative distance for each sample point. Corresponding local density and relative distance ; The clustering module is used to iterate through all sample points and determine the local density of the sample points. and relative distance All are greater than their corresponding thresholds and If so, then that sample point is selected as the cluster center; The reassignment clustering module, starting from the determined cluster centers, assigns the remaining sample points to the nearest cluster with higher local density, following a decreasing local density order. This process is repeated until all samples have been assigned, yielding the final face clustering result CL. ), indicating the category of the face image, if CL( ) = CL( ),express and The two facial images represent the same person; The results output module is used to output the face clustering results.