A color sorting method based on a particle swarm algorithm

By combining K-means clustering and particle swarm optimization to optimize the color classification boundary parameters of the color sorter, the adaptability problem of the color sorter under changes in lighting and materials was solved, achieving high-precision and high-efficiency sorting results.

CN121661006BActive Publication Date: 2026-08-04SHANDONG TAISHAN LIFU FOOD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANDONG TAISHAN LIFU FOOD TECH CO LTD
Filing Date
2025-12-04
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

Existing color sorter algorithms have poor adaptability to changes in lighting and differences between batches of materials, making it difficult to achieve ideal results in complex sorting scenarios. Furthermore, traditional particle swarm optimization algorithms are prone to getting stuck in local optima, leading to missed or incorrect rejections.

Method used

A color sorting method based on particle swarm optimization is adopted. The particle swarm is initialized by K-means clustering analysis, and a fitness function is constructed that combines the true positive rate, false positive rate and virtual execution time index. An asymmetric acceleration constant and differential perturbation mechanism are configured to optimize the boundary parameters of color classification.

Benefits of technology

It improves the sorting accuracy and processing efficiency of color sorters, avoids missed or incorrect rejections, enhances the global search capability of the algorithm, and adapts to different lighting and material changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121661006B_ABST
    Figure CN121661006B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of data processing, in particular to a color sorting method of a color sorter based on a particle swarm algorithm. The method comprises: obtaining a sample image of a material to be screened and a label image corresponding to the sample image; initializing a particle swarm; the initial position vector of each particle in the particle swarm is a color classification boundary parameter for image segmentation of the sample image; after multiple iterations, a global optimal position vector is obtained, which is used in the rejection operation of the material to be screened of the color sorter to reject unqualified materials. That is, the scheme of the present application can accurately color sort, thereby avoiding the problems of missed rejection or mistaken rejection in online sorting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology. More specifically, this invention relates to a color sorting method for color sorters based on the particle swarm optimization algorithm. Background Technology

[0002] Color sorters, as automated sorting equipment, are widely used in agriculture, food processing, and industrial recycling. They are used to automatically separate discolored particles, impurities, or substandard products based on differences in the optical properties of materials, such as color and shape. Their core workflow typically includes four stages: image acquisition, image processing, decision control, and rejection. Among these, the performance of the image processing algorithm directly determines the sorting accuracy and efficiency of the color sorter.

[0003] Traditional color sorting algorithms often employ a method of setting fixed thresholds in specific color spaces (such as RGB and HSV) and classifying materials by comparing the color values ​​of their pixels with the preset thresholds. However, this method is highly sensitive to factors such as changes in lighting and batch-to-batch differences in materials. The threshold parameters often require repeated manual adjustments, making it highly subjective, lacking adaptability, and difficult to achieve ideal results in complex sorting scenarios.

[0004] To improve the automation and intelligence of algorithms, some studies have introduced clustering analysis methods, such as K-means clustering. This method automatically identifies the main color centers of materials by performing unsupervised learning on the color features of sample images, thus providing a basis for segmentation. However, accurately defining the classification boundaries based on the clustering results and determining the optimal number of clusters remain challenges for existing technologies. Parameter settings still have certain empirical limitations, making it difficult to guarantee the global optimality of the segmentation results.

[0005] To overcome the shortcomings of traditional methods, researchers have begun to apply intelligent optimization algorithms such as Particle Swarm Optimization (PSO) and Genetic Algorithm (GA) to the optimization of image segmentation parameters in color sorters. These methods encode the color boundary parameters of image segmentation as particles or individuals in the optimization algorithm, evaluate the merits of each set of parameters by constructing an evaluation function (i.e., fitness function), and iteratively search for the optimal combination of parameters.

[0006] However, standard particle swarm optimization (PSO) algorithms also have inherent limitations when applied to such complex optimization problems. For example, in the later stages of iteration, the algorithm is prone to getting stuck in local optima due to a decrease in population diversity, leading to search stagnation and an inability to find the global optimum, thus affecting the final sorting accuracy. Furthermore, key control parameters such as inertia weights and acceleration constants in traditional PSO algorithms are usually set to fixed values, making it impossible to dynamically adjust them according to the needs of different search stages (such as early global exploration and later local development), limiting the algorithm's convergence speed and optimization capabilities. More importantly, existing optimization methods, when designing fitness functions, mostly only consider image-level evaluation metrics such as segmentation accuracy and recall, neglecting the linkage performance between algorithm parameters and the physical execution mechanism of the color sorter (such as the spray valve). This can result in excessively long actual computation time during image segmentation, or the generated rejection instructions may not match the response time and operating frequency of the spray valve, leading to missed or incorrect rejections in online sorting. Summary of the Invention

