An Image Threshold Segmentation Method Based on Improved Chaotic Particle Swarm

Through the improved chaotic particle swarm algorithm, elite particles are screened using particle contribution degree, and quasi-Newtonian method accelerated chaos optimization is solved in the elite particles, and the problems of low image threshold segmentation efficiency and local optimality in the existing technology are solved, and efficient and accurate image threshold segmentation is achieved.

CN114863114BActive Publication Date: 2025-06-10CHANGZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210568128.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-24
Publication Date
2025-06-10
Estimated Expiration
2042-05-24

AI Technical Summary

Technical Problem

In the prior art, when processing complex images, it is difficult to find the maximum entropy function, which leads to an increase in threshold separation time, reduces the working efficiency of image processing, and standard particle swarm algorithms are prone to fall into local optimal problems.

Method used

The improved chaotic particle swarm algorithm is used to screen elite particles through particle contribution degree, and iterative chaotic optimization based on quasi-Newtonian method is carried out in elite particles to achieve image threshold segmentation.

Benefits of technology

The speed and accuracy of image threshold segmentation are improved, the range of chaotic optimization is narrowed, the calculation amount is reduced, optimization time is saved, and the work efficiency of image processing is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114863114B_ABST
    Figure CN114863114B_ABST
Patent Text Reader

Abstract

The present invention discloses an image threshold segmentation method based on an improved chaotic particle swarm, including: initializing a particle swarm, calculating the fitness value of each particle individual, updating the individual extreme value of the particle and the global extreme value of the particle; iteratively updating the position and velocity of each particle individual; calculating the threshold segmentation contribution degree of each particle individual; screening to obtain elite particles according to the threshold segmentation contribution degree of each particle individual; performing iterative chaotic optimization accelerated by the quasi-Newton method on the elite particles, performing threshold segmentation on the grayscale image to obtain the optimal fitness value; determining whether the current chaotic iteration number meets the set maximum chaotic iteration number or whether the chaotic optimization reaches the set accuracy, if the current chaotic iteration number meets the set maximum chaotic iteration number or the chaotic optimization reaches the set accuracy, then inverse map the optimal fitness value back to the particle swarm cluster, calculate the fitness values of all particles in the particle swarm cluster, and output the optimal solution if the set conditions are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an image threshold segmentation method based on an improved chaotic particle swarm, belonging to the technical field of digital image segmentation. Background Art

[0002] Digital image segmentation is an important technology in the process of image processing. Its purpose is to separate the target area in the image from the background. Among many methods of image segmentation, threshold segmentation is simple and has stable performance. It is a most popular and basic segmentation technology. It uses the gray histogram of the image to obtain one or more image segmentation thresholds, and then compares the gray value of each pixel in the image through this segmentation threshold to achieve the separation of the target and the background. In recent years, scholars at home and abroad have proposed many threshold image segmentation methods, such as the Otsu method of maximum inter-class variance, the method of minimum cross-entropy value, and the kapur method of maximum entropy, etc. Among them, the kapur entropy function is widely used in threshold image segmentation due to its advantages of simple implementation and high segmentation accuracy. However, when the kapur entropy function processes complex images, it is very difficult to find the maximum entropy function, which greatly increases the time of threshold separation and reduces the working efficiency of image processing.

[0003] The particle swarm optimization algorithm (PSO) is an intelligent optimization algorithm proposed by Eberhart and kennedy in 1995. Due to the characteristics of simple operation, few parameters, and easy implementation of the PSO algorithm, it has been recognized by scholars since it was proposed and has developed rapidly. However, the standard PSO algorithm is prone to falling into the problem of local optimum when solving the threshold segmentation of images. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to overcome the defects of the prior art and provide an image threshold segmentation method based on an improved chaotic particle swarm to improve the working efficiency of image processing by optimizing the segmentation method.

[0005] To achieve the above object, the present invention provides an image threshold segmentation method based on an improved chaotic particle swarm, including:

[0006] Step 1, preprocess the image to obtain a grayscale image;

[0007] Step 2, initialize the particle swarm and calculate the fitness value of each particle individual;

[0008] Step 3, update the individual extreme value of the particle and the global extreme value of the particle based on the fitness value of the particle individual;

[0009] Step 4, iteratively update the position of the particle individual and the velocity of the particle individual;

[0010] Step 5, calculate the contribution degree of the particle individual to threshold segmentation;

[0011] Step 6: Filter and obtain elite particles according to the threshold segmentation contribution degree of particle individuals.

[0012] Step 7: Perform iterative chaotic optimization based on the quasi-Newton method acceleration on the elite particles, perform threshold segmentation on the grayscale image, and obtain the optimal fitness value.

