An image segmentation method based on superpixels and improved on granules
Patent Information
- Application Number
- CN202410047400.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-11
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2044-01-11
AI Technical Summary
[0009]基于上述背景技术所以提出的问题,本发明的目的在于提供一种基于超像素和基于粒球改进的图像分割方法,通过SLIC算法,得到超像素分割的结果,经过特征提取,以获得高维特征向量,接着使用基于粒球改进的ISOMAP提取重要特征,最后将这些特征作为DPC聚类算法的输入,得到最终的聚类结果,解决了现有技术没有考虑超像素的高维特征和特征间的非线性关系,从而导致了输出图像不够准确的问题
[0061]为克服目前技术中的没有考虑超像素的高维特征和特征间的非线性关系而导致输出不够准确的问题,本发明主要使用SLIC算法,得到超像素分割的结果,经过特征提取,以获得高维特征向量,接着使用基于粒球改进的ISOMAP提取重要特征,最后将这些特征作为DPC聚类算法的输入,得到最终的聚类结果。较于现有技术,能够在保证高效性的同时,采用丰富的特征表示来获取精确的分割结果。
Smart Images

Figure CN117765263B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and more specifically to an image segmentation method based on superpixels and improved particle spheres. Background Technology
[0002] Image segmentation is the process of dividing an image into regions with similar attributes or semantics. Existing image segmentation techniques can be mainly classified into the following categories:
[0003] Threshold-based methods: Threshold segmentation methods divide pixels into different regions by comparing the grayscale or color values of pixels in an image with a pre-set threshold.
[0004] Edge-based methods: Edges are important structural information in an image. Edge-based segmentation methods detect edges in an image and segment based on the relationships between the edges.
[0005] Graph-cut-based methods: Graph-cut algorithms treat image segmentation as a minimum cut problem and achieve it by finding the optimal segmentation in the graph.
[0006] Superpixel-based methods: Superpixel segmentation methods provide better feature representation and more efficient image processing by segmenting an image into compact regions with similar properties.
[0007] Deep learning-based methods: Deep learning methods such as convolutional neural networks (CNNs) have achieved remarkable results in image segmentation tasks.
[0008] However, the above methods do not take into account the high-dimensional features of superpixels and the nonlinear relationships between features, which leads to the problem that the output image is not accurate enough. Summary of the Invention
[0009] Based on the problems raised in the above-mentioned background technology, the purpose of this invention is to provide an image segmentation method based on superpixels and improved particle spheres. The method obtains superpixel segmentation results through the SLIC algorithm, extracts high-dimensional feature vectors through feature extraction, extracts important features using ISOMAP based on improved particle spheres, and finally uses these features as input to the DPC clustering algorithm to obtain the final clustering results. This solves the problem that existing technologies do not consider the high-dimensional features of superpixels and the nonlinear relationships between features, resulting in inaccurate output images.
[0010] This invention is achieved through the following technical solution:
[0011] The first aspect of this invention provides an image segmentation method based on superpixels and improved based on spheres, comprising the following steps:
[0012] Step S1: Use the SLIC algorithm to perform superpixel segmentation on the image to be segmented to obtain superpixels;
[0013] Step S2: Extract features from the superpixels to obtain a feature set;
[0014] Step S3: The feature set is dimensionality reduced using the ISOMAP algorithm based on particle spheres to obtain important features;
[0015] Step S4: Use the optimized DPC clustering algorithm to cluster the important features to obtain cluster labels;
[0016] Step S5: Merge the superpixels and cluster labels to generate a segmentation result image.
[0017] In the above technical solution, to overcome the problem of inaccurate output caused by the lack of consideration for the high-dimensional features of superpixels and the nonlinear relationships between features in current technologies, this invention uses the SLIC algorithm to perform superpixel segmentation on the image to be segmented, thereby merging similar pixels to create compact regions, thus providing better feature representation and more efficient image processing, reducing discontinuities and inaccuracies in image segmentation. When merging superpixels, issues such as similarity measurement and computational efficiency need to be considered. When selecting a similarity measurement method, multiple metrics can be considered to comprehensively evaluate the similarity between superpixels, resulting in a feature vector whose dimension corresponds to the number of metrics, thus the feature vector may become very long. In this invention, the ISOMAP algorithm based on particle spheres is used for dimensionality reduction, thereby reducing the dimension of the feature vector, which helps to reduce the length of the feature vector while retaining important feature information.
[0018] The feature vectors obtained by dimensionality reduction using the ISOMAP algorithm are used as input to the DPC clustering algorithm to generate cluster labels. Finally, superpixels are associated with their corresponding cluster labels, assigning each superpixel in the image to a specific cluster. At this point, each superpixel is labeled as belonging to a specific region or object. Compared to existing technologies, this approach can achieve accurate segmentation results while maintaining high efficiency and employing rich feature representations.
[0019] In one optional embodiment, superpixel segmentation of the image to be segmented using the SLIC algorithm includes the following steps:
[0020] Step S11: Determine the number of superpixels and the size of the superpixels, obtain the width and height of the image to be segmented, segment the width and height based on the number of superpixels and the size of the superpixels to obtain M×N superpixel blocks of equal size, and take the center point of each superpixel block as the center pixel of the corresponding superpixel block;
[0021] Step S12: Calculate the color distance and spatial distance between the center pixel of each superpixel block and the surrounding pixels of the center pixel;
[0022] Step S13: Allocate pixels based on the color distance and the spatial distance, and calculate the average color and average position of all pixels in each superpixel block after allocation;
[0023] Step S14: Repeat steps S12 and 13 until the stopping condition of the iteration is met.
[0024] In one optional embodiment, the dimensionality reduction of the feature set based on the particle-sphere-based improved ISOMAP algorithm includes the following steps:
[0025] Step S31: Initialize the feature set into spheres, divide the spheres into spheres, and obtain a set of spheres;
[0026] Step S32: Calculate the center of each particle in the set of particles to obtain the set of particle centers;
[0027] Step S33: Use the ISOMAP algorithm to calculate the k nearest neighbors of each particle center in the particle center set to obtain an adjacency graph. Perform pruning optimization on the edge set in the adjacency graph and calculate the weight values of the edge set after pruning optimization to obtain a weight matrix.
[0028] Step S34: Calculate the weight matrix using the Dijkstra algorithm based on Fibonacci heaps to obtain the shortest path matrix;
[0029] Step S35: Calculate the shortest path matrix using the MDS algorithm to obtain the eigenvalue matrix and eigenvector matrix. Perform a comprehensive calculation on the eigenvalue matrix and the eigenvector matrix to obtain the target matrix.
[0030] In one optional embodiment, initializing the feature set as spheres and dividing the spheres into spheres includes the following steps:
[0031] Step S311: Initialize the feature set as a particle gb, and divide the particle gb into particles gb1 and particle gb2;
[0032] Step S312: Calculate the mass of the particle gb, the particle gb1, and the particle gb2 to obtain the mass dm. gb ,quality and quality If the mass dm gb ,quality and quality If the substitution formula is satisfied, then use particle gb1 and particle gb2 to replace particle gb; otherwise, retain particle gb.
[0033] Step S313: Repeat steps S311 and S312 until no new particles are generated, thus generating a particle set.
[0034] In an optional embodiment, the substitution formula is expressed as follows:
[0035]
[0036] In the above formula, |gb| represents the number of elements in the current sphere.
[0037] In one alternative embodiment, the formula for calculating the center of each sphere in the sphere set is as follows:
[0038]
[0039] In the above formula, c represents the center of each sphere in the sphere set, info i A one-dimensional feature vector representing a superpixel.
[0040] In one optional embodiment, pruning optimization of the edge set in the adjacency graph includes: dividing the edge set in the adjacency graph into a strongly connected edge set SCC and a weakly connected edge set WCC, retaining the edges belonging to the strongly connected edge set SCC, and deleting the edges belonging to the weakly connected edge set WCC, to obtain the pruned and optimized edge set.
[0041] In one optional embodiment, the comprehensive calculation of the eigenvalue matrix and the eigenvector matrix includes the following steps:
[0042] A new eigenvalue matrix is formed by selecting the first p eigenvalues from the eigenvalue matrix, and a new eigenvector matrix is formed by selecting the eigenvectors corresponding to the first p eigenvalues from the eigenvector matrix; where p is the expected dimension.
[0043] The new eigenvalue matrix and the new eigenvector matrix are calculated using the target matrix formula to obtain the target matrix; wherein the target matrix formula is expressed as follows:
[0044]
[0045] In the above formula, Y represents the target matrix, Q * Let Λ represent the new eigenvector matrix. * This represents the new eigenvalue matrix.
[0046] In one optional embodiment, clustering the important features using the optimized DPC clustering algorithm includes the following steps:
[0047] Step S41: Calculate the local density of each eigenvector in the target matrix, and divide the target matrix into a high-density set HDS and a low-density set LDS based on the local density;
[0048] The formula for calculating the local density is as follows:
[0049]
[0050] In the above formula, ρ i k represents the local density. * Represents the neighborhood size, y i Let y represent the i-th eigenvector. i j This represents the j-th nearest neighbor of the i-th eigenvector;
[0051] Step S42: Calculate the nearest distance between the high-density set HDS and the low-density set LDS using different strategies to obtain the nearest distance of the target matrix and determine the dependency relationship;
[0052] Step S43: Multiply the local density and the nearest distance corresponding to the local density to obtain the density value, and select q points with the highest density values as density peak points;
[0053] Step S44: Assign each feature vector to the cluster containing the nearest density peak point according to the dependency relationship, and obtain the cluster label.
[0054] In one alternative embodiment, calculating the nearest distance between the high-density set HDS and the low-density set LDS using different strategies includes:
[0055] For the high-density set HDS, the nearest distance calculation formula is as follows:
[0056]
[0057] For the low-density set LDS, the nearest distance calculation formula is as follows:
[0058]
[0059] In the above formula, δ i ρ represents the closest distance. i k represents the local density. * Represents the neighborhood size, y i Let i represent the i-th eigenvector.
[0060] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0061] To overcome the inaccurate output caused by current technologies failing to consider the high-dimensional features of superpixels and the nonlinear relationships between features, this invention primarily uses the SLIC algorithm to obtain superpixel segmentation results. After feature extraction to obtain high-dimensional feature vectors, an improved ISOMAP algorithm based on spheres is used to extract important features. Finally, these features are used as input to the DPC clustering algorithm to obtain the final clustering results. Compared to existing technologies, this approach achieves accurate segmentation results while maintaining high efficiency through rich feature representations. Attached Figure Description
[0062] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be considered as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. In the drawings:
[0063] Figure 1 This is a flowchart illustrating an image segmentation method based on superpixels and improved particle spheres, as provided in Embodiment 1 of the present invention.
[0064] Figure 2 This is a schematic diagram of the structure of an electronic device provided in Embodiment 2 of the present invention. Detailed Implementation
[0065] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.
[0066] Example 1
[0067] Figure 1 This is a flowchart illustrating an image segmentation method based on superpixels and improved particle spheres according to Embodiment 1 of the present invention, as shown below. Figure 1 As shown, an image segmentation method based on superpixels and improved particle spheres includes the following steps:
[0068] Step S1: Use the SLIC algorithm to perform superpixel segmentation on the image to be segmented to obtain superpixels;
[0069] Step S2: Extract features from the superpixels to obtain a feature set;
[0070] Step S3: The feature set is dimensionality reduced using the ISOMAP algorithm based on particle spheres to obtain important features;
[0071] Step S4: Use the optimized DPC clustering algorithm to cluster the important features to obtain cluster labels;
[0072] Step S5: Merge the superpixels and cluster labels to generate a segmentation result image.
[0073] It should be noted that, to overcome the problem of inaccurate output caused by the lack of consideration for the high-dimensional features of superpixels and the nonlinear relationships between features in current technologies, this invention uses the SLIC algorithm to perform superpixel segmentation on the image to be segmented, thereby merging similar pixels to create compact regions, thus providing better feature representation and more efficient image processing, reducing discontinuities and inaccuracies in image segmentation. When merging superpixels, issues such as similarity measurement and computational efficiency need to be considered. When choosing a similarity measurement method, multiple metrics can be considered to comprehensively evaluate the similarity between superpixels, resulting in a feature vector whose dimension corresponds to the number of metrics, thus the feature vector may become very long. In this invention, the ISOMAP algorithm based on particle spheres is used for dimensionality reduction, thereby reducing the dimension of the feature vector, which helps to reduce the length of the feature vector while retaining important feature information.
[0074] The feature vectors obtained by dimensionality reduction using the ISOMAP algorithm are used as input to the DPC clustering algorithm to generate cluster labels. Finally, superpixels are associated with their corresponding cluster labels, assigning each superpixel in the image to a specific cluster. At this point, each superpixel is labeled as belonging to a specific region or object. Compared to existing technologies, this approach can achieve accurate segmentation results while maintaining high efficiency and employing rich feature representations.
[0075] In one optional embodiment, superpixel segmentation of the image to be segmented using the SLIC algorithm includes the following steps:
[0076] Step S11: Determine the number of superpixels and the size of the superpixels, obtain the width and height of the image to be segmented, segment the width and height based on the number of superpixels and the size of the superpixels to obtain M×N superpixel blocks of equal size, and take the center point of each superpixel block as the center pixel of the corresponding superpixel block;
[0077] Step S12: Calculate the color distance and spatial distance between the center pixel of each superpixel block and the surrounding pixels of the center pixel;
[0078] Step S13: Allocate pixels based on the color distance and the spatial distance, and calculate the average color and average position of all pixels in each superpixel block after allocation;
[0079] Step S14: Repeat steps S12 and 13 until the stopping condition of the iteration is met.
[0080] It should be noted that the purpose of this step is to achieve superpixel segmentation of the image. Superpixel segmentation can merge similar pixels to create compact regions, thereby providing better feature representation and more efficient image processing for subsequent steps. Simultaneously, it can better handle complex textures, thus improving the segmentation capability for complex textures.
[0081] Those skilled in the art can determine the number of superpixels and the superpixel size S according to the specific application scenario. The number of superpixels determines the number of superpixels generated, and the superpixel size defines the number of pixels in each superpixel. The width W and height H of the image to be segmented are obtained, and the image is divided into M×N equal-sized superpixel blocks, where M = W / S and N = H / S. The center point of each superpixel block is used as its initial center pixel. Then, the color distance and spatial distance between the center pixel of each superpixel and its surrounding pixels are calculated. In this embodiment, the surrounding pixels include 2S×2S pixels surrounding the center pixel of the superpixel. Each pixel is reassigned to the center pixel of the nearest superpixel block based on the color distance and spatial distance. Iteration stops if the center pixel of the superpixel block no longer changes or the maximum number of iterations is reached. That is, the stopping condition for iteration in this invention is that the center pixel of the superpixel block no longer changes or the maximum number of iterations is reached.
[0082] In this embodiment, color distance can be calculated using Euclidean distance or distance metrics in other color spaces, and spatial distance can be calculated using Euclidean distance or other spatial distance metrics. Average color is obtained by averaging the colors of all pixels in the superpixel block, and average position is obtained by averaging the positions of all pixels in the superpixel block.
[0083] It should be noted that feature extraction of superpixels in step S2 refers to extracting representative information from the superpixels, such as color, texture, edges, and shape. Color is one of the most intuitive features in an image, and different color spaces can be used for color feature extraction, commonly including RGB, Lab, and HSV. Texture features are important features that reflect local structure and details in an image. Commonly used texture feature extraction methods include co-occurrence matrix features, local binary features, and Gabor filtering features. Other features usually have multiple extraction methods, and appropriate features and corresponding extraction methods can be selected according to specific needs and problems. Generally speaking, for ordinary images, color and texture features are sufficient.
[0084] In this embodiment of the invention, each superpixel uses The superpixel's feature set is represented by the average of all pixels [x,y,h,s,v] plus the contrast, dissimilarity, and autocorrelation moment (ASM) of its gray-level co-occurrence matrix. Here, [x,y] represents the coordinate information, and [h,s,v] represents the hue (h), saturation (s), and lightness (v) corresponding to the HSV color space. Finally, all one-dimensional feature vectors representing superpixels are merged to obtain a feature set I = {info1,info2,...,info...} N}
[0085] In one optional embodiment, the dimensionality reduction of the feature set based on the particle-sphere-based improved ISOMAP algorithm includes the following steps:
[0086] Step S31: Initialize the feature set into spheres, divide the spheres into spheres, and obtain a set of spheres;
[0087] Step S32: Calculate the center of each particle in the set of particles to obtain the set of particle centers;
[0088] Step S33: Use the ISOMAP algorithm to calculate the k nearest neighbors of each particle center in the particle center set to obtain an adjacency graph. Perform pruning optimization on the edge set in the adjacency graph and calculate the weight values of the edge set after pruning optimization to obtain a weight matrix.
[0089] Step S34: Calculate the weight matrix using the Dijkstra algorithm based on Fibonacci heaps to obtain the shortest path matrix;
[0090] Step S35: Calculate the shortest path matrix using the MDS algorithm to obtain the eigenvalue matrix and eigenvector matrix. Perform a comprehensive calculation on the eigenvalue matrix and the eigenvector matrix to obtain the target matrix.
[0091] It is important to emphasize that when merging superpixels, issues such as similarity measurement and computational efficiency need to be considered. When choosing a similarity measurement method, multiple metrics can be considered to comprehensively evaluate the similarity between superpixels, resulting in a feature vector whose dimension corresponds to the number of metrics; therefore, the feature vector may become very long.
[0092] To address this, this invention employs an improved ISOMAP algorithm based on grain spheres to reduce the dimensionality of the feature set. This maps the original feature vectors to a lower-dimensional space, thereby reducing the dimensionality of the feature vectors and helping to reduce their length while retaining important feature information, thus extracting crucial features from the image. Furthermore, this invention uses an improved ISOMAP algorithm based on grain spheres, which, compared to existing ISOMAP algorithms, improves computational efficiency to a certain extent.
[0093] In one optional embodiment, initializing the feature set as spheres and dividing the spheres into spheres includes the following steps:
[0094] Step S311: Initialize the feature set as a particle gb, and divide the particle gb into particles gb1 and particle gb2;
[0095] Step S312: Calculate the mass of the particle gb, the particle gb1, and the particle gb2 to obtain the mass dm. gb Quality dm gb1 and quality dm gb2 If the mass dm gb Quality dm gb1 and quality dm gb2 If the substitution formula is satisfied, then use particle gb1 and particle gb2 to replace particle gb; otherwise, retain particle gb.
[0096] Step S313: Repeat steps S311 and S312 until no new particles are generated, thus generating a particle set.
[0097] In this embodiment, the mass of the pellet refers to the average distance from the data within the pellet to the center of the pellet, and its calculation formula is as follows:
[0098]
[0099] In an optional embodiment, the substitution formula is expressed as follows:
[0100]
[0101] In the above formula, |gb| represents the number of elements in the current sphere.
[0102] In one alternative embodiment, the formula for calculating the center of each sphere in the sphere set is as follows:
[0103]
[0104] In the above formula, c represents the center of each sphere in the sphere set, info i A one-dimensional feature vector representing a superpixel.
[0105] In one optional embodiment, pruning optimization of the edge set in the adjacency graph includes: dividing the edge set in the adjacency graph into a strongly connected edge set SCC and a weakly connected edge set WCC, retaining the edges belonging to the strongly connected edge set SCC, and deleting the edges belonging to the weakly connected edge set WCC, to obtain the pruned and optimized edge set.
[0106] It should be noted that the set of sphere centers C = {c1, c2, ..., c...} m As input to the ISOMAP algorithm, the k nearest neighbors of each sphere center are calculated, resulting in the adjacency graph G = (C, E); where E represents the edge set, and the edge set E contains element e. ij , element e ij This indicates that the center of the i-th particle and the center of the j-th particle are neighbors. Based on this, the present invention divides the edge set into a strongly connected edge set SCC and a weakly connected edge set WCC, where the edges in SCC represent c. i It is C j k nearest neighbors and c j It is C i The k-nearest neighbors, and the edges in WCC represent c. i and c j In a given set of particles, the k nearest neighbors of the center of each particle do not include the other. Based on the strongly connected edge set SCC and the weakly connected edge set WCC, edges belonging to the strongly connected edge set SCC are retained in edge set E, while edges belonging to the weakly connected edge set WCC are deleted, resulting in the pruned and optimized edge set E. * Calculate the edge set E. * The weight values corresponding to all elements in the array, element e ij The corresponding weight value w ij For the center of the granule c i and the center of the granule c j The L2 norm of the weight matrix is used to integrate all the weight values to obtain the weight matrix W.
[0107] The shortest path matrix D is obtained by calculating the weight matrix W using Dijkstra's algorithm based on Fibonacci heaps. This shortest path matrix D is then used as input to the MDS algorithm. It can be proven from the given conditions that the elements of the inner product matrix B of the target matrix are... Where d ij The elements of the shortest path matrix are given, indicating that solving the target matrix is only related to the shortest path matrix D. The MDS algorithm in this invention is an effective data analysis method that can map high-dimensional data to a low-dimensional space while preserving the relative distance relationships between data points.
[0108] In one optional embodiment, the comprehensive calculation of the eigenvalue matrix and the eigenvector matrix includes the following steps:
[0109] A new eigenvalue matrix is formed by selecting the first p eigenvalues from the eigenvalue matrix, and a new eigenvector matrix is formed by selecting the eigenvectors corresponding to the first p eigenvalues from the eigenvector matrix; where p is the expected dimension.
[0110] The new eigenvalue matrix and the new eigenvector matrix are calculated using the target matrix formula to obtain the target matrix; wherein the target matrix formula is expressed as follows:
[0111]
[0112] In the above formula, Y represents the target matrix, Q * Let Λ represent the new eigenvector matrix. * This represents the new eigenvalue matrix.
[0113] It should be noted that solving for the elements of the inner product matrix B of the target matrix yields the eigenvalue matrix Λ = diag(λ1, λ2, ..., λ). m Given the eigenvector matrix Q, select the first p eigenvalues Λ * =diag(λ1,λ2,···,λ p ) and the corresponding eigenvector matrix Q * , take the first p eigenvalues Λ * and the corresponding eigenvector matrix Q * Through formula The calculation is performed to obtain the target matrix Y.
[0114] In one optional embodiment, clustering the important features using the optimized DPC clustering algorithm includes the following steps:
[0115] Step S41: Calculate the local density of each eigenvector in the target matrix, and divide the target matrix into a high-density set HDS and a low-density set LDS based on the local density;
[0116] Step S42: Calculate the nearest distance between the high-density set HDS and the low-density set LDS using different strategies to obtain the nearest distance of the target matrix and determine the dependency relationship;
[0117] Step S43: Multiply the local density and the nearest distance corresponding to the local density to obtain the density value, and select q points with the highest density values as density peak points;
[0118] Step S44: Assign each feature vector to the cluster containing the nearest density peak point according to the dependency relationship, and obtain the cluster label.
[0119] It should be noted that, in order to avoid calculating the distance between all point pairs, this invention uses an optimized DPC clustering algorithm for clustering. The optimized DPC clustering algorithm is an accelerated density peak clustering algorithm.
[0120] Specifically, it takes the target matrix Y as input and calculates the local density of each eigenvector. The local density is calculated using the reciprocal of the average distance between each feature vector and other feature vectors in its neighborhood, where k * Represents the neighborhood size, y i Let y represent the i-th eigenvector. i j Let j represent the j-th nearest neighbor of the i-th eigenvector.
[0121] Then, considering that when using the density peak clustering algorithm in the decision graph, points with higher local density have a greater impact on the selection of cluster centers, while the impact of other points is relatively smaller, this invention employs different strategies to calculate the nearest distance between high-density sets and low-density sets respectively.
[0122] Next, the density value γ is obtained by multiplying the local density by the nearest distance to the local density. i Its formula is γ i =ρ i ×δ i Select density value γ i The top q points with the highest density are selected as the density peak points. Finally, δ is calculated based on the eigenvectors. i When the value is selected, the dependency relationship is determined. Then, each feature vector is assigned to the cluster where the nearest density peak is located according to the dependency relationship, resulting in a set of cluster labels, denoted as L.
[0123] It's important to note that q is typically set to p, similar to the idea of setting an intrinsic dimension for the number of clusters in spectral clustering. Here, p represents the dimension of the Euclidean embedding. This concept can also be applied to manifold learning.
[0124] In one alternative embodiment, calculating the nearest distance between the high-density set HDS and the low-density set LDS using different strategies includes:
[0125] For the high-density set HDS, the nearest distance calculation formula is as follows:
[0126]
[0127] For the low-density set LDS, the nearest distance calculation formula is as follows:
[0128]
[0129] In the above formula, δ i ρ represents the closest distance. i k represents the local density. * Represents the neighborhood size, y i Let i represent the i-th eigenvector.
[0130] It should be noted that for feature vectors with high local density, it is necessary to calculate the distances to all points with high density, including the nearest distance. For points with low local density, it is sufficient to calculate only the distance to the nearest point with higher density; the closest distance.
[0131] It should be noted that merging the superpixels and clustering labels involves mapping the clustering result L to the corresponding spheres. Feature vectors belonging to the same sphere share the same label. Then, the label is mapped to each feature vector, and combined with the superpixel, the final label for each superpixel is obtained, denoted as L. * .
[0132] After completing the label clustering, superpixels belonging to the same label are labeled with the same color, and finally the segmentation result image of different color blocks is obtained.
[0133] Example 2
[0134] Figure 2 This is a schematic diagram of the structure of an electronic device provided in Embodiment 2 of the present invention, as shown below. Figure 2 As shown, the electronic device includes a processor 21, a memory 22, an input device 23, and an output device 24; the number of processors 21 in the computer device can be one or more. Figure 2 Taking a processor 21 as an example; the processor 21, memory 22, input device 23, and output device 24 in an electronic device can be connected via a bus or other means. Figure 2 Taking the example of a connection between China and Israel via a bus.
[0135] The memory 22, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules. The processor 21 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the memory 22, thereby implementing the image segmentation method based on superpixels and particle spheres as described in Embodiment 1.
[0136] The memory 22 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on terminal usage. Furthermore, the memory 22 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory, or other non-volatile solid-state storage device. In some instances, the memory 22 may further include memory remotely located relative to the processor 21, which can be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0137] Input device 23 can be used to receive user input such as ID and password. Output device 24 is used to output the network configuration page.
[0138] Example 3
[0139] Embodiment 3 of the present invention also provides a computer-readable storage medium, wherein the computer-executable instructions, when executed by a computer processor, are used to implement an image segmentation method based on superpixels and improved based on spheres as provided in Embodiment 1.
[0140] The storage medium containing computer-executable instructions provided in the embodiments of the present invention is not limited to the method operation provided in Embodiment 1, but can also perform related operations in the image segmentation method based on superpixels and based on spheres provided in any embodiment of the present invention.
[0141] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An image segmentation method based on superpixels and improved particle spheres, characterized in that, Includes the following steps: Step S1: Use the SLIC algorithm to perform superpixel segmentation on the image to be segmented to obtain superpixels; Step S2: Extract features from the superpixels to obtain a feature set; Step S3: The feature set is dimensionality reduced using the ISOMAP algorithm based on particle spheres to obtain important features; wherein, the dimensionality reduction of the feature set using the ISOMAP algorithm based on particle spheres includes the following steps: Step S31: Initialize the feature set into spheres, divide the spheres into spheres, and obtain a set of spheres; Step S32: Calculate the center of each particle in the set of particles to obtain the set of particle centers; Step S33: Use the ISOMAP algorithm to calculate the k nearest neighbors of each particle center in the particle center set to obtain an adjacency graph. Perform pruning optimization on the edge set in the adjacency graph and calculate the weight value of the edge set after pruning optimization to obtain a weight matrix. Step S34: Calculate the weight matrix using the Dijkstra algorithm based on Fibonacci heaps to obtain the shortest path matrix; Step S35: Calculate the shortest path matrix using the MDS algorithm to obtain the eigenvalue matrix and eigenvector matrix. Perform a comprehensive calculation on the eigenvalue matrix and the eigenvector matrix to obtain the target matrix. Step S4: Cluster the important features using the optimized DPC clustering algorithm to obtain cluster labels; wherein, clustering the important features using the optimized DPC clustering algorithm includes the following steps: Step S41: Calculate the local density of each eigenvector in the target matrix, and divide the target matrix into a high-density set HDS and a low-density set LDS based on the local density; Step S42: Calculate the nearest distance between the high-density set HDS and the low-density set LDS using different strategies to obtain the nearest distance of the target matrix and determine the dependency relationship; Step S43: Multiply the local density and the nearest distance corresponding to the local density to obtain the density value, and select q points with the highest density values as density peak points; Step S44: Assign each feature vector to the cluster containing the nearest density peak point according to the dependency relationship, and obtain the cluster label; Step S5: Merge the superpixels and cluster labels to generate a segmentation result image.
2. The image segmentation method based on superpixels and improved based on spheres according to claim 1, characterized in that, The SLIC algorithm for superpixel segmentation of the image to be segmented includes the following steps: Step S11: Determine the number of superpixels and the size of the superpixels, obtain the width and height of the image to be segmented, segment the width and height based on the number of superpixels and the size of the superpixels to obtain M×N superpixel blocks of equal size, and take the center point of each superpixel block as the center pixel of the corresponding superpixel block; Step S12: Calculate the color distance and spatial distance between the center pixel of each superpixel block and the surrounding pixels of the center pixel; Step S13: Allocate pixels based on the color distance and the spatial distance, and calculate the average color and average position of all pixels in each superpixel block after allocation; Step S14: Repeat steps S12 and 13 until the stopping condition of the iteration is met.
3. The image segmentation method based on superpixels and improved based on spheres according to claim 1, characterized in that, The feature set is initialized as spheres, and the spheres are divided into spheres, which includes the following steps: Step S311: Initialize the feature set as a particle gb, and divide the particle gb into particles gb1 and particle gb2; Step S312: Calculate the mass of the particle gb, the particle gb1, and the particle gb2 to obtain the mass. ,quality and quality If the mass ,quality and quality If the substitution formula is satisfied, then use particle gb1 and particle gb2 to replace particle gb; otherwise, retain particle gb. Step S313: Repeat steps S311 and S312 until no new particles are generated, thus generating a particle set.
4. The image segmentation method based on superpixels and improved based on spheres according to claim 3, characterized in that, The substitution formula is expressed as follows: In the above formula, This indicates the number of elements in the current sphere.
5. The image segmentation method based on superpixels and improved based on grain spheres according to claim 4, characterized in that, The formula for calculating the center of each sphere in the sphere set is as follows: In the above formula, c represents the center of each sphere in the sphere set. A one-dimensional feature vector representing a superpixel.
6. The image segmentation method based on superpixels and improved based on grain spheres according to claim 1, characterized in that, The pruning optimization of the edge set in the adjacency graph includes: dividing the edge set in the adjacency graph into a strongly connected edge set SCC and a weakly connected edge set WCC, retaining the edges belonging to the strongly connected edge set SCC, and deleting the edges belonging to the weakly connected edge set WCC, to obtain the pruned and optimized edge set.
7. The image segmentation method based on superpixels and improved based on grain spheres according to claim 1, characterized in that, The comprehensive calculation of the eigenvalue matrix and the eigenvector matrix includes the following steps: A new eigenvalue matrix is formed by selecting the first p eigenvalues from the eigenvalue matrix, and a new eigenvector matrix is formed by selecting the eigenvectors corresponding to the first p eigenvalues from the eigenvector matrix; where p is the expected dimension. The new eigenvalue matrix and the new eigenvector matrix are calculated using the target matrix formula to obtain the target matrix; wherein the target matrix formula is expressed as follows: In the above formula, Y represents the target matrix. Represents the new eigenvector matrix. This represents the new eigenvalue matrix.
8. The image segmentation method based on superpixels and improved based on spheres according to claim 1, characterized in that, The formula for calculating the local density is as follows: In the above formula, Indicates local density, Indicates the size of the neighborhood. Indicates the first 1 eigenvector Indicates the first The eigenvector of the th feature vector A close neighbor.
9. The image segmentation method based on superpixels and improved based on spheres according to claim 8, characterized in that, The nearest distance between the high-density set (HDS) and the low-density set (LDS) is calculated using different strategies, including: For the high-density set HDS, the nearest distance calculation formula is as follows: For the low-density set LDS, the nearest distance calculation formula is as follows: In the above formula, Indicates the closest distance. Represents local density. Indicates the size of the neighborhood. Indicates the first 1 eigenvector.
Citation Information
Patent Citations
Color image segmentation method based on improved wavelet clustering
CN110796667A
Database simplification method and system based on granular ball face clustering image quality evaluation
CN114003752A