[0007] The purpose of this invention is to propose a color sorting method for color sorters based on particle swarm optimization algorithm, in order to solve the problem that the prior art cannot perform accurate color sorting, resulting in missed or incorrect rejections in online sorting; to this end, this invention provides a solution in one aspect.

[0008] This invention provides a color sorting method for color sorters based on particle swarm optimization, comprising: Obtain sample images of the materials to be screened; Initialize the particle swarm; the initial position vector of each particle in the particle swarm is the initial color classification boundary parameter when performing image segmentation on the sample image in the CIELAB color space; After multiple iterations, the global optimal position vector is obtained, which is used in the rejection operation of the color sorter to remove unqualified materials. The fitness function of each particle is positively correlated with the true positive rate of the segmentation result corresponding to the updated position vector of each particle after each iteration, and negatively correlated with the false positive rate and virtual execution time index of the segmentation result. The true positive rate and false positive rate are obtained by comparing the segmentation result with the label image of the sample image at the pixel level. The virtual execution time index is the ratio of the product of the proportion of pixels to be removed in the segmentation result and the removal action time constant to the maximum execution time.

[0009] Optionally, the process of obtaining the initial position vector is as follows: K-means clustering analysis is performed on the two-dimensional chromaticity coordinates of each pixel in the CIELAB chromaticity space of the sample image, which are composed of the a-chromaticity component and the b-chromaticity component, to obtain initial chromaticity cluster centers of N cluster categories. Random sampling is performed within the neighborhood range corresponding to the N initial chromaticity cluster centers to form initial position vectors. The initial position vectors are composed of two-dimensional chromaticity coordinates of the N cluster categories.

[0010] Optionally, the fitness function is: F = w1 × TPR - w2 × FPR - w3 × T; Wherein, TPR is the true positive rate of the segmentation result, FPR is the false positive rate of the segmentation result, w1, w2, and w3 are preset positive weight coefficients, and T is the virtual execution time index.

[0011] Optionally, the specific process of updating the particle's own historical best position and the global best position of the particle swarm in each iteration is as follows: For each particle in the swarm, if the fitness value of the fitness function at the current iteration is better than the historical best fitness value before the current iteration, then update its position vector at the current iteration to the historical best position vector of that particle; then, search for the particle with the best fitness value in the entire swarm. If the best fitness value is better than the historical best fitness value recorded globally, then update the position vector of that particle to the global best position vector of the swarm.

[0012] Optionally, the label image of the sample image is an image in which each pixel in the sample image is manually labeled.

[0013] Optionally, it also includes: at each iteration, configuring asymmetric acceleration constant pairs for each particle based on the ranking of its fitness function fitness values, specifically: The particle swarm is sorted in descending order based on the fitness value of each particle. For the first m sorted particles, their individual learning factor c1 is set to be less than the group learning factor c2 to enhance convergence to the global optimum. For the remaining particles excluding the first m, their individual learning factor c1 is set to be greater than the group learning factor c2 to enhance the optimization in the local solution space.

[0014] Optionally, for the first m sorted particles, the acceleration constant pair (c1, c2) is set to (1.7, 2.3); for the remaining particles other than the first m, the acceleration constant pair (c1, c2) is set to (2.3, 1.7).

[0015] Optionally, it also includes generating new position vectors for stagnant particles whose fitness values ​​remain unchanged across multiple iterations through differential perturbation and arithmetic recombination, specifically: From the particle swarm at the current iteration, randomly select two particles that are different from the stationary particle, calculate the product of the difference vector of the position vectors of the two other particles and the set scaling factor, and use it as the difference perturbation vector. The differential perturbation vector is vector-synthesized with the global optimal position vector at the current iteration to generate the target vector; The target vector and the position vector of the stagnant particle at the current iteration are arithmetically recombinated to generate the new position vector.

[0016] Optionally, the segmentation result is obtained by segmenting the pixels of the sample image in the CIELAB color space using the updated position vectors of each particle after each iteration.

[0017] Optionally, after the multiple iterations, a globally optimal position vector is obtained, which is used in the rejection operation of the color sorter for materials to be screened. The specific process for rejecting unqualified materials is as follows: The global optimal position vector is loaded into the online control system of the color sorter as the optimal color classification boundary parameter. The system acquires images of the materials to be screened in real time and compares the chromaticity value of each pixel with the optimal color classification boundary parameter for classification. When a defective pixel is identified, the corresponding spray valve is immediately driven to perform the rejection action.