[0013] Step 8: Determine whether the current chaotic iteration times meet the set maximum chaotic iteration times or whether the chaotic optimization reaches the set accuracy. If the current chaotic iteration times meet the set maximum chaotic iteration times or the chaotic optimization reaches the set accuracy, then enter Step 9; otherwise, enter Step 7.

[0014] Step 9: Inverse map the optimal fitness value back into the particle swarm cluster, calculate the fitness values of all particles in the particle cluster. If the set conditions are met, output the optimal solution; otherwise, enter Step 2.

[0015] Preferably, in Step 2, initialize the particle swarm, calculate the fitness value of the particle individual, and implement it through the following steps:

[0016] In the D-dimensional target search space, initialize the total number m of particle individuals, the positions of particle individuals, and the velocity v of particle individuals i =(v i1 , v i2 , …, v iD );

[0017] Divide the target and background in the grayscale image, and calculate the fitness value of the current particle individual:

[0018] Calculate the probability U of each gray level j appearing in the grayscale image j :

[0019]

[0020] In the formula: L represents the gray level, where the range of L is [1, 255], and n j is the jth gray level;

[0021] Calculate the entropy values of the target and the background:

[0022]

[0023]

[0024] In the formula, H 0 represents the entropy value of the target, H 1 represents the entropy value of the background, γ 0 represents the cumulative probability of pixels of the target in the grayscale image, γ 1Represents the cumulative probability of pixels in the grayscale image for the background, γ 0 and γ 1 The sum of the two is 1, and t is the set threshold;

[0025] Calculate the total entropy H(t) of the grayscale image:

[0026] H(t) = H 0 +H 1 ,

[0027] Take the threshold t corresponding to the maximum value of H(t) as the optimal threshold;

[0028] Take the pixels in the grayscale image with gray levels greater than the optimal threshold as the target, and take the pixels in the grayscale image with gray levels less than or equal to the optimal threshold as the background;

[0029] Let x i =(x i2 ,x i2 ,…,x iD ) be the D-dimensional position vector of the i-th particle (i = 1, 2, …, m), and use the Kapur entropy function as the fitness function;

[0030] Calculate the fitness value of the current particle individual according to the Kapur entropy function.

[0031] Preferably, in step 4, iteratively update the position and velocity of the particle individual, which is implemented by the following steps:

[0032] Update the velocity and position of the particle individual according to the following formula:

[0033]

[0034]

[0035] where, is the velocity of the i-th particle individual at the (k + 1)-th iteration, ω is the inertia weight, is the position of the i-th particle individual at the (k + 1)-th iteration, i = 1, 2, …, m, d = 1, 2, …, D; p i =(p i1 ,p i2 ,…,p id ,…,p iD ) is the personal best of the i-th particle individual, p g =(p g1 ,p g2 ,…,p gd ,…,p gD ) is the global best of the g-th, k is the current iteration number, r 1 and r2 is a random number between [0, 1]; c 1 and c 2 are learning factors, is the position of the i-th particle individual at the k-th iteration; the calculation formula for the inertia weight ω is:

[0036]

[0037] In the formula, ω max is the maximum inertia weight value, ω min is the minimum inertia weight value, k max is the set total number of iterations. Preferably, in step 5, calculate the threshold segmentation contribution degree of the particle individual, which is achieved through the following steps:

[0038]

[0039]

[0040] In the formula, z is the distance difference between the i-th particle individual and the particle individual corresponding to the global extreme value, e gbest is the abscissa of the particle individual corresponding to the global extreme value in the target search space, s gbest is the ordinate of the particle individual corresponding to the global extreme value in the target search space, e i is the abscissa of the i-th particle individual in the target search space, s i is the ordinate of the i-th particle individual in the target search space, m is the total number of particle individuals, and ACD is the threshold segmentation contribution degree of each particle individual.

[0041] Preferably, in step 6, according to the threshold segmentation contribution degree of the particle individual, screen and obtain elite particles, which is achieved through the following steps: Select a set proportion of particle individuals as elite particles in descending order of the threshold segmentation contribution degree.

[0042] Preferably, steps 7 and 8 are achieved through the following steps:

[0043] A, set the set number of chaotic iterations M, and map the g-th global extreme value p g to the domain [0, 1] of the logistic equation:

[0044] In the formula, is the sequence element obtained in the first iteration, is the global extreme value of the particle swarm, is the minimum value of the particle position range, is the maximum value of the particle position range;

[0045] B, Through the logistic equation After performing M iterations accelerated by the quasi - Newton method, a chaotic sequence is obtained

[0046] Wherein is the sequence element obtained in the (n + 1)-th iteration, μ is the control parameter, is the sequence element obtained in the M-th iteration;

