Automatic image segmentation method based on superpixel and improved fuzzy C-means clustering
By introducing superpixel and density peak clustering into the fuzzy C-means clustering algorithm, the image segmentation process is optimized, the problems of cluster number setting and noise sensitivity are solved, and the efficiency and accuracy of automatic image segmentation are achieved.
Patent Information
- Application Number
- CN202210877458.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-25
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-07-25
AI Technical Summary
The existing fuzzy C-means clustering algorithm requires manual setting of the number of clusters in image segmentation and is sensitive to noise, resulting in slow segmentation speed and low efficiency.
An automatic image segmentation method based on superpixels and improved fuzzy C-means clustering is used to optimize the weighted image by calculating local grayscale changes and spatial distance information. The SLIC algorithm is used to pre-segment the superpixels and automatically determine the clusters through density peak clustering. The number of clusters is finally determined by using the optimized membership degree improved fuzzy C-means clustering algorithm for secondary segmentation.
It improves the computational efficiency of image segmentation, automatically determines the number of clusters, reduces the impact of noise on the segmentation process, and achieves efficient image segmentation without manual intervention.
Smart Images

Figure CN115131566B
Abstract
Description
Technical Field
[0001] The present invention generally relates to the technical field of image processing, and more particularly, to an automatic image segmentation method based on superpixel and improved fuzzy C-means clustering. Background Art
[0002] Clustering algorithm is a very popular research topic in the field of data mining, and it is also an important data analysis technology. Fuzzy clustering is an important branch of clustering algorithm. The most classic method is the Fuzzy C-means (FCM) clustering algorithm. This algorithm takes the objective function as the benchmark, regards the fuzzy clustering problem as a nonlinear programming problem, iteratively minimizes the objective function, and obtains the membership value of each sample data to the cluster center, thereby realizing the fuzzy division of the data set. The fuzzy C-means clustering algorithm has a simple principle, is easy to implement, and can well characterize the uncertainty of sample data classification. Therefore, it is suitable for processing objects with fuzzy characteristics such as images.
[0003] However, there are two obvious disadvantages when using the fuzzy C-means clustering algorithm to segment images. The first is that the number of clusters needs to be set manually and the second is that it is very sensitive to noise. Although the number of clusters can be found by introducing the density peak clustering algorithm, since an image often contains a large number of pixels, the segmentation speed is slow, which reduces the image segmentation efficiency. Summary of the invention
[0004] According to an embodiment of the present invention, an automatic image segmentation scheme based on superpixels and improved fuzzy C-means clustering is provided. This scheme can fully consider the influence of local neighborhood pixels on the center point, and introduce the idea of superpixel blocks into the density peak clustering algorithm, which can effectively improve the calculation efficiency, automatically determine the number of clusters, and use the optimized membership to improve the fuzzy C-means clustering algorithm, and finally achieve image segmentation without manual intervention.
[0005] In a first aspect of the present invention, an automatic image segmentation method based on superpixels and improved fuzzy C-means clustering is provided. The method comprises:
[0006] Select any neighborhood in the target image, calculate the local grayscale change information of the pixels in the neighborhood and the spatial distance information between the pixels in the neighborhood and the central pixel, and count the influence weights of the local grayscale change information and the spatial distance information of the pixels in the neighborhood on the central pixel to obtain an optimized weighted image;
[0007] Pre-segmenting the optimized weighted image using a SLIC algorithm to obtain superpixels;
[0008] Performing density peak clustering on the superpixels to obtain the number of clusters;
[0009] The optimized membership degree is used to improve the fuzzy C-means clustering algorithm, and the superpixel is segmented twice to obtain an image after the second segmentation.
[0010] Further, calculating the local grayscale change information of the pixels in the neighborhood, and counting the influence weights of the local grayscale change information of the pixels in the neighborhood on the central pixel, including:
[0011] Compare the grayscale value of each pixel in the neighborhood with the average grayscale of all pixels in the neighborhood to obtain local grayscale change information; the local grayscale change information is: in, is the local grayscale change information; is the grayscale value of pixel point j in the neighborhood; is a local window centered on pixel i; is the average grayscale of all pixels in the neighborhood, and ,in, For local window The number of pixels in the
[0012] The weight of the influence of the local grayscale change information of the pixels in the neighborhood on the central pixel is: in, The weight of the influence of the local grayscale change information of the pixels in the neighborhood on the central pixel; It is the local grayscale change information.
[0013] Further, calculating the spatial distance information between the pixels in the neighborhood and the central pixel, and controlling the influence weight of the spatial distance information of the pixels in the neighborhood on the central pixel, includes:
[0014] Using a Gaussian kernel function to define the spatial distance information between the pixels in the neighborhood and the central pixel;
[0015] An exponential function is used to control the weight of the spatial distance information of the pixels in the neighborhood to the central pixel; the weight of the spatial distance information is: in, is the weight of the spatial distance information of the pixels in the neighborhood to the central pixel; It is the spatial distance information between the pixels in the neighborhood and the central pixel.
[0016] Furthermore, the optimized weighted image is: in, To optimize the gray value of pixel i in the weighted image; is a local window centered on pixel i; The weight of the influence of the local grayscale change information of the pixels in the neighborhood on the central pixel; is the weight of the spatial distance information of the pixels in the neighborhood to the central pixel; is the grayscale value of pixel j in the neighborhood.
[0017] Furthermore, the method of pre-segmenting the optimized weighted image using the SLIC algorithm to obtain superpixels includes:
[0018] According to the set number of superpixels, seed points are evenly distributed in the optimized weighted image;
[0019] according to , calculate the distance between the centers of two adjacent superpixels ,in, To optimize the total number of pixels of the weighted image, is the number of pre-segmented superpixels;
[0020] The distance between the centers of two adjacent superpixels As the step size, several pixels in the optimized weighted image are uniformly selected as the initial superpixel clustering centers;
[0021] Assign a class label to each pixel in the neighborhood around each seed point, and limit the search range to ;
[0022] according to Compute the distance measure, where is the distance measure; is the gray value difference between pixel i and seed pixel b; is the gray value at pixel i, is the gray value at pixel b, and ; Pixel With seed pixel The spatial distance of ,in and are the horizontal coordinates of two pixels respectively; and are the ordinates of two pixels respectively; is a measure of the compactness index of superpixels, and The larger the value of , the higher the compactness; is the distance between the centers of two adjacent superpixels; the seed point with the minimum distance measure to the pixel is taken as the cluster center of the pixel;
[0023] The superpixel cluster center is iteratively updated until convergence or the preset maximum number of iterations of superpixel clustering is reached, the superpixel segmentation is completed, and a superpixel segmentation image is obtained.
[0024] Further, performing density peak clustering on the superpixel to obtain the number of clusters includes:
[0025] Randomly select two superpixels and calculate the first distance between the two superpixels; the first distance is: in, is the pth superpixel With the qth superpixel The first distance between is the pth superpixel The number of pixels contained in ; is the qth superpixel The number of pixels contained in ; is the pth superpixel The pixels in for q superpixels Pixels in ; Pixel The gray value of Pixel Gray value of
[0026] Calculate the local density of any superpixel and the second distance from the current superpixel to the superpixel with a larger local density and the closest distance; the local density is: in, is the pth superpixel The local density of is the pth superpixel and the qth superpixel The first distance between is the qth superpixel The number of pixels contained in ; is the total number of superpixels, , ; is the cutoff distance;
[0027] The second distance is: in, is the pth superpixel The second distance to the superpixel with greater local density and closest distance; is the pth superpixel The local density of is the qth superpixel The local density of is the pth superpixel and the qth superpixel The first distance between
[0028] With local density As the horizontal axis, the second distance As the vertical axis, generate the first decision diagram , and the first decision graph Normalize and get the second decision graph ,in represents the minimum value, represents the maximum value;
[0029] The second decision diagram Mapping to the third decision diagram , and normalize the third decision graph to obtain a fourth decision graph ;
[0030] Arrange the element values contained in the fourth decision diagram in descending order, calculate the absolute value of the difference between the current element and the next element in turn, and use the index value corresponding to the largest absolute value of the difference as the number of clusters.
[0031] Furthermore, the second decision graph Mapping to the third decision diagram ,include: in, is the total number of superpixels; is the threshold value, and ; For constraints The second decision diagram the number of is the indicator function; The first term is 0, the last term is 1, and the common difference is The arithmetic progression of , is a constant, , .
[0032] Furthermore, the optimized membership improved fuzzy C-means clustering algorithm is used to perform secondary segmentation on the superpixel to obtain the secondary segmented image, including:
[0033] Initialize the membership matrix to obtain an initial membership matrix; the initial membership matrix is: in, is the initial membership matrix; Superpixel The initial membership of the kth cluster; is the number of clusters; is the total number of superpixels;
[0034] according to Calculate the cluster center of each cluster and get the cluster center set ;in, is the cluster center of the kth cluster; Superpixel The degree of membership to the kth cluster; Superpixel The corresponding gray value; is the fuzzy index; is the total number of superpixels;
[0035] according to Calculate each superpixel For the membership of the kth cluster, we get the membership matrix; among them, For the The cluster center, is the kth cluster center; is the fuzzy index; Superpixel The corresponding gray value; is the number of clusters;
[0036] If the termination condition is reached, the membership matrix calculated last time is output; otherwise, the iterative calculation continues;
[0037] After obtaining the membership matrix calculated for the last time, the membership is assigned to each pixel in the target image, a local window of a preset size is selected, and the optimized membership of the central pixel i in the local window to the kth cluster is counted. ,in, is the local window centered at pixel i, is the membership degree of pixel j to the kth cluster in the local window; is a Gaussian kernel function, wherein It is used to reflect the influence of the membership of pixel point j in the local window to the kth cluster on the membership of the central pixel to the kth cluster; re-count each superpixel Optimize the membership of the kth cluster ,in Superpixel The optimized membership of the k-th cluster; is the optimized membership of pixel i to the kth cluster; is the pth superpixel The number of pixels contained in ;
[0038] According to the maximum membership principle, Determine the cluster to which each superpixel belongs and obtain the image after secondary segmentation, where: Superpixel The cluster to which it belongs; Superpixel The optimized membership of the k-th cluster.
[0039] In a second aspect of the present invention, an automatic image segmentation device based on superpixel and improved fuzzy C-means clustering is provided. The device comprises:
[0040] A calculation and statistics module is used to select any neighborhood in the target image, calculate the local grayscale change information of the pixels in the neighborhood and the spatial distance information between the pixels in the neighborhood and the central pixel, and calculate the influence weight of the local grayscale change information and the spatial distance information of the pixels in the neighborhood on the central pixel to obtain an optimized weighted image;
[0041] A pre-segmentation module, used for pre-segmenting the optimized weighted image using a SLIC algorithm to obtain superpixels;
[0042] A clustering module, used for performing density peak clustering on the superpixels to obtain the number of clusters;
[0043] The segmentation module is used to adopt the optimized membership improved fuzzy C-means clustering algorithm to perform secondary segmentation on the superpixel to obtain a secondary segmented image.
[0044] In a third aspect of the present invention, an electronic device is provided. The electronic device has at least one processor; and a memory connected to the at least one processor in communication; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the method of the first aspect of the present invention.
[0045] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The above and other features, advantages and aspects of the embodiments of the present invention will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0047] Figure 1 A flow chart of an automatic image segmentation method based on superpixels and improved fuzzy C-means clustering according to an embodiment of the present invention is shown;
[0048] Figure 2 A flowchart of a pre-segmentation process according to an embodiment of the present invention is shown;
[0049] Figure 3 A flow chart of performing density peak clustering on superpixels according to an embodiment of the present invention is shown;
[0050] Figure 4 A flowchart of performing secondary segmentation of superpixels according to an embodiment of the present invention is shown;
[0051] Figure 5 A schematic diagram showing a segmentation result obtained on a synthetic image containing noise according to an embodiment of the present invention is shown;
[0052] Figure 6 A schematic diagram of a segmentation result obtained on a natural image according to an embodiment of the present invention is shown;
[0053] Figure 7 A schematic diagram of segmentation results obtained on a remote sensing image according to an embodiment of the present invention is shown;
[0054] Figure 8 A schematic structural diagram of an automatic image segmentation system based on superpixels and improved fuzzy C-means clustering according to an embodiment of the present invention is shown;
[0055] Fig. 9 A block diagram of an exemplary electronic device capable of implementing embodiments of the present invention is shown.
[0056] Among them, 900 is an electronic device, 901 is a CPU, 902 is a ROM, 903 is a RAM, 904 is a bus, 905 is an I / O interface, 906 is an input unit, 907 is an output unit, 908 is a storage unit, and 909 is a communication unit. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0059] The present invention can fully consider the influence of local neighborhood pixels on the center point and introduce the idea of superpixel blocks into the density peak clustering algorithm, which can effectively improve the calculation efficiency, automatically determine the number of clusters, and finally realize image segmentation without human intervention.
[0060] Figure 1 A flow chart of an automatic image segmentation method based on superpixels and improved fuzzy C-means clustering according to an embodiment of the present invention is shown.
[0061] The method includes:
[0062] S101. Select any neighborhood in the target image, calculate the local grayscale change information of the pixels in the neighborhood and the spatial distance information between the pixels in the neighborhood and the central pixel, count the influence weights of the local grayscale change information and the spatial distance information of the pixels in the neighborhood on the central pixel, and obtain an optimized weighted image.
[0063] As an embodiment of the present invention, a local window may be established, and an area of the target image corresponding to the local window may be taken as a neighborhood.
[0064] As an embodiment of the present invention, for any neighborhood in the target image, the gray value of each pixel point j in the neighborhood is The average grayscale of all pixels in the neighborhood By comparison, the average gray value difference is obtained as the local gray value change information.
[0065] In this embodiment, the local grayscale change information is: in, is the local grayscale change information; is the gray value of pixel j in the neighborhood; is a local window centered at pixel i, and the size of the local window is ; is the average grayscale value of all pixels in the neighborhood, and ,in, For local window The number of pixels within.
[0066] For areas where grayscale changes are relatively gentle, local grayscale change information The value of is small; for areas where grayscale changes suddenly (such as edges, noise, etc.), the local grayscale change information The value of is large. It can be seen that the local grayscale change information It can reflect the uniformity of the grayscale distribution of pixels in the local neighborhood. When calculating the grayscale value of the central pixel of the local window, For points with larger values, their influence on the grayscale calculation of the central pixel should be reduced, and vice versa, their influence should be increased.
[0067] In view of the fact that the exponential function has a faster decay speed, the exponential function is used to further control the influence weight of the neighborhood pixels. The influence weight of the local grayscale change information of the pixel points in the neighborhood on the central pixel point is: in, The weight of the influence of the local grayscale change information of the pixels in the neighborhood on the central pixel; It is the local grayscale change information.
[0068] As an embodiment of the present invention, calculating the spatial distance information between the pixels in the neighborhood and the central pixel, and controlling the influence weight of the spatial distance information of the pixels in the neighborhood on the central pixel, includes:
[0069] The Gaussian kernel function is used to define the spatial distance information between the pixels in the neighborhood and the central pixel. Specifically, a Gaussian kernel function with a standard deviation of 2 and a size of Gaussian kernel function To define a local window The spatial distance between the inner neighborhood pixel and the central pixel. The smaller the value, the greater the distance between the neighborhood pixel and the central pixel. The larger the value, the smaller the distance between the neighborhood pixel and the central pixel.
[0070] In view of the fact that the exponential function has a faster decay speed, the exponential function is used to control the influence weight of the spatial distance information of the pixels in the neighborhood on the central pixel.
[0071] The spatial distance information influence weight is: in, is the weight of the spatial distance information of the pixels in the neighborhood to the central pixel; is the spatial distance information between the pixel points in the neighborhood and the central pixel point, which is calculated by the Gaussian kernel function ,and .
[0072] Furthermore, the weight of the local neighborhood pixel to the central pixel is fully weighed by combining the local grayscale change information and the spatial change information to obtain an optimized weighted image. The optimized weighted image is: in, To optimize the value of pixel i in the weighted image; is a local window centered on pixel i; The weight of the influence of the local grayscale change information of the pixels in the neighborhood on the central pixel; is the weight of the spatial distance information of the pixels in the neighborhood to the central pixel; is the grayscale value of pixel j in the neighborhood.
[0073] The embodiment of the present invention uses local grayscale changes and spatial information to calculate the influence weight of neighborhood pixels on the center point in a local window to obtain an optimized weighted image; as a preprocessing step for the original image, the influence of local neighborhood pixels on the center point is fully considered, the influence of noise points on the image segmentation process is effectively reduced, and the image segmentation accuracy is improved.
[0074] S102: Pre-segment the optimized weighted image using the SLIC algorithm to obtain superpixels.
[0075] As an embodiment of the present invention, Figure 2 As shown, the pre-segmentation process includes:
[0076] S201 . Preset the number of superpixels, and evenly distribute seed points in the optimized weighted image according to the set number of superpixels.
[0077] S202, according to , calculate the distance between the centers of two adjacent superpixels ;in, To optimize the total number of pixels of the weighted image, is the number of pre-segmented superpixels, and .
[0078] S203, the distance between the centers of the two adjacent super pixels As the step size, several pixels in the optimized weighted image are uniformly selected as the initial superpixel clustering centers.
[0079] S204: assign a class label to each pixel point in the neighborhood around each seed point, and limit the search range to .
[0080] S205, according to Compute the distance measure, where is the distance measure; is the gray value difference between pixel i and seed pixel b; is the gray value at pixel i, is the gray value at pixel b, and ; Pixel With seed pixel The spatial distance of ,in and are the horizontal coordinates of two pixels respectively; and are the ordinates of two pixels respectively; is a measure of the compactness index of superpixels, and , The larger the value of , the higher the compactness; is the distance between the centers of two adjacent superpixels; and the seed point with the minimum distance measure to the pixel is taken as the cluster center of the pixel.
[0081] S206, iterate the above S202 to S205, and update the superpixel cluster center until convergence or reaching a preset maximum number of iterations of superpixel clustering, such as 10 times.
[0082] S103: Perform density peak clustering on the superpixels to obtain the number of clusters.
[0083] In this embodiment, if Figure 3 As shown, the superpixels are clustered by density peaks to obtain the number of clusters, including:
[0084] S301. Randomly select two superpixels and calculate a first distance between the two superpixels.
[0085] The first distance is: in, is the pth superpixel With the qth superpixel The first distance between is the pth superpixel The number of pixels contained in ; is the qth superpixel The number of pixels contained in ; is the pth superpixel The pixels in for q superpixels Pixels in ; Pixel The gray value of Pixel The gray value of .
[0086] S302, calculating the local density of any superpixel and the second distance from the current superpixel to the superpixel with a larger local density and the closest distance.
[0087] Specifically, the local density is: in, is the pth superpixel The local density of is the pth superpixel and the qth superpixel The first distance between is the qth superpixel The number of pixels contained in ; is the total number of superpixels, , ; is the cutoff distance;
[0088] The second distance is: in, is the pth superpixel The second distance to the superpixel with greater local density and closest distance; is the pth superpixel With the qth superpixel The first distance between is the pth superpixel The local density of is the qth superpixel The local density of .
[0089] S303, local density As the horizontal axis, the second distance As the vertical axis, generate a first decision diagram; Normalize and get the second decision graph .
[0090] The first decision diagram ;
[0091] The second decision diagram in, represents the minimum value, Represents the maximum value.
[0092] S304: The second decision graph Mapping to the third decision diagram , and normalize the third decision diagram to obtain a fourth decision diagram.
[0093] Specifically, the second decision graph Mapping to the third decision diagram ,include: in, is the total number of superpixels; is the threshold value, and ; For constraints The second decision diagram the number of is the indicator function; The first term is 0, the last term is 1, and the common difference is The arithmetic progression of , is a constant, , .
[0094] The fourth decision diagram .
[0095] S305, the fourth decision diagram Arrange the element values contained in from large to small, calculate the absolute value of the difference between the current element and the next element in turn, and use the index value corresponding to the largest absolute value of the difference as the number of clusters. To express.
[0096] By introducing the idea of superpixel blocks into the density peak clustering algorithm, the use of superpixel blocks can effectively improve the computational efficiency of the density peak clustering algorithm compared to pixel points, obtain image prior information, automatically determine the number of clusters, and use it as the input for subsequent clustering.
[0097] S104, using the optimized membership improved fuzzy C-means clustering algorithm to perform secondary segmentation on the superpixel to obtain a secondary segmented image.
[0098] As an embodiment of the present invention, Figure 4 As shown, the superpixel is segmented twice, specifically including:
[0099] S401, initializing a membership matrix to obtain an initial membership matrix.
[0100] The initial membership matrix is: in, is the initial membership matrix; Superpixel The initial membership of the kth cluster; is the number of clusters; is the total number of superpixels.
[0101] S402: Calculate the cluster center of each cluster to obtain a cluster center set .
[0102] The calculation of the cluster center of each cluster includes: in, is the cluster center of the kth cluster; Superpixel The degree of membership to the kth cluster; Superpixel The corresponding gray value; is the fuzzy index, and ; is the total number of superpixels.
[0103] S403, calculating each superpixel For the membership of the kth cluster, we get the membership matrix.
[0104] The calculation of each superpixel The membership degree of the k-th cluster includes: in Superpixel The degree of membership to the kth cluster; For the The cluster center, is the kth cluster center; Superpixel The corresponding gray value; is the fuzzy index; is the number of clusters.
[0105] The above S401 to S403 are iterated cyclically. If the termination condition is reached, the membership matrix calculated for the last time is output; otherwise, the iterative calculation continues.
[0106] In this embodiment, the termination condition is: or the current iteration number ,in, is the iteration termination threshold, and ; is the maximum number of iterations, and .
[0107] S404, after obtaining the membership matrix calculated for the last time, assign the membership to each pixel in the target image; optimize the membership of each pixel to the kth cluster using a Gaussian kernel function, and then optimize the membership of each superpixel to the kth cluster. The membership of pixels belonging to the same superpixel to the kth cluster is also the same.
[0108] Select a local window of a preset size and count the membership of the central pixel i in the local window to the kth cluster. The size of the preset local window is ; The optimized membership of the central pixel i in the local window to the kth cluster is: in, In pixels is the local window centered on is the membership degree of pixel j to the kth cluster in the local window; is a standard deviation of 2 and a size of The Gaussian kernel function It is used to reflect the influence of the membership of pixel j in the local window to the kth cluster on the membership of the central pixel to the kth cluster. The larger the distance between the neighboring pixel and the central pixel in the local window, the greater the Gaussian kernel function. The smaller the value, the closer the neighboring pixels are to the central pixel. The smaller the distance between the neighborhood pixel and the central pixel in the local window, the smaller the influence on the membership value of the kth cluster; when the distance between the neighborhood pixel and the central pixel in the local window is, the Gaussian kernel function The larger the value of , the greater the influence of the neighborhood pixel's membership to the k-th cluster on the value of the central pixel's membership to the k-th cluster.
[0109] Based on this, re-count each superpixel Optimized membership for the kth cluster: in, Superpixel The optimized membership of the k-th cluster; is the optimized membership of pixel i to the kth cluster; is the pth superpixel The number of pixels contained in .
[0110] S405 . According to the maximum membership principle, determine the cluster to which each superpixel belongs, and obtain the image after secondary segmentation.
[0111] Determining the cluster to which each superpixel belongs includes: in, Superpixel The cluster to which it belongs; Superpixel The optimized membership of the k-th cluster.
[0112] The present invention adopts the fuzzy C-means clustering algorithm with membership optimization to perform post-segmentation on each superpixel, thereby realizing image segmentation, and has strong application flexibility. In the image segmentation process, it can more accurately and effectively identify noise points, improve the segmentation accuracy, and automatically determine the number of clusters without manual input.
[0113] In some optional implementation scenarios of this embodiment, such as Figure 5 The figure shows the segmentation result obtained by the present invention on the synthetic image containing noise, wherein Figure 5 (a) is a synthetic image containing noise. Figure 5 (b) is a segmented image obtained on a synthetic image containing noise. It can be seen that when segmenting a synthetic image containing noise, the present invention can effectively identify noise points, ensure the clarity of the boundary, and obtain a good segmentation result.
[0114] In some optional implementation scenarios of this embodiment, such as Figure 6The figure shows the segmentation result obtained by the present invention on a natural image. Figure 6 (a) is a natural image, Figure 6 (b) is a segmented image obtained on a natural image. It can be seen that the present invention can effectively extract the target contour when segmenting a natural image containing a large number of noise points, and obtain a good segmentation result.
[0115] In some optional implementation scenarios of this embodiment, such as Figure 7 Shown is the segmentation result obtained by the present invention on the remote sensing image. Figure 7 (a) is a remote sensing image, Figure 7 (b) is a segmented image obtained on a remote sensing image. It can be seen that when segmenting a remote sensing image containing noise, the present invention obtains a smooth segmentation result while maintaining clear boundaries.
[0116] According to the embodiments of the present invention, the local grayscale changes and spatial information of the image are fully considered, and the influence of the local neighborhood points on the central point can be more fully measured. As a preprocessing step for the original image, it can effectively reduce the influence of noise points on the image segmentation process and improve the image segmentation accuracy.
[0117] According to an embodiment of the present invention, the superpixel concept is introduced to improve the density peak clustering algorithm, which effectively improves the calculation efficiency, obtains image prior information, and sets the number of clusters based on it without manual intervention.
[0118] According to the embodiment of the present invention, the membership degree in the fuzzy C-means clustering algorithm is optimized, so that noise points can be identified more accurately and the segmentation accuracy is improved.
[0119] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0120] The above is an introduction to a method embodiment. The following is a further explanation of the solution of the present invention through an apparatus embodiment.
[0121] like Figure 8 As shown, the device 800 includes:
[0122] A calculation and statistics module 810 is used to select any neighborhood in the target image, calculate the local grayscale change information of the pixels in the neighborhood and the spatial distance information between the pixels in the neighborhood and the central pixel, and calculate the influence weight of the local grayscale change information and the spatial distance information of the pixels in the neighborhood on the central pixel to obtain an optimized weighted image;
[0123] A pre-segmentation module 820 is used to pre-segment the optimized weighted image using a SLIC algorithm to obtain superpixels;
[0124] A clustering module 830 is used to perform density peak clustering on the superpixels to obtain the number of clusters;
[0125] The segmentation module 840 is used to use the optimized membership improved fuzzy C-means clustering algorithm to perform secondary segmentation on the superpixel to obtain a secondary segmented image.
[0126] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the described module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0127] In the technical solution of the present invention, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0128] According to an embodiment of the present invention, the present invention further provides an electronic device.
[0129] Fig. 9 A schematic block diagram of an electronic device 900 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0130] The device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0131] A number of components in the device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0132] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as methods S101 to S104. For example, in some embodiments, methods S101 to S104 may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the methods S101 to S104 described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to execute methods S101 - S104 in any other appropriate manner (eg, by means of firmware).
[0133] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0134] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0135] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0136] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0137] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0138] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0139] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0140] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An automatic image segmentation method based on superpixels and improved fuzzy C-means clustering, characterized in that: include: Select any neighborhood in the target image, calculate the local grayscale change information of the pixels in the neighborhood and the spatial distance information between the pixels in the neighborhood and the central pixel, and count the influence weights of the local grayscale change information and the spatial distance information of the pixels in the neighborhood on the central pixel to obtain an optimized weighted image; Pre-segmenting the optimized weighted image using a SLIC algorithm to obtain superpixels; Performing density peak clustering on the superpixels to obtain the number of clusters; Using the optimized membership improved fuzzy C-means clustering algorithm, the superpixel is secondary segmented to obtain a secondary segmented image; Performing density peak clustering on the superpixel to obtain the number of clusters includes: Randomly select two superpixels and calculate the first distance between the two superpixels; the first distance is: in, is the pth superpixel With the qth superpixel The first distance between is the pth superpixel The number of pixels contained in is the qth superpixel The number of pixels contained in ; is the pth superpixel The pixels in for q superpixels Pixels in ; Pixel The gray value of Pixel Gray value of Calculate the local density of any superpixel and the second distance from the current superpixel to the superpixel with a larger local density and the closest distance; the local density is: in, is the pth superpixel The local density of is the pth superpixel and the qth superpixel The first distance between is the qth superpixel The number of pixels contained in ; is the total number of superpixels, , ; is the cutoff distance; The second distance is: in, is the pth superpixel The second distance to the superpixel with greater local density and closest distance; is the pth superpixel The local density of is the qth superpixel The local density of is the pth superpixel and the qth superpixel The first distance between With local density As the horizontal axis, the second distance As the vertical axis, generate the first decision diagram , and the first decision graph Normalize and get the second decision graph ,in represents the minimum value, represents the maximum value; The second decision diagram Mapping to the third decision diagram , and normalize the third decision graph to obtain a fourth decision graph ; Arrange the element values contained in the fourth decision diagram in descending order, calculate the absolute value of the difference between the current element and the next element in turn, and use the index value corresponding to the largest absolute value of the difference as the number of clusters; The second decision diagram Mapping to the third decision diagram ,include: in, is the total number of superpixels; is the threshold value, and ; For constraints The second decision diagram the number of is the indicator function; The first term is 0, the last term is 1, and the common difference is The arithmetic progression of , is a constant, , ; The method adopts the optimized membership improved fuzzy C-means clustering algorithm to perform secondary segmentation on the superpixel to obtain the secondary segmented image, including: Initialize the membership matrix to obtain an initial membership matrix; the initial membership matrix is: in, is the initial membership matrix; Superpixel The initial membership of the kth cluster; is the number of clusters; is the total number of superpixels; according to Calculate the cluster center of each cluster and get the cluster center set ;in, is the cluster center of the kth cluster; Superpixel The degree of membership to the kth cluster; Superpixel The corresponding gray value; is the fuzzy index; is the total number of superpixels; according to Calculate each superpixel For the membership of the kth cluster, we get the membership matrix; among them, For the Cluster centers, is the kth cluster center; Superpixel The corresponding gray value; is the number of clusters; is the fuzzy index; If the termination condition is reached, the membership matrix calculated last time is output; otherwise, the iterative calculation continues; After obtaining the membership matrix calculated for the last time, the membership is assigned to each pixel in the target image, a local window of a preset size is selected, and the optimized membership of the central pixel i in the local window to the kth cluster is counted: in, is a local window centered at pixel i, is the membership degree of pixel j to the kth cluster in the local window; is a Gaussian kernel function, wherein It is used to reflect the influence of the membership of pixel point j in the local window to the k-th cluster on the membership of the central pixel to the k-th cluster; Re-count each superpixel Optimize the membership of the kth cluster: in Superpixel The optimized membership of the k-th cluster; Pixel The optimized membership of the k-th cluster; is the pth superpixel The number of pixels contained in ; According to the maximum membership principle, Determine the cluster to which each superpixel belongs and obtain the image after secondary segmentation, where: Superpixel The cluster to which it belongs; Superpixel The optimized membership of the k-th cluster.
2. The method according to claim 1, characterized in that: Calculating the local grayscale change information of the pixels in the neighborhood, and counting the influence weights of the local grayscale change information of the pixels in the neighborhood on the central pixel, including: Compare the grayscale value of each pixel in the neighborhood with the average grayscale of all pixels in the neighborhood to obtain local grayscale change information; the local grayscale change information is: in, is the local grayscale change information; is the gray value of pixel j in the neighborhood; is a local window centered on pixel i; is the average grayscale of all pixels in the neighborhood, and ,in, For local window The number of pixels in the The weight of the influence of the local grayscale change information of the pixels in the neighborhood on the central pixel is: in, The weight of the influence of the local grayscale change information of the pixels in the neighborhood on the central pixel; It is the local grayscale change information.
3. The method according to claim 1, characterized in that Calculating the spatial distance information between the pixels in the neighborhood and the central pixel, and controlling the influence weight of the spatial distance information of the pixels in the neighborhood on the central pixel, including: Using a Gaussian kernel function to define the spatial distance information between the pixels in the neighborhood and the central pixel; An exponential function is used to control the weight of the spatial distance information of the pixels in the neighborhood to the central pixel; the weight of the spatial distance information is: in, is the weight of the spatial distance information of the pixels in the neighborhood to the central pixel; It is the spatial distance information between the pixels in the neighborhood and the central pixel.
4. The method according to claim 2 or 3, characterized in that: The optimized weighted image is: in, To optimize the gray value of pixel i in the weighted image; is a local window centered on pixel i; The weight of the influence of the local grayscale change information of the pixels in the neighborhood on the central pixel; is the weight of the spatial distance information of the pixels in the neighborhood to the central pixel; is the grayscale value of pixel j in the neighborhood.
5. The method according to claim 1, characterized in that The method of pre-segmenting the optimized weighted image by using the SLIC algorithm to obtain superpixels includes: According to the set number of superpixels, seed points are evenly distributed in the optimized weighted image; according to , calculate the distance between the centers of two adjacent superpixels ,in, To optimize the total number of pixels of the weighted image, is the number of pre-segmented superpixels; The distance between the centers of two adjacent superpixels As the step size, several pixels in the optimized weighted image are uniformly selected as the initial superpixel clustering centers; Assign a class label to each pixel in the neighborhood around each seed point, and limit the search range to ; according to Compute the distance measure, where is the distance measure; Pixel With seed pixel Gray value difference; is the gray value at pixel i, is the gray value at pixel b, and ; Pixel With seed pixel The spatial distance of ,in and are the horizontal coordinates of two pixels respectively; and are the ordinates of two pixels respectively; is a measure of the compactness index of superpixels, and The larger the value of , the higher the compactness; is the distance between the centers of two adjacent superpixels; the seed point with the minimum distance measure to the pixel is taken as the cluster center of the pixel; The superpixel cluster center is iteratively updated until convergence or the preset maximum number of iterations of superpixel clustering is reached, the superpixel segmentation is completed, and a superpixel segmentation image is obtained.
6. An automatic image segmentation device based on improved fuzzy C-means clustering, characterized in that: include: A calculation and statistics module is used to select any neighborhood in the target image, calculate the local grayscale change information of the pixels in the neighborhood and the spatial distance information between the pixels in the neighborhood and the central pixel, and calculate the influence weight of the local grayscale change information and the spatial distance information of the pixels in the neighborhood on the central pixel to obtain an optimized weighted image; A pre-segmentation module, used for pre-segmenting the optimized weighted image using a SLIC algorithm to obtain superpixels; A clustering module, used for performing density peak clustering on the superpixels to obtain the number of clusters; A segmentation module, used to perform secondary segmentation on the superpixel by using an optimized membership improved fuzzy C-means clustering algorithm to obtain a secondary segmented image; Performing density peak clustering on the superpixel to obtain the number of clusters includes: Randomly select two superpixels and calculate the first distance between the two superpixels; the first distance is: in, is the pth superpixel With the qth superpixel The first distance between is the pth superpixel The number of pixels contained in is the qth superpixel The number of pixels contained in ; is the pth superpixel The pixels in for q superpixels Pixels in ; Pixel The gray value of Pixel Gray value of Calculate the local density of any superpixel and the second distance from the current superpixel to the superpixel with a larger local density and the closest distance; the local density is: in, is the pth superpixel The local density of is the pth superpixel and the qth superpixel The first distance between is the qth superpixel The number of pixels contained in ; is the total number of superpixels, , ; is the cutoff distance; The second distance is: in, is the pth superpixel The second distance to the superpixel with greater local density and closest distance; is the pth superpixel The local density of is the qth superpixel The local density of is the pth superpixel and the qth superpixel The first distance between With local density As the horizontal axis, the second distance As the vertical axis, generate the first decision diagram , and the first decision graph Normalize and get the second decision graph ,in represents the minimum value, represents the maximum value; The second decision diagram Mapping to the third decision diagram , and normalize the third decision graph to obtain a fourth decision graph ; Arrange the element values contained in the fourth decision diagram in descending order, calculate the absolute value of the difference between the current element and the next element in turn, and use the index value corresponding to the largest absolute value of the difference as the number of clusters; The second decision diagram Mapping to the third decision diagram ,include: in, is the total number of superpixels; is the threshold value, and ; For constraints The second decision diagram the number of is the indicator function; The first term is 0, the last term is 1, and the common difference is The arithmetic progression of , is a constant, , ; The method adopts the optimized membership improved fuzzy C-means clustering algorithm to perform secondary segmentation on the superpixel to obtain the secondary segmented image, including: Initialize the membership matrix to obtain an initial membership matrix; the initial membership matrix is: in, is the initial membership matrix; Superpixel The initial membership of the kth cluster; is the number of clusters; is the total number of superpixels; according to Calculate the cluster center of each cluster and get the cluster center set ;in, is the cluster center of the kth cluster; Superpixel The degree of membership to the kth cluster; Superpixel The corresponding gray value; is the fuzzy index; is the total number of superpixels; according to Calculate each superpixel For the membership of the kth cluster, we get the membership matrix; among them, For the Cluster centers, is the kth cluster center; Superpixel The corresponding gray value; is the number of clusters; is the fuzzy index; If the termination condition is reached, the membership matrix calculated last time is output; otherwise, the iterative calculation continues; After obtaining the membership matrix calculated for the last time, the membership is assigned to each pixel in the target image, a local window of a preset size is selected, and the optimized membership of the central pixel i in the local window to the kth cluster is counted: in, is a local window centered at pixel i, is the membership degree of pixel j to the kth cluster in the local window; is a Gaussian kernel function, wherein It is used to reflect the influence of the membership of pixel point j in the local window to the k-th cluster on the membership of the central pixel to the k-th cluster; Re-count each superpixel Optimize the membership of the kth cluster: in Superpixel The optimized membership of the k-th cluster; Pixel The optimized membership of the k-th cluster; is the pth superpixel The number of pixels contained in ; According to the maximum membership principle, Determine the cluster to which each superpixel belongs and obtain the image after secondary segmentation, where: Superpixel The cluster to which it belongs; Superpixel The optimized membership of the k-th cluster.
7. An electronic device comprising at least one processor; and A memory communicatively connected to the at least one processor; characterized in that The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