[0018] The beneficial effects of this invention are as follows: 1. This invention utilizes K-means clustering analysis to initialize the particle swarm, providing a high-quality starting point for the optimization search and accelerating the convergence speed of the algorithm.

[0019] 2. By combining the classification index (true positive rate and false positive rate) of the segmentation results corresponding to the updated position vector of each particle in each iteration with the virtual execution time index of the rejection mechanism on the color sorter, a fitness function of the particle swarm algorithm is constructed. This makes the optimization process not only pursue high accuracy of image segmentation, but also take into account the feasibility and efficiency of physical execution. This ensures that the optimized color classification parameters can truly play a role in high-speed online operation, significantly improving the sorting cleanliness and processing efficiency in actual production.

[0020] 3. By configuring acceleration constant pairs for particles of different quality and introducing differential perturbation and arithmetic recombination mechanisms for stagnant particles, the shortcomings of the standard particle swarm algorithm, which is prone to getting trapped in local optima, are effectively overcome. This enhances the algorithm's global search capability, enabling it to explore the entire solution space more fully and thus find color classification boundary parameters with higher accuracy. Attached Figure Description

[0021] Figure 1 The flowchart illustrating the steps of a color sorting method for a color sorter based on the particle swarm optimization algorithm in this embodiment is shown in the diagram. Detailed Implementation

[0022] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0023] like Figure 1 As shown in this embodiment, a color sorting method for a color sorter based on particle swarm optimization includes the following steps: Step S1: Obtain a sample image of the material to be screened and a label image corresponding to the sample image.

[0024] Specifically, an industrial camera is used to photograph the flowing material in the color sorter channel to obtain a high-resolution RGB format sample image; then, each pixel in the sample image is labeled by manually operating an image annotation tool to obtain a label image.

[0025] For example, when there are only two types in the sample image, namely good product areas and defective product areas, the resulting label image is a binary image, such as good product areas being marked as white and defective product areas being marked as black.

[0026] When there are multiple types in the sample image, the label image is a multi-value image, such as a pixel range of 0-4, which represents different categories.

[0027] Step S2: The particle swarm optimization algorithm is used to optimize the optimal color classification boundary parameters of the sample image, so as to remove unqualified materials in the rejection operation of the color sorter.

[0028] In this embodiment, the process of using the particle swarm optimization algorithm to optimize the optimal color classification boundary parameters (global optimal position vector) of the sample image is as follows: Step S21, initialize the particle swarm; the initial position vector of each particle in the particle swarm is the initial color classification boundary parameter when performing image segmentation on the sample image in the CIELAB color space.

[0029] In one embodiment, the process of obtaining the initial position vector of each particle in the particle swarm is as follows: K-means clustering analysis is performed on the two-dimensional chromaticity coordinates of each pixel in the CIELAB chromaticity space of the sample image, which are composed of the a-chromaticity component and the b-chromaticity component, to obtain N initial chromaticity cluster centers. Based on the N initial chromaticity cluster centers, the initial position vector of each particle in the particle swarm is generated by random sampling within its neighborhood. Each initial position vector represents a segmentation scheme of the sample image, where the initial position vector is the two-dimensional chromaticity coordinate within the N neighborhood.

[0030] Specifically, the sample image is converted from RGB space to CIELAB color space, and the a-chromaticity component and b-chromaticity component of all pixels are extracted to form the two-dimensional chromaticity coordinates of each pixel. K-means clustering is then used to cluster the two-dimensional chromaticity coordinates of all pixels to obtain N cluster categories and their corresponding initial chromaticity cluster centers.

[0031] For example, the number of cluster categories N is preset to 5 based on experience, which can yield 5 initial chromaticity cluster centers and their corresponding two-dimensional chromaticity coordinates.

[0032] The specific process of generating the initial position vector of each particle in the particle swarm by randomly sampling within its neighborhood range is as follows: obtain multiple neighborhood coordinate points within the neighborhood range of each initial chromaticity cluster center, and randomly sample multiple two-dimensional chromaticity coordinates from N neighborhood ranges respectively. The two-dimensional chromaticity coordinates of different cluster categories constitute the initial position vector of each particle in the particle swarm.

[0033] It should be noted that an initial position vector includes two-dimensional chromaticity coordinates of N cluster categories. For example, when there are 5 cluster categories, an initial position vector includes two-dimensional chromaticity coordinates from 5 cluster categories.