[0047] C, Inverse map the chaotic sequence back to the original solution space through the following formula to obtain a feasible solution sequence of chaotic variables

[0048] Wherein is the sequence element obtained in the m-th iteration;

[0049] F, Calculate the fitness value of each feasible solution vector in the feasible solution sequence of chaotic variables, and obtain the maximum value of the fitness corresponding to the feasible solution vector according to the characteristics of Kapur entropy threshold segmentation;

[0050] G, If m≥2, then determine whether the maximum value of the current fitness is greater than the maximum value of the fitness obtained in the previous step. If the maximum value of the current fitness is greater than the maximum value of the fitness obtained in the previous step, then use the maximum value of the current fitness as the optimal fitness value;

[0051] F, Determine whether the optimal fitness value reaches the set accuracy or whether the current iteration number reaches the set maximum number of chaotic iterations; If the optimal fitness value reaches the set accuracy or the current iteration number reaches the set maximum number of chaotic iterations, then go to step 9, otherwise go to step B.

[0052] Preferably, step 9 is implemented through the following steps:

[0053] Step 11, Randomly select a particle individual from the particle swarm, and use the feasible solution vector corresponding to the optimal fitness value to replace the feasible solution vector of this particle individual;

[0054] Step 12, Calculate the fitness values of all particles in the particle swarm;

[0055] Step 13, If the fitness values of all particles in the particle swarm reach the accuracy set for the particle swarm or the current iteration number reaches the set maximum number of iterations of the particle swarm, then output the optimal solution, otherwise go to step 11.

[0056] Preferably, step 1, Preprocess the image to obtain a grayscale image, which is implemented through the following steps:

[0057] Perform gray - scale transformation, Gaussian filtering, and logarithmic transformation on the image;

[0058] Perform gray-scale transformation using the weighted mean method;

[0059] In Gaussian filtering, use the two-dimensional Gaussian distribution function as the smoothing filter for the grayscale image.

[0060] An electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor. It is characterized in that when the processor executes the program, the steps of the method described in any one of the above are implemented.

[0061] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of the above are implemented.

[0062] The beneficial effects achieved by the present invention:

[0063] The present invention is mainly aimed at the threshold segmentation of grayscale images, and has improved in the speed and accuracy of threshold segmentation, making grayscale image processing more suitable for factory production to improve production speed and production efficiency. The main innovation points are as follows:

[0064] Compared with the transmission of chaotic particle swarms, where all particles need to be repeatedly chaotically optimized to improve accuracy and avoid particle prematurity, the present invention applies the proposed idea of particle contribution degree, selects elite particles according to the contribution degree, and performs chaotic optimization among the elite particles, narrowing the scope of chaotic optimization, reducing the computational amount required for chaotic optimization, saving the overall model optimization time, and ensuring the accuracy of threshold segmentation;

[0065] Chaotic optimization requires equation mapping and inverse mapping. In the case of a large number of input particles, it will prolong the chaotic optimization time, resulting in the overall optimization time being slowed down due to the excessive chaotic optimization time and the model efficiency being low. The present invention applies the quasi-Newton method nested in the chaotic iteration process, preprocesses some of the particles to be processed by chaotic optimization in advance, reduces the chaotic optimization time, and realizes the acceleration of chaotic optimization by the quasi-Newton method, thereby improving the overall working efficiency of the model;

[0066] The present invention has achieved a significant improvement in the speed of the threshold segmentation part of image processing while ensuring accuracy according to the common acceleration of the above two steps. Description of the Drawings

[0067] Figure 1 is the flowchart of the present invention;

[0068] Figure 2 is the schematic diagram of the chaotic particle swarm algorithm accelerated by the quasi-Newton method of the present invention;

[0069] Figure 3 is the comparison chart of the convergence speed between the standard particle swarm algorithm and the present invention;

[0070] Figure 4 It is the original image of the magnetic material;

[0071] Figure 5 It is the threshold segmentation image obtained by the entropy function;

[0072] Figure 6 It is the threshold segmentation image optimized by the standard particle swarm algorithm;

[0073] Figure 7 It is the threshold segmentation image optimized by the improved particle swarm algorithm of the present invention. Specific implementation manner

[0074] The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.

[0075] 1. A method for image threshold segmentation based on improved chaotic particle swarm Specific implementation manner:

[0077] Step 1, preprocess the image to obtain a grayscale image;

[0078] Step 2, initialize the particle swarm, and calculate the fitness value of each particle individual;

[0079] Step 3, update the individual extreme value of the particle and the global extreme value of the particle based on the fitness value of the particle individual;

[0080] Step 4, iteratively update the position of the particle individual and the velocity of the particle individual;

