K-means bridge surface defect segmentation method and system based on improved sparrow search algorithm optimization
Patent Information
- Application Number
- CN202611471003.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-21
- Publication Date
- 2026-10-27
AI Technical Summary
然而K-means算法的聚类结果高度依赖于初始聚类中心的选择,若初始聚类中心选取不当,算法极易收敛至局部最优解,导致分割效果不理想
[0036]1、本发明通过改进帐篷混沌映射引入随机变量,有效避免了帐篷映射陷入小周期点和不稳定周期点的问题,使初始种群分布更加均匀多样,提高了算法的全局搜索能力。
Smart Images

Figure CN122989765A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing and algorithm optimization technology, specifically to a K-means bridge surface defect segmentation method and system based on an improved sparrow search algorithm. Background Technology
[0002] Automatic detection and segmentation of bridge surface defects is a crucial aspect of bridge safety assessment and maintenance. Common bridge surface defects include cracks, honeycombing, spalling, exposed reinforcement, and potholes. Timely detection and accurate location of these defects are of great significance for ensuring the structural safety of bridges.
[0003] Currently, bridge surface defect detection mainly relies on manual visual inspection. This method requires extensive engineering experience, is labor-intensive, has low detection efficiency, and struggles to guarantee the objectivity and consistency of the results. With the development of computer vision technology, image processing-based automatic bridge defect detection methods have gradually attracted researchers' attention. The K-means algorithm, a classic unsupervised image segmentation method, is widely used in image segmentation due to its simple principle and high computational efficiency. However, the clustering results of the K-means algorithm are highly dependent on the selection of initial cluster centers. If the initial cluster centers are not properly selected, the algorithm is prone to convergence to local optima, resulting in unsatisfactory segmentation results. While the sparrow search algorithm has advantages such as fewer parameters and faster convergence speed, it suffers from reduced population diversity and a tendency to get trapped in local optima when approaching the global optimum.
[0004] Therefore, there is an urgent need for a method that can effectively optimize the initial cluster centers of K-means and improve the segmentation accuracy of bridge surface defect images. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to address the shortcomings of the prior art by providing a K-means bridge surface defect segmentation method and system based on an improved sparrow search algorithm.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0007] The K-means bridge surface defect segmentation method based on the improved sparrow search algorithm includes the following steps:
[0008] Step S1: Obtain images of surface defects on the bridge and construct a K-means image segmentation model;
[0009] Step S2: Construct an improved sparrow search algorithm and initialize the population, set the algorithm parameters. The improved sparrow search algorithm includes an optimized tent chaotic perturbation strategy, a Cauchy mutation perturbation strategy, an improved discoverer position update method, and an adaptive adjustment strategy for discoverers and followers.
[0010] Step S3: Iteratively optimize the initial cluster centers of K-means using the improved sparrow search algorithm, and output the optimal initial cluster centers;
[0011] Step S4: Use the optimal initial cluster centers as the initial input of the K-means algorithm, perform K-means clustering iterations until convergence, and obtain the TCSSA-Kmeans image segmentation model;
[0012] Step S5: Input the bridge surface defect image into the TCSSA-Kmeans image segmentation model and output the bridge surface defect image segmentation result.
[0013] Furthermore, in step S1, the bridge surface defect image includes at least one of cracks, honeycombing, spalling, exposed reinforcement, and potholes.
[0014] Further, in step S2, the optimized tent chaos perturbation strategy is as follows: a random variable is introduced into the original tent chaos mapping. When the chaotic sequence value is greater than or equal to 0 and less than or equal to 0.5, the chaotic sequence value of the next iteration is equal to twice the current chaotic sequence value plus the product of the random variable and the reciprocal of the total number of particles; when the chaotic sequence value is greater than 0.5 and less than or equal to 1, the chaotic sequence value of the next iteration is equal to twice 1 minus the current chaotic sequence value plus the product of the random variable and the reciprocal of the total number of particles.
[0015] Furthermore, in step S2, the Cauchy mutation perturbation strategy is as follows: the position of the mutated individual is equal to the original individual position multiplied by 1 plus the tangent function value, where the independent variable of the tangent function is the difference between π multiplied by a random number and 0.5.
[0016] Further, in step S2, the improved discoverer position update method is as follows: when the warning value is less than the safety threshold, the updated discoverer position is equal to the current position multiplied by 2 and divided by the exponential function value, where the exponent of the exponential function is negative 4 times the discoverer index divided by the square of the product of the random parameter and the maximum number of iterations; when the warning value is greater than or equal to the safety threshold, the updated discoverer position is equal to the current position plus the random number vector.
[0017] Further, in step S2, the adaptive adjustment strategy for discoverers and followers is as follows: the number of discoverers is equal to the difference between the sparrow population size multiplied by the scaling factor multiplied by the tangent function value and the perturbation bias factor multiplied by the random number, where the independent variable of the tangent function is negative π multiplied by the current iteration number divided by 4 times the maximum iteration number plus 4 / π; the number of followers is equal to the difference between the sparrow population size multiplied by 1 minus the difference between the scaling factor multiplied by the tangent function value and the perturbation bias factor multiplied by the random number, where the independent variable of the tangent function is negative π multiplied by the current iteration number divided by 4 times the maximum iteration number plus 4 / π.
[0018] Furthermore, step S3 specifically includes the following steps:
[0019] Step S3.1: Calculate the population fitness function value and update the optimal individual;
[0020] Step S3.2: Perform the discoverer position update according to the improved discoverer position update method, and perform the follower position update and the vigilant position update in parallel;
[0021] Step S3.3: Calculate the fitness value and the average fitness value, and determine whether the fitness value of each individual is less than the average fitness value. If it is less, execute the Cauchy mutation perturbation strategy; otherwise, execute the optimized tent chaotic perturbation strategy to update the individual after mutation perturbation into a new generation of individuals.
[0022] Step S3.4: Determine if the current iteration number is less than the maximum iteration number. If it is less, return to step S3.1 to continue iterating; otherwise, output the optimal initial cluster center.
[0023] Furthermore, in step S3.1, the population fitness function is a K-means loss function, which is equal to the sum of the squared Euclidean distances between each sample point and its cluster center. The optimization objective of the improved sparrow search algorithm is to minimize the loss function.
[0024] Furthermore, step S4 specifically includes the following steps:
[0025] Step S4.1: Use the optimal initial cluster centers as the initial input of the K-means algorithm to calculate the Euclidean distance from the cluster points to the cluster centers;
[0026] Step S4.2: Calculate the category of each sample based on the minimum distance principle, that is, assign the sample to the cluster containing the nearest cluster center;
[0027] Step S4.3: Update cluster centers and segmentation distances;
[0028] Step S4.4: Determine whether the cluster centers have converged. If they have not converged, return to step S4.1 to continue iterating. If they have converged, output the optimization result and obtain the TCSSA-Kmeans image segmentation model.
[0029] A K-means bridge surface defect segmentation system based on an improved sparrow search algorithm is provided to implement any of the K-means bridge surface defect segmentation methods based on an improved sparrow search algorithm, including:
[0030] Image acquisition module, used to acquire images of surface defects on bridges;
[0031] The model building module is used to build K-means image segmentation models;
[0032] The algorithm construction and initialization module is used to construct the improved sparrow search algorithm and initialize the population and algorithm parameters;
[0033] The iterative optimization module is used to iteratively optimize the initial cluster centers of K-means using an improved sparrow search algorithm until the maximum number of iterations is reached and the optimal initial cluster centers are output.
[0034] The clustering and segmentation module is used to take the optimal initial cluster centers as the initial input of K-means, iteratively calculate the distance from the cluster points to the cluster centers, update the cluster centers and segmentation distances until convergence, and output the segmentation results of the bridge surface defect image.
[0035] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0036] 1. This invention introduces random variables by improving the tent chaotic mapping, which effectively avoids the problem of the tent mapping getting stuck in small periodic points and unstable periodic points, making the initial population distribution more uniform and diverse, and improving the global search capability of the algorithm.
[0037] 2. This invention improves the discoverer position update method, achieving a smooth transition between the early-stage fast global search and the later-stage fine local search, thereby enhancing the algorithm's optimization accuracy and convergence speed.
[0038] 3. This invention introduces the Cauchy mutation perturbation strategy, which utilizes the nonlinear characteristics of the tangent function to effectively avoid the algorithm getting trapped in local optima while maintaining population diversity.
[0039] 4. This invention proposes an adaptive adjustment strategy for discoverers and followers, realizing a dynamic transition from global exploration to local development, which improves the overall convergence accuracy and speed of the algorithm.
[0040] 5. This invention combines the improved sparrow search algorithm with K-means, which solves the problem that the K-means algorithm is sensitive to the initial cluster center and is prone to getting trapped in local optima, thus improving the segmentation quality of bridge surface defect images. Attached Figure Description
[0041] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0042] Figure 1 This is a flowchart illustrating an embodiment of the present invention;
[0043] Figure 2 This is a system schematic diagram according to an embodiment of the present invention;
[0044] Figure 3 This is a comparison diagram of defect image segmentation results according to an embodiment of the present invention;
[0045] Figure 4 This is a flowchart of the TCSSA-Kmeans image segmentation process according to an embodiment of the present invention. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0047] like Figure 1 As shown, the K-means bridge surface defect segmentation method optimized based on the improved sparrow search algorithm includes the following steps:
[0048] Step S1: Obtain images of surface defects on the bridge and construct a K-means image segmentation model;
[0049] Step S2: Construct an improved sparrow search algorithm and initialize the population, set the algorithm parameters. The improved sparrow search algorithm includes an optimized tent chaotic perturbation strategy, a Cauchy mutation perturbation strategy, an improved discoverer position update method, and an adaptive adjustment strategy for discoverers and followers.
[0050] Step S3: Iteratively optimize the initial cluster centers of K-means using the improved sparrow search algorithm, and output the optimal initial cluster centers;
[0051] Step S4: Use the optimal initial cluster centers as the initial input of the K-means algorithm, perform K-means clustering iterations until convergence, and obtain the TCSSA-Kmeans image segmentation model;
[0052] Step S5: Input the bridge surface defect image into the TCSSA-Kmeans image segmentation model and output the bridge surface defect image segmentation result.
[0053] In step S1, the bridge surface defect image includes at least one of cracks, honeycombing, spalling, exposed reinforcement, and potholes.
[0054] Images of bridge surface defects, such as cracks, honeycombing, spalling, exposed rebar, and potholes, are acquired through on-site photography. A K-means image segmentation model is constructed. When segmenting images, the K-means algorithm is based on pixel features such as grayscale, texture, shape, and color. These pixel features exhibit similarity within the same region but significant differences between different regions. Ultimately, regions with unique properties are segmented from the image. Assume an unlabeled dataset exists. , Given the total number of samples, the dataset is clustered into K clusters. Cluster center is defined as ;
[0055] To determine whether the optimal clustering result has been achieved, a loss function needs to be introduced. The loss function represents the sum of squared distances between each sample and its corresponding cluster center. When the loss function reaches its minimum value, the K-means algorithm achieves its theoretically optimal clustering result. The specific formula is as follows:
[0056]
[0057] in, The loss function is the sum of the squared distances between each sample and the center of its cluster. Represents the r-th sample point, This represents the feature vector of the r-th sample point. Let q be the q-th cluster. Let q be the cluster center vector. Represents sample points With cluster center The square of the Euclidean distance between them.
[0058] When optimizing K-means using the improved Sparrow Search Algorithm TCSSA, the cluster centers are used as the optimization variables of the sparrow algorithm. After optimization by the TCSSA algorithm, the optimal value of the K-means loss function and the optimal initial parameters are finally obtained. The important initial parameters set by TCSSA are the maximum number of iterations, the number of sparrows, the number of discoverers, and the number of followers. The purpose of optimizing the initial parameters of the K-means model is to obtain the minimum loss function to the maximum extent, that is, the distance between the cluster centers and the cluster points. Therefore, the fitness function of TCSSA is consistent with the loss function of K-means.
[0059] The original sparrow search algorithm was improved by optimizing the tent chaos perturbation and Cauchy mutation perturbation methods and adding an adaptive adjustment strategy for discoverers and followers. This improved the algorithm to address the problems of reduced population diversity and easy getting trapped in local optima when the original sparrow search algorithm is close to the global optimum.
[0060] To prevent the tent chaotic mapping from getting stuck at small-period points and unstable periodic points, random variables are introduced into the original tent chaotic mapping. The improved tent chaotic mapping expression is as follows:
[0061]
[0062] in, This represents the chaotic sequence value in the (k+1)th iteration. This represents the chaotic sequence value in the k-th iteration. Represents a random number between 0 and 1. This represents the total number of particles in the sequence;
[0063] After Bernoulli shift transformation, the expression is obtained:
[0064]
[0065] in, This represents the modulo operator.
[0066] The initial sparrow population is generated using the improved tent chaotic mapping described above, with the specific formula as follows:
[0067]
[0068] in, Let represent the initial position vector of the i-th sparrow. Represents the lower bound vector of the search space. Represents the upper bound vector of the search space. This represents the i-th chaotic sequence value, which corresponds one-to-one with the index of the individual sparrows;
[0069] Cauchy variation perturbs individuals, making the variation range more uniform. The variation equation is expressed as:
[0070]
[0071] in, Indicates the location of an individual after Cauchy mutation. Indicates the original individual location. Represents a random number within the interval (0, 1);
[0072] Since small changes in the exp value have a significant impact on the discoverer, this application improves the discoverer update equation, the specific formula of which is as follows:
[0073]
[0074] in, Let represent the position vector of the i-th discoverer in the (t+1)-th generation in the d-th dimension, where i represents the discoverer's index in the population, consistent with the meaning of i for a sparrow individual mentioned above. Let represent the position vector of the i-th discoverer in generation t, in dimension d, where d represents the dimension index of the position vector, and represents which dimension component of the position vector is being calculated. Indicates the maximum number of iterations. Represents a random number within the range (0, 1). This represents a control index that influences the balance between global and local searches by sparrow finders; it is typically set to 2. Indicates the warning value. Indicates the safety threshold. This represents a vector of random numbers that follows a normal distribution. This represents a matrix where all elements are 1;
[0075] The number of discoverers decreases adaptively with the number of iterations, while the number of followers increases adaptively with the number of iterations. The specific formula for the number of discoverers is:
[0076]
[0077] in, Indicates the number of discoverers. Indicates the size of the sparrow population. This is represented as a scaling factor, used to control the number of discoverers and followers, with a value of 0.9. Indicates the current iteration number. Indicates the maximum number of iterations. This represents the perturbation bias factor, used to perturb the nonlinear decreasing value, and has a value of 0.25. Represents a random number between 0 and 1;
[0078] The specific formula for adjusting the number of followers is as follows:
[0079]
[0080] in, Indicates the number of followers.
[0081] An improved sparrow search algorithm is used to iteratively optimize the initial cluster centers of K-means. The cluster centers are used as the optimization variable of the sparrow algorithm, and the loss function of K-means is used as the fitness function of the improved sparrow search algorithm. The optimal initial cluster centers are obtained through the global optimization capability of the sparrow algorithm, so as to solve the problem that the K-means algorithm gets stuck in local optima due to improper selection of initial cluster centers.
[0082] The specific iterative optimization process is as follows:
[0083] Step S3.1: Calculate the population fitness function value and update the optimal individual;
[0084] Step S3.2: Perform the discoverer position update according to the improved discoverer position update method, and perform the follower position update and the vigilant position update in parallel;
[0085] Step S3.3: Calculate the fitness value and the average fitness value, and determine whether the fitness value of each individual is less than the average fitness value. If it is less, execute the Cauchy mutation perturbation strategy; otherwise, execute the optimized tent chaotic perturbation strategy to update the individual after mutation perturbation into a new generation of individuals.
[0086] Step S3.4: Determine if the current iteration number is less than the maximum iteration number. If it is less, return to step S3.1 to continue iterating; otherwise, output the optimal initial cluster center.
[0087] The optimal initial cluster centers are used as the initial input to the K-means algorithm. K-means clustering iterations are performed until convergence to obtain the TCSSA-Kmeans image segmentation model.
[0088] The specific clustering process is as follows:
[0089] Step S4.1: Use the optimal initial cluster centers as the initial input of the K-means algorithm to calculate the Euclidean distance from the cluster points to the cluster centers;
[0090] Step S4.2: Calculate the category of each sample based on the minimum distance principle, that is, assign the sample to the cluster containing the nearest cluster center;
[0091] Step S4.3: Update cluster centers and segmentation distances;
[0092] Step S4.4: Determine whether the cluster centers have converged. If they have not converged, return to step S4.1 to continue iterating. If they have converged, output the optimization result and obtain the TCSSA-Kmeans image segmentation model.
[0093] The cluster center convergence criterion is that the sum of the squared distances between the previous generation cluster centers and the current generation cluster centers is less than a preset convergence threshold.
[0094] The bridge surface defect image is input into the TCSSA-Kmeans image segmentation model. The model clusters the image pixels based on the optimized cluster centers and outputs the bridge surface defect image segmentation result, effectively separating the defect area from the background area.
[0095] like Figure 2 As shown, a K-means bridge surface defect segmentation system based on an improved sparrow search algorithm is used to implement any of the K-means bridge surface defect segmentation methods based on an improved sparrow search algorithm, comprising:
[0096] Image acquisition module, used to acquire images of surface defects on bridges;
[0097] The model building module is used to build K-means image segmentation models;
[0098] The algorithm construction and initialization module is used to construct the improved sparrow search algorithm and initialize the population and algorithm parameters;
[0099] The iterative optimization module is used to iteratively optimize the initial cluster centers of K-means using an improved sparrow search algorithm until the maximum number of iterations is reached and the optimal initial cluster centers are output.
[0100] The clustering and segmentation module is used to take the optimal initial cluster centers as the initial input of K-means, iteratively calculate the distance from the cluster points to the cluster centers, update the cluster centers and segmentation distances until convergence, and output the segmentation results of the bridge surface defect image.
[0101] like Figure 3 As shown, a visual comparison of the segmentation results obtained using the standard K-means algorithm and the TCSSA-optimized K-means algorithm is presented. It can be seen intuitively that the TCSSA-optimized K-means segmentation model performs better and is closer to the actual segmentation of the image. The segmented bridge surface defects are also clearer, indicating that the TCSSA algorithm is effective in optimizing image segmentation tasks.
[0102] like Figure 4 As shown, the TCSSA-Kmeans image segmentation process specifically includes:
[0103] Acquire and input images of bridge surface defects; design and construct a K-means image segmentation model; construct an improved sparrow search algorithm, initialize the population, and set algorithm parameters, including the maximum number of iterations, sparrow population size, number of discoverers, and number of followers; calculate the population fitness function value; update the optimal individual; perform discoverer position updates according to the improved discoverer position update method, and perform follower and watchdog position updates in parallel; calculate the fitness value and average fitness value; determine whether the fitness value of each individual is less than the average fitness value; if it is less, execute the Cauchy mutation perturbation strategy; otherwise, execute the optimized tent chaotic perturbation strategy; and sort the individuals after mutation perturbation... The process involves updating the individual data to a new generation; determining if the current iteration count is less than the maximum iteration count, and if so, returning to continue iterating; otherwise, outputting the optimal initial cluster centers; using the optimal initial cluster centers as the initial input to the K-means algorithm, calculating the distance from cluster points to cluster centers, and calculating the category of each sample based on the minimum distance principle; updating the cluster centers and segmentation distances; determining if the cluster centers have converged, i.e., whether the distance between the previous generation cluster centers and the next generation cluster centers has converged; if not, returning to continue iterating; if converged, outputting the optimization result; obtaining the TCSSA-Kmeans image segmentation model and outputting the surface defect image segmentation result.
[0104] The examples described herein are merely preferred embodiments of the invention and are not intended to limit the concept and scope of the invention. Any modifications and improvements made by those skilled in the art to the technical solutions of the invention without departing from the design concept of the invention should fall within the protection scope of the invention.
Claims
1. A K-means bridge surface defect segmentation method based on an improved sparrow search algorithm, characterized in that, Includes the following steps: Step S1: Obtain images of surface defects on the bridge and construct a K-means image segmentation model; Step S2: Construct an improved sparrow search algorithm and initialize the population, set the algorithm parameters. The improved sparrow search algorithm includes an optimized tent chaotic perturbation strategy, a Cauchy mutation perturbation strategy, an improved discoverer position update method, and an adaptive adjustment strategy for discoverers and followers. Step S3: Iteratively optimize the initial cluster centers of K-means using the improved sparrow search algorithm, and output the optimal initial cluster centers; Step S4: Use the optimal initial cluster centers as the initial input of the K-means algorithm, perform K-means clustering iterations until convergence, and obtain the TCSSA-Kmeans image segmentation model; Step S5: Input the bridge surface defect image into the TCSSA-Kmeans image segmentation model and output the bridge surface defect image segmentation result.
2. The method according to claim 1, characterized in that, In step S1, the bridge surface defect image includes at least one of cracks, honeycombing, spalling, exposed reinforcement, and potholes.
3. The method according to claim 2, characterized in that, In step S2, the optimized tent chaotic perturbation strategy is as follows: a random variable is introduced into the original tent chaotic mapping. When the chaotic sequence value is greater than or equal to 0 and less than or equal to 0.5, the chaotic sequence value of the next iteration is equal to twice the current chaotic sequence value plus the product of the random variable and the reciprocal of the total number of particles. When the chaotic sequence value is greater than 0.5 and less than or equal to 1, the chaotic sequence value of the next iteration is equal to twice 1 minus the current chaotic sequence value plus the product of the random variable and the reciprocal of the total number of particles.
4. The method according to claim 3, characterized in that, In step S2, the Cauchy mutation perturbation strategy is as follows: the position of the mutated individual is equal to the original individual position multiplied by 1 plus the tangent function value, where the independent variable of the tangent function is the difference between π multiplied by a random number and 0.
5.
5. The method according to claim 4, characterized in that, In step S2, the improved discoverer location update method is as follows: when the warning value is less than the safety threshold, the updated discoverer location is equal to the current location multiplied by 2 and divided by the exponential function value, where the exponent of the exponential function is negative 4 times the discoverer number divided by the square of the product of the random parameter and the maximum number of iterations; when the warning value is greater than or equal to the safety threshold, the updated discoverer location is equal to the current location plus the random number vector.
6. The method according to claim 5, characterized in that, In step S2, the adaptive adjustment strategy for discoverers and followers is as follows: the number of discoverers is equal to the difference between the sparrow population size multiplied by the scaling factor multiplied by the tangent function value and the perturbation bias factor multiplied by the random number, where the independent variable of the tangent function is negative π multiplied by the current iteration number divided by 4 times the maximum iteration number plus π / 4; the number of followers is equal to the difference between the sparrow population size multiplied by 1 minus the difference between the scaling factor multiplied by the tangent function value and the perturbation bias factor multiplied by the random number, where the independent variable of the tangent function is negative π multiplied by the current iteration number divided by 4 times the maximum iteration number plus π / 4.
7. The method according to claim 6, characterized in that, Step S3 specifically includes the following steps: Step S3.1: Calculate the population fitness function value and update the optimal individual; Step S3.2: Perform the discoverer position update according to the improved discoverer position update method, and perform the follower position update and the vigilant position update in parallel; Step S3.3: Calculate the fitness value and the average fitness value, and determine whether the fitness value of each individual is less than the average fitness value. If it is less, execute the Cauchy mutation perturbation strategy; otherwise, execute the optimized tent chaotic perturbation strategy to update the individual after mutation perturbation into a new generation of individuals. Step S3.4: Determine if the current iteration number is less than the maximum iteration number. If it is less, return to step S3.1 to continue iterating; otherwise, output the optimal initial cluster center.
8. The method according to claim 7, characterized in that, In step S3.1, the population fitness function is a K-means loss function, which is equal to the sum of the squared Euclidean distances between each sample point and its cluster center. The optimization objective of the improved sparrow search algorithm is to minimize the loss function.
9. The method according to claim 8, characterized in that, Step S4 specifically includes the following steps: Step S4.1: Use the optimal initial cluster centers as the initial input of the K-means algorithm to calculate the Euclidean distance from the cluster points to the cluster centers; Step S4.2: Calculate the category of each sample based on the minimum distance principle, that is, assign the sample to the cluster containing the nearest cluster center; Step S4.3: Update cluster centers and segmentation distances; Step S4.4: Determine whether the cluster centers have converged. If they have not converged, return to step S4.1 to continue iterating. If they have converged, output the optimization result and obtain the TCSSA-Kmeans image segmentation model.
10. A K-means bridge surface defect segmentation system optimized based on an improved sparrow search algorithm, used to implement the K-means bridge surface defect segmentation method optimized based on an improved sparrow search algorithm as described in any one of claims 1-9, characterized in that, include: Image acquisition module, used to acquire images of surface defects on bridges; The model building module is used to build K-means image segmentation models; The algorithm construction and initialization module is used to construct the improved sparrow search algorithm and initialize the population and algorithm parameters; The iterative optimization module is used to iteratively optimize the initial cluster centers of K-means using an improved sparrow search algorithm until the maximum number of iterations is reached and the optimal initial cluster centers are output. The clustering and segmentation module is used to take the optimal initial cluster centers as the initial input of K-means, iteratively calculate the distance from the cluster points to the cluster centers, update the cluster centers and segmentation distances until convergence, and output the segmentation results of the bridge surface defect image.