[0034] The neighborhood of each initial chromaticity cluster center can be a circular region with a radius of 3 centered at the coordinates of the corresponding initial chromaticity cluster center.

[0035] The initial position vector of the aforementioned particles is composed of two-dimensional chromaticity coordinates near the center of multiple cluster categories. This allows the particle swarm optimization algorithm to start from multiple initial guesses, explore the possibility of color segmentation under different conditions, and finally find the optimal color classification boundary parameters.

[0036] Step S22: Construct a fitness function; the fitness function is related to the classification performance index and the virtual execution time index of the elimination mechanism.

[0037] Specifically, the fitness function is positively correlated with the true positive rate and negatively correlated with the false positive rate and the virtual execution time metric.

[0038] The process of obtaining the classification performance indicators is as follows: Within a preset number of iterations, for each particle, the N two-dimensional chromaticity coordinates (i.e., N color centers) in its position vector are used as segmentation parameters for the sample image. Each pixel in the sample image is traversed, and the Euclidean distance between the pixel's two-dimensional chromaticity index and any of the N color centers is calculated. The pixel is then classified into the cluster category represented by the nearest color center, generating a segmentation result. This segmentation result is compared pixel-level with the labeled image, and the number of true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN) are counted to obtain the classification performance indices of true positive rate and false positive rate. The true positive rate (TPR) is equal to TP divided by the sum of TP and FN, and the false positive rate (FPR) is equal to FP divided by the sum of FP and TN.

[0039] The virtual execution time index is the ratio of the product of the number of connected regions (C) identified as defective products in the statistical segmentation result graph and the single response time constant of the spray valve to the maximum execution time. The maximum execution time is the highest execution time found in historical experience.

[0040] The virtual execution time metric T is used to quantify the impact of rejection actions on production efficiency. For example, if after image segmentation, it is calculated that the material to be rejected occupies 5% of the total pixel area, i.e., P_rej equals 0.05, and the physical time for performing one rejection action, such as the opening and closing of a spray valve once, is 10 milliseconds, i.e., T_c equals 10, then the virtual execution time T_exec is calculated as 0.05 multiplied by 10, which equals 0.5 milliseconds. The virtual execution time metric is the ratio of 0.5 milliseconds to the maximum execution time.

[0041] In one embodiment, the fitness function F is: F = w1×TPR - w2×FPR - w3×T; Wherein, TPR is the true positive rate of the segmentation result, FPR is the false positive rate of the segmentation result, w1, w2, and w3 are preset positive weight coefficients, and T is the virtual execution time index.

[0042] In one embodiment, w1, w2, and w3 are 0.6, 0.3, and 0.1, respectively.

[0043] The fitness function described above aims to comprehensively measure the performance of image segmentation algorithms, considering not only accuracy but also execution efficiency in actual production. Accuracy is evaluated by two metrics: True Positive Rate (TPR) and False Positive Rate (FPR). The TPR represents the proportion of correctly identified materials to be rejected; a higher TPR indicates fewer missed detections. The FPR represents the proportion of good materials incorrectly identified as materials to be rejected; a lower FPR indicates fewer misclassifications. Therefore, by maximizing the fitness value of the fitness function, the particle swarm optimization algorithm can find a set of optimal color classification boundary parameters, resulting in a high detection rate, a low misclassification rate, and a short rejection time, thus achieving an overall optimal effect.

[0044] Step S23: Update the particle's own historical best position and the global best position of the particle swarm.

[0045] Specifically, for each particle in the particle swarm, if the fitness value at the current iteration is better than the historical best fitness value before the current iteration, then the position vector of the particle at the current iteration is updated to the historical best position vector of the particle; then, the particle with the best fitness value is searched in the entire particle swarm, and if the best fitness value is better than the historical best fitness value recorded globally, then the position vector of the particle is updated to the global best position vector of the particle swarm.

[0046] During the update process, acceleration constant pairs are also configured for each particle based on its fitness value ranking.

[0047] The process of obtaining the acceleration constant pairs is as follows: Sort all particles in the swarm from best to worst according to their fitness values; The particle swarm is sorted in descending order based on the fitness values ​​of each particle. For a subset of particles with higher fitness values ​​after sorting (such as the first m particles), their individual learning factor c1 is set to be less than the swarm learning factor c2 to enhance their convergence to the global optimum. For another subset of particles with lower fitness values ​​after sorting (such as the remaining particles other than the first m particles), their individual learning factor c1 is set to be greater than the swarm learning factor c2 to enhance their exploration in the solution space.