[0081] Step 5, calculate the threshold segmentation contribution degree of the particle individual;

[0082] Step 6, screen and obtain elite particles according to the threshold segmentation contribution degree of the particle individual;

[0083] Step 7, perform iterative chaotic optimization based on the quasi-Newton method acceleration on the elite particles, perform threshold segmentation on the grayscale image, and obtain the optimal fitness value;

[0084] Step 8, determine whether the current chaotic iteration times meet the set maximum chaotic iteration times or whether the chaotic optimization reaches the set accuracy. If the current chaotic iteration times meet the set maximum chaotic iteration times or the chaotic optimization reaches the set accuracy, enter step nine, otherwise enter step 7;

[0085] Step 9, inverse map the optimal fitness value back into the particle swarm cluster, calculate the fitness value of all particles in the particle swarm cluster. If the set conditions are met, output the optimal solution, otherwise enter step 2.

[0086] Step S1: Preprocess the image;

[0087] The preprocessing includes gray-scale transformation: The weighted mean method is adopted in the present invention. The weighted average method takes a weight value for each of the three-channel component values of the RGB color image, and then performs weighted averaging to obtain a gray-scale image;

[0088] The expression for weighted average is:

[0089] Gray(i,j) = 0.299R(i,j) + 0.587G(i,j) + 0.114B(i,j)

[0090] where ω R , ω G , ω B are the weight values of the R-channel component value, the G-channel component value, and the B-channel component value respectively. Different weight values result in different gray-scale images; ω R = 0.299, ω G = 0.587, ω B = 0.114 gives the best effect of the gray-scale image.

[0091] Step S2: The preprocessing also includes performing Gaussian filtering on the gray-scale image. Generally, a two-dimensional Gaussian distribution function is used as the smoothing filter for the gray-scale image, that is:

[0092]

[0093] where (x, y) represents the template coordinates of the pixel, the center position of the template is the origin, σ is the standard deviation of the normal distribution, often taken as 1, and the size of the template depends on the resolution of the gray-scale image. The resolution of the gray-scale image in the present invention is 512×512. Step S3: The preprocessing also includes performing logarithmic transformation on the gray-scale image to enhance the contrast of the gray-scale image, that is:

[0094] s = c*log(1 + J)

[0095] where s is the gray value of the output gray-scale image, J is the gray value of the input gray-scale image, and c is a constant, often taken as 1. The present invention adopts a chaotic particle swarm optimization algorithm accelerated by the quasi-Newton method to optimize the Kapur threshold image segmentation method, and performs threshold segmentation on the gray-scale image. The specific process is as Figure 1 .

[0096] 1) Initialize the particle swarm: In a D-dimensional target search space, for the total number m of particle individuals in the particle swarm, the position x i = (x i1 , x i2 , …, x iD ) and velocity v i = (v i1 , vi2 , …, v iD ) are initialized, where the dimension D = 1, the number of particle individuals m = 50, the position x of the particle i ranges from [1, 255], and the velocity v of the particle i ranges from [-10, 10].

[0097] 2) Divide the target and background in the grayscale image, and calculate the fitness value of the current particle individual;

[0098] Specifically, the fitness function used in the present invention is the Kapur entropy function. The Kapur entropy function calculates the probability U of each gray level j appearing in the grayscale image through the following formula j :

[0099]

[0100] In the formula: L represents the gray level, where the range of L is [1, 255], and n j is the j-th gray level;

[0101] The entropy values corresponding to the target and background are expressed as follows:

[0102]

[0103]

[0104] In the formula, γ 0 represents the cumulative probability of target pixels in the grayscale image, and γ 1 represents the cumulative probability of background pixels in the grayscale image. The sum of γ 0 and γ 1 is 1, and t is the threshold;

[0105] At this threshold, the total entropy H(t) of the grayscale image is:

[0106] H(t) = H 0 + H 1

[0107] The threshold corresponding to the maximum value of H(t) is the optimal threshold. The pixels in the grayscale image with gray levels greater than the optimal threshold are taken as the target, otherwise as the background.

[0108] Let x i = (x i2 , x i2 , …, x iD ) be the D-dimensional position vector of the i-th particle (i = 1, 2, …, m). According to the set Kapur entropy function, calculate the fitness value of the current particle individual.

[0109] 3) Obtain the individual extreme value and the global extreme value: After obtaining the fitness value of the current particle individual, the individual extreme value p of the current particle individual can be directly obtained i =(p i1 ,p i2 ,…,p id ,…,p iD ) and the global extreme value.

[0110] p g =(p g1 ,p g2 ,…,p gd ,…,p gD ), where p i is the optimal position searched by the particle individual so far, and p g is the optimal position searched by the entire particle swarm so far.