[0048] The value of m can be either half or one-third of the total number of particles.

[0049] Specifically, the search efficiency of the entire particle swarm optimization algorithm is optimized by assigning different learning tasks to particles with different performance levels. After each iteration, all particles are sorted from high to low according to their fitness values. Particles with high fitness values ​​can be regarded as the current search leaders (dominant particles), and their positions are likely close to the global optimum. For these dominant particles, their individual learning factor c1 is decreased, while the group learning factor c2 is increased. This means reducing their tendency to learn towards their own historical best position, while enhancing their tendency to learn towards the best position discovered by the entire group, prompting these dominant particles to quickly approach the discovered global optimum and conduct in-depth exploration, thus playing a role in convergence and optimization. Conversely, for particles with low fitness values, they can be regarded as explorers, and their current position may be far from the optimal region or located in a local optimum trap. In this case, their individual learning factor c1 is set to be greater than the group learning factor c2. This will enhance their tendency to learn towards their own historical best position, while reducing the attraction to the current global optimum.

[0050] Furthermore, for stagnant particles whose fitness values ​​remain unchanged after multiple iterations, a new position vector is generated through differential perturbation and arithmetic recombination; for non-stagnant particles, their velocity and position are updated using adjusted inertial weights and asymmetric acceleration constants.

[0051] Specifically, a stagnation counter is set for each particle. If the fitness value of a particle does not improve for 5 consecutive iterations (e.g., the fitness value remains unchanged or there is no improvement), it is determined to be a stagnation particle. For stagnation particles, two particles different from itself are randomly selected from the population, and a perturbation vector is generated using the differential evolution operator. This perturbation vector is then arithmetically recombined with the global optimal position vector to generate a new position vector, in order to escape the local optimum.

[0052] The above arithmetic recombination is existing technology and will not be elaborated here.

[0053] For example, once particle A is determined to be stagnant, the system initiates a reset procedure. It randomly selects two other particles from the swarm, such as particles B and C. It then calculates the difference between their position vectors (particle B's position vector minus particle C's position vector), obtaining a difference vector. This difference vector is then multiplied by a set scaling factor, such as 0.6, to form a difference perturbation vector. This perturbation vector is added to the current global optimal position vector to generate a target vector that contains both global optimal information and population diversity information. Finally, through arithmetic recombination, the current position vector of stagnant particle A is combined with the newly generated target vector in a specific ratio, thereby generating a new position vector for particle A.

[0054] The new position vector allows stagnant particles to escape the trap and rejoin the effective search process. The differential perturbation vector represents a trend of change within the particle swarm at the current iteration.

[0055] For non-stationary particles, such as particles whose fitness changes with the number of iterations, their velocity and position are updated directly using the adjusted inertia weights and acceleration constants.

[0056] Step S24: After the iteration is completed, the global optimal position vector is used as the optimal color classification boundary parameter and applied to the online material rejection operation of the color sorter.

[0057] Specifically, the iteration stops when the preset maximum number of iterations (e.g., 100 times); the final global optimal position vector is extracted, which is the optimal color classification boundary parameter (i.e., a set of optimal color classification center coordinates), and the optimal color classification boundary parameter is solidified into the color sorting parameter; the color sorting parameter is loaded into the online control system of the color sorter, the system collects images of the materials to be screened in real time, and compares and classifies the chromaticity value of each pixel with the optimal color classification boundary parameter. Once a defective pixel is identified, the corresponding spray valve is immediately driven to perform the rejection action.

[0058] In one embodiment, the comparison and classification of two pixels can be achieved by calculating the Euclidean distance. When the calculated Euclidean distance is less than the distance threshold, it proves that the corresponding pixel belongs to the corresponding cluster category. When the pixel belongs to all cluster categories, the classification of the pixel is achieved. Based on the specific cluster category, the pixel is judged to filter out bad pixels and drive the corresponding spray valve to perform the rejection action.

[0059] The solution of this invention avoids the problem of getting trapped in local optima when using the particle swarm optimization algorithm to detect abnormal pixels in the image of the material to be screened. It enhances the global search capability of the algorithm and can explore the entire solution space more fully, thereby finding color classification boundary parameters with higher accuracy.

[0060] In the description of this specification, "multiple" means at least two, such as two, three or more, etc., unless otherwise expressly and specifically defined.

[0061] While various embodiments of the invention have been shown and described in this specification, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention.

Claims