[0111] 4) Iteratively update the velocity of the particle individual and the position of the particle individual:

[0112] During each iteration, update the velocity of the particle individual and the position of the particle individual according to the following formula:

[0113]

[0114]

[0115] where, is the velocity of the i-th particle individual at the (k + 1)-th iteration, is the position of the i-th particle individual at the (k + 1)-th iteration, i = 1, 2, …, m, d = 1, 2, …, D; k is the current iteration number, r 1 and r 2 are random numbers between [0, 1], and these two parameters are used to maintain the diversity of the population; c 1 and c 2 are learning factors, and in the present invention, c 1 = c 2 = 2, is the position of the i-th particle individual at the k-th iteration, and the inertia weight ω reflects the ability of the particle to inherit the previous velocity. Usually, it adopts a linearly decreasing manner, and the specific calculation formula of ω is as follows:

[0116]

[0117] where ω max is the maximum weight value, ω min is the minimum weight value, k is the iteration number, and k max is the total number of iterations;

[0118] Specifically, ω max= 0.9, ω min = 0.4, k max = 100.

[0119] 5) The standard particle swarm optimization algorithm is a group of random particles that find the optimal solution through iteration. In each iteration, the particles update themselves by tracking two extreme values, which are the individual extreme value and the global extreme value. However, since the particle swarm optimization algorithm needs to update the positions and velocities of all particles in each iteration, when the fitness function is relatively complex, the computational amount of the standard particle swarm is relatively large.

[0120] The global extreme value is judged according to the fitness of all current particles, that is, the maximum fitness value of all particles in this iteration. The individual extreme value is judged according to the fitness values of each particle in different iterations.

[0121] Specifically, the individual extreme value is judged according to the fitness of a single particle. The fitness values of each particle in different iterations are different. The individual extreme value of the particle is judged according to the change of the fitness values of the single particle before and after. The specific steps are as follows

[0122] 1) The fitness value of the initial iteration is the individual extreme value of each particle.

[0123] 2) The fitness value obtained in the second iteration is compared with the fitness value obtained in the initial iteration. If the fitness value of the second iteration is greater than the fitness value of the previous iteration, then use this value to replace the previous value.

[0124] 3) Repeat step 2, that is, compare the fitness value obtained in the k-th iteration with the fitness value obtained in the (k - 1)-th iteration. If the fitness value of the k-th iteration is greater than the fitness value of the (k - 1)-th iteration, then use this value to replace the previous value.

[0125] The global extreme value is judged according to the fitness values of all particles. The fitness values of all particles, according to the requirements of the fitness function (the requirement of the present invention is to find the maximum fitness value), the maximum fitness value of all particles in the current iteration is the global extreme value of this iteration. During each iteration, the fitness values of the particles will change, and the particles representing the maximum fitness value will also change, and the global extreme value will also change accordingly.

[0126] When used for the positioning of magnetic materials, a large amount of calculation will result in a long image processing time, thus reducing the overall work efficiency. Of course, in addition to the standard particle swarm algorithm, the entropy function also has a built-in enumeration method to calculate the maximum entropy value, that is, all cases of the entropy value are listed to find the optimal entropy value. Although this method can ensure accuracy, the running time is much slower than the optimization algorithm, and the work efficiency is also much lower. In view of the above situation, the present invention proposes a threshold segmentation method based on chaotic particle swarm accelerated by the quasi-Newton method. Based on the standard particle swarm, in the process of each iteration, the particles are preferentially processed, and 20% of the elite particles are selected according to the threshold segmentation contribution degree of each particle individual for chaotic optimization, and the quasi-Newton method is used for acceleration in the process of chaotic optimization. Through this method, the amount of calculation in the image processing part is reduced, thus reducing the running time of this step and improving the overall work efficiency.

[0127] The present invention screens out 20% of the particles as elite particles according to the threshold segmentation contribution degree of each particle individual. The threshold segmentation contribution degree of each particle individual is obtained by comparing the fitness value of each particle and the fitness value of the global extreme value of this iteration, and calculating the distance difference between each particle individual and the global extreme value of this iteration. The smaller the distance, the closer it is to the optimal threshold, and the greater the contribution degree to the optimization. Let the global extreme value particle of each time be (e gbest , s gbest ), the distance difference between the particle individual and the global extreme value, and the threshold segmentation contribution degree value of each particle individual are obtained according to the following formula:

[0128]

[0129]