1. A color sorting method for color sorters based on particle swarm optimization algorithm, characterized in that, include: Obtain sample images of the materials to be screened; Initialize the particle swarm; The initial position vector of each particle in the particle swarm is the initial color classification boundary parameter when performing image segmentation on the sample image in the CIELAB color space; After multiple iterations, the global optimal position vector is obtained, which is used in the rejection operation of the color sorter to remove unqualified materials. The fitness function of each particle is positively correlated with the true positive rate of the segmentation result corresponding to the updated position vector of each particle after each iteration, and negatively correlated with the false positive rate and virtual execution time index of the segmentation result. The true positive rate and false positive rate are obtained by comparing the segmentation result with the label image of the sample image at the pixel level. The virtual execution time index is the ratio of the product of the proportion of pixels occupied by the material to be removed in the segmentation result and the removal action time constant to the maximum execution time. The fitness function is: F = w1 × TPR - w2 × FPR - w3 × T; Wherein, TPR is the true positive rate of the segmentation result, FPR is the false positive rate of the segmentation result, w1, w2, and w3 are preset positive weight coefficients, and T is the virtual execution time index. The specific process of updating the particle's own historical best position and the global best position of the particle swarm in each iteration is as follows: For each particle in the swarm, if the fitness value of the fitness function at the current iteration is better than the historical best fitness value before the current iteration, then update its position vector at the current iteration to the historical best position vector of that particle; then, search for the particle with the best fitness value in the entire swarm. If the best fitness value is better than the historical best fitness value recorded globally, then update the position vector of that particle to the global best position vector of the swarm. In each iteration, based on the ranking of the fitness values ​​of each particle's fitness function, asymmetric acceleration constant pairs are assigned to them, specifically: The particle swarm is sorted in descending order based on the fitness value of each particle. For the first m sorted particles, their individual learning factor c1 is set to be less than the group learning factor c2 to enhance convergence to the global optimum. For the remaining particles other than the first m, set their individual learning factor c1 to be greater than the group learning factor c2 to enhance the optimization in the local solution space. For stationary particles whose fitness values ​​remain unchanged across multiple iterations, a new position vector is generated through differential perturbation and arithmetic recombination, specifically as follows: From the particle swarm at the current iteration, randomly select two particles that are different from the stationary particle, calculate the product of the difference vector of the position vectors of the two other particles and the set scaling factor, and use it as the difference perturbation vector. The differential perturbation vector is vector-synthesized with the global optimal position vector at the current iteration to generate the target vector; The target vector and the position vector of the stagnant particle at the current iteration are arithmetically recombinated to generate the new position vector.

2. The color sorting method for a color sorter based on particle swarm optimization algorithm according to claim 1, characterized in that, The process of obtaining the initial position vector is as follows: K-means clustering analysis is performed on the two-dimensional chromaticity coordinates of each pixel in the CIELAB chromaticity space of the sample image, which are composed of the a-chromaticity component and the b-chromaticity component, to obtain initial chromaticity cluster centers of N cluster categories. Random sampling is performed within the neighborhood range corresponding to the N initial chromaticity cluster centers to form initial position vectors. The initial position vectors are composed of two-dimensional chromaticity coordinates of the N cluster categories.

3. The color sorting method for a color sorter based on particle swarm optimization algorithm according to claim 1, characterized in that, The label image of the sample image is an image in which each pixel in the sample image is manually labeled.

4. The color sorting method for a color sorter based on particle swarm optimization algorithm according to claim 1, characterized in that, For the first m sorted particles, the acceleration constant pair (c1, c2) is set to (1.7, 2.3); for the remaining particles other than the first m, the acceleration constant pair (c1, c2) is set to (2.3, 1.7).

5. The color sorting method for a color sorter based on particle swarm optimization algorithm according to claim 1, characterized in that, The segmentation result is obtained by segmenting the pixels of the sample image in the CIELAB color space using the updated position vectors of each particle after each iteration.

6. The color sorting method for a color sorter based on particle swarm optimization algorithm according to claim 1, characterized in that, After the multiple iterations are completed, a globally optimal position vector is obtained, which is used in the rejection operation of the color sorter for materials to be screened. The specific process for rejecting unqualified materials is as follows: The global optimal position vector is loaded into the online control system of the color sorter as the optimal color classification boundary parameter. The system acquires images of the materials to be screened in real time and compares the chromaticity value of each pixel with the optimal color classification boundary parameter for classification. When a defective pixel is identified, the corresponding spray valve is immediately driven to perform the rejection action.