[0130] Among them, z represents the distance difference between the i-th particle individual and the particle individual corresponding to the global extreme value, e gbest is the abscissa of the particle individual corresponding to the global extreme value in the target search space, s gbest is the ordinate of the particle individual corresponding to the global extreme value in the target search space, e i is the abscissa of the i-th particle individual in the target search space, s i is the ordinate of the i-th particle individual in the target search space, m is the total number of particle individuals, m = 50, ACD (actual contribution degree) is the threshold segmentation contribution degree of each particle individual, and the threshold segmentation contribution degree is inversely proportional to the distance difference z. When the i-th particle individual is closer to the particle individual corresponding to the global extreme value, it means that the threshold segmentation contribution degree of the i-th particle individual to this optimization is greater. The top 20% of the elite particles are selected according to the threshold segmentation contribution degree from large to small, so as to reduce the optimization time.

[0131] As Figure 2 is a schematic diagram of an improved particle swarm optimization algorithm. The standard particle swarm optimization algorithm is improved to a chaotic particle swarm optimization algorithm accelerated by the quasi-Newton method, thereby improving the speed of threshold segmentation and at the same time improving the overall working efficiency.

[0132] Map the elite particles to the domain [0,1] of the logistic equation. Perform M iterations on a chaotic sequence through the logistic equation. During the iteration process, accelerate through the quasi-Newton method. The quasi-Newton is an acceleration method that continuously shrinks the range through negative feedback. After iteration, a chaotic sequence is obtained. Map the chaotic sequence back to the original solution space through the following equation, thereby generating a feasible solution sequence of chaotic variables. Calculate the fitness value of each feasible solution vector and screen out the optimal feasible solution vector. Return the optimal feasible solution vector to all the particles until the maximum number of iterations is reached or the optimal solution is obtained. The optimal solution is the maximum fitness value. The finally output optimal solution is particle p g (n i ,n j ).

[0133] The chaotic optimization process is also an iterative process. It is necessary to set the accuracy requirement for jumping out of the iteration and the number of chaotic iterations. In the present invention, the determination requirement for jumping out of the iteration in chaotic optimization is whether the result of this optimization is the optimal accuracy of all sent into chaotic optimization, that is, the optimal solution.

[0134] Use the chaotic particle swarm optimization algorithm accelerated by the quasi-Newton method to optimize the Kapur threshold image segmentation method. The Kapur threshold image segmentation method performs threshold segmentation on grayscale images, which is specifically implemented through the following steps:

[0135] A. Set the number of chaotic iterations M. Map the g-th global extreme value p g to the domain [0,1] of the logistic equation:

[0136] In the formula, is the sequence element obtained in the first iteration, is the global extreme value of the particle swarm, is the minimum value of the particle position range, is the maximum value of the particle position range;

[0137] B. After performing M iterations accelerated by the quasi-Newton method through the logistic equation , obtain the chaotic sequence

[0138] In the formula, is the sequence element obtained in the (n + 1)-th iteration, and μ is the control parameter. is the sequence element obtained in the M-th iteration;

[0139] C, inverse-map the chaotic sequence back to the original solution space through the following formula to obtain a sequence of feasible solutions of chaotic variables

[0140] where is the sequence element obtained in the m-th iteration;

[0141] H, calculate the fitness value of each feasible solution vector in the sequence of feasible solutions of chaotic variables, and obtain the maximum value of the fitness corresponding to the feasible solution vector according to the characteristics of Kapur entropy threshold segmentation;

[0142] I, if m ≥ 2, then judge whether the maximum value of the current fitness is greater than the maximum value of the previously obtained fitness. If the maximum value of the current fitness is greater than the maximum value of the previously obtained fitness, then take the maximum value of the current fitness as the optimal fitness value;

[0143] F, judge whether the optimal fitness value reaches the set accuracy or whether the current iteration number reaches the set maximum number of chaotic iterations; if the optimal fitness value reaches the set accuracy or the current iteration number reaches the set maximum number of chaotic iterations, then go to step 9, otherwise go to step B.

[0144] Step 9 is implemented through the following steps:

[0145] Step 11, randomly select a particle individual from the particle swarm, and use the feasible solution vector corresponding to the optimal fitness value to replace the feasible solution vector of this particle individual;

[0146] Step 12, calculate the fitness values of all particles in the particle swarm;

[0147] Step 13, if the fitness values of all particles in the particle swarm reach the accuracy set for the particle swarm or the current iteration number reaches the set maximum number of iterations of the particle swarm, then output the optimal solution, otherwise go to step 11.

[0148] The algorithm flow of the quasi-Newton method

[0149] a. Given parameters δ ∈ (0, 1), σ ∈ (0, 0.5), initialize the point p0 0 ∈ θ n with a termination error 0 ≤ ∈ ≤ 1, initialize the symmetric positive definite matrix B 0 which is usually taken as the identity matrix I n and p0 0 is the initialization point, θ is a real number, ∈ is the termination error, and B 0is a positive definite matrix, po ξ is the initialization point, τ ξ is the gradient, is the function for calculating the gradient, w ξ is the search direction, B ξ is a positive definite matrix, since ξ = 0, δ ρ is the set constant parameter, H(.) is the Kapur entropy function, σ is the set constant parameter, a ξ is the set constant parameter;

[0150] b. Calculate If ||τ ξ || << ∈, then terminate and output po ξ as the approximate minimum point, and let ξ = 0.

[0151] c. Determine the search direction w ξ = -B ξ *τ ξ .

[0152] d. Let ρ ξ be the smallest non - negative integer ρ that satisfies the following inequality:

[0153]

[0154] Let a ξ = δ ρξ , po ξ+1 = po ξ + a ξ w ξ

[0155] e. Determine B by the correction formula ξ+1

[0156] f. Go to step b.

[0157] Verify the effectiveness of the improved particle swarm algorithm: Table 1 compares the running time and accuracy of the entropy function optimized by the standard particle swarm algorithm and the entropy function optimized by a chaotic particle swarm algorithm accelerated by a quasi - Newton method used in the present invention. Figure 3 is the comparison chart of the convergence speed of the standard particle swarm algorithm and the chaotic particle swarm algorithm accelerated by the quasi - Newton method of the present invention. Figure 4 , Figure 5 , Figure 6 and Figure 7 are respectively the original image of the magnetic material, the threshold segmentation image obtained by the entropy function, the threshold segmentation image optimized by the standard particle swarm algorithm, and the threshold segmentation image optimized by the improved particle swarm algorithm of the present invention. In the experiment, the picture resolution is set to 512×512.

[0158] As can be seen from the experimental results, a chaotic particle swarm optimization algorithm based on quasi-Newton method acceleration proposed by the present invention is faster in terms of running time than the other two methods while ensuring accuracy, which proves the superiority and effectiveness of the algorithm of the present invention and has more application value in the processing of magnetic material pictures. The table is as follows:

[0159] Table 1

[0160]

[0161] This application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple blocks.

[0162] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple blocks.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple blocks.

[0164] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the technical principles of the present invention, several improvements and deformations can be made, and these improvements and deformations should also be regarded as the protection scope of the present invention.

Claims

1. An image threshold segmentation method based on improved chaotic particle swarm, characterized in that, it includes: Step 1, preprocess the image to obtain a grayscale image; Step 2, initialize the particle swarm and calculate the fitness value of each particle individual; Step 3, update the individual extreme value of the particle and the global extreme value of the particle based on the fitness value of the particle individual; Step 4, iteratively update the position and velocity of the particle individual; Step 5, calculate the threshold segmentation contribution degree of the particle individual; Step 6, screen and obtain elite particles according to the threshold segmentation contribution degree of the particle individual; Step 7, perform iterative chaotic optimization based on quasi-Newton method acceleration on the elite particles, perform threshold segmentation on the grayscale image, and obtain the optimal fitness value; Step 8, determine whether the current chaotic iteration times meet the set maximum chaotic iteration times or whether the chaotic optimization reaches the set accuracy. If the current chaotic iteration times meet the set maximum chaotic iteration times or the chaotic optimization reaches the set accuracy, then enter Step 9, otherwise enter Step 7; Step 9, inverse map the optimal fitness value back to the particle swarm cluster, calculate the fitness values of all particles in the particle cluster. If the set conditions are met, output the optimal solution, otherwise enter Step 2; Steps 7 and 8 are implemented through the following steps: A, set the number of chaotic iterations M, and map the g-th global extreme value onto the domain [0, 1] of the logistic equation: ; where, is the sequence element obtained in the first iteration, is the global extreme value of the particle swarm, is the minimum value of the particle position range, is the maximum value of the particle position range; B, After M iterations accelerated by the quasi - Newton method through the logistic equation a chaotic sequence is obtained , wherein, is the sequence element obtained in the (n + 1)-th iteration, μ is the control parameter, is the sequence element obtained in the M-th iteration; C, inverse-map the chaotic sequence back to the original solution space through the following formula to obtain a sequence of feasible solutions of the chaotic variables : In the formula, is the sequence element obtained in the m-th iteration; D, calculate the fitness value of each feasible solution vector in the feasible solution sequence of the chaotic variable, and obtain the maximum value of the fitness corresponding to the feasible solution vector according to the characteristics of Kapur entropy threshold segmentation; E, if m≥2, then determine whether the maximum value of the current fitness is greater than the maximum value of the previously obtained fitness. If the maximum value of the current fitness is greater than the maximum value of the previously obtained fitness, then use the maximum value of the current fitness as the optimal fitness value; F, determine whether the optimal fitness value reaches the set accuracy or whether the current iteration times reach the set chaotic iteration times; if the optimal fitness value reaches the set accuracy or the current iteration times reach the set chaotic iteration times, then enter Step 9, otherwise enter Step B.

2. The image threshold segmentation method based on improved chaotic particle swarm according to claim 1, characterized in that, Step 2, initialize the particle swarm and calculate the fitness value of the particle individual, which is implemented through the following steps: In a D-dimensional target search space, initialize the total number of particle individuals in the particle swarm m , the positions of particle individuals, and the velocities of particle individuals ; Divide the target and background in the grayscale image and calculate the fitness value of the current particle individual: Calculate each gray level j The probability of occurrence in the grayscale image U j : ; where: L represents the gray level, where L ranges from [1, 255], is the j-th gray level; Calculate the entropy values of the target and the background: ; where H 0 represents the entropy value of the target, H 1 represents the entropy value of the background, represents the cumulative probability of the target pixels in the grayscale image, represents the cumulative probability of the background pixels in the grayscale image, and the sum of the two is 1, t is the set threshold value; Calculate the total entropy of a grayscale image H(t) : H(t)= , Take the threshold t corresponding to the maximum value of H(t) as the optimal threshold; Take the pixels in the grayscale image with gray levels greater than the optimal threshold as the target, and take the pixels in the grayscale image with gray levels less than or equal to the optimal threshold as the background; Let be the i th particle 's D dimensional position vector, and use the Kapur entropy function as the fitness function; Calculate the fitness value of the current particle individual according to the kapur entropy function.

3. The image threshold segmentation method based on improved chaotic particle swarm according to claim 1, characterized in that, Step 4, iteratively update the position and velocity of the particle individual, which is implemented through the following steps: Update the velocity and position of the particle individual according to the following formula: Among them, is the velocity of the (k + 1)-th iteration of the i -th particle individual, ω is the inertia weight, is the position of the (k + 1)-th iteration of the i -th particle individual, is the personal best of the i -th particle individual, is the global best of the g-th, k is the current iteration number, and are random numbers between; and are learning factors, is the position of the i -th particle individual at the k -th iteration; the calculation formula of the inertia weight is: In the formula, ω max is the maximum inertia weight value, ω min is the minimum inertia weight value, is the set total number of iterations.

4. The image threshold segmentation method based on improved chaotic particle swarm according to claim 1, characterized in that, Step 5, calculate the threshold segmentation contribution degree of each particle individual, which is implemented through the following steps: In the formula, z is the distance difference between the i ith particle individual and the particle individual corresponding to the global extreme value, e gbest is the abscissa of the particle individual corresponding to the global extreme value in the target search space, s gbest is the ordinate of the particle individual corresponding to the global extreme value in the target search space, e i is the i abscissa of the ith particle individual in the target search space, s i is the i ordinate of the ith particle individual in the target search space, m is the total number of particle individuals, ACD is the threshold segmentation contribution degree of each particle individual.

5. A method for image threshold segmentation based on an improved chaotic particle swarm according to claim 4, characterized in that, Step 6, screen and obtain elite particles according to the threshold segmentation contribution degree of each particle individual, which is implemented through the following steps: Select a set proportion of particle individuals as elite particles in descending order of the threshold segmentation contribution degree.

6. A method for image threshold segmentation based on an improved chaotic particle swarm according to claim 1, characterized in that, Step 9, which is implemented through the following steps: Step 11, randomly select a particle individual from the particle swarm, and use the feasible solution vector corresponding to the optimal fitness value to replace the feasible solution vector of this particle individual; Step 12, calculate the fitness values of all particles in the particle swarm; Step 13, if the fitness values of all particles in the particle swarm reach the accuracy set by the particle swarm or the current iteration number reaches the set maximum iteration number of the particle swarm, then output the optimal solution, otherwise enter Step 11.

7. A method for image threshold segmentation based on an improved chaotic particle swarm according to claim 1, characterized in that, Step 1, preprocess the image to obtain a grayscale image, which is implemented through the following steps: Perform grayscale transformation, Gaussian filtering, and logarithmic transformation on the image; Use the weighted mean method for grayscale transformation; In Gaussian filtering, use the two-dimensional Gaussian distribution function as the smoothing filter for the grayscale image.

8. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, when the processor executes the program, it implements the steps of the method according to any one of claims 1 to 7.

9. A computer-readable storage medium, on which a computer program is stored, characterized in that, when the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Multi-target reactive power optimization method based on adaptive chaos particle swarm algorithm

    CN103972908A

  • Hybrid global optimization method

    CN108133258A