Image multistage threshold segmentation method based on improved whale optimization algorithm

Through the improved whale optimization algorithm, including shrinkage encirclement, spiral update and random search stages, the problem of optimal threshold solution in image multi-threshold segmentation is solved, the algorithm development capability and efficiency are improved, and the local optimal trap is avoided.

CN119540272AInactive Publication Date: 2025-02-28NORTHEAST AGRICULTURAL UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410597817.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-14
Publication Date
2025-02-28
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art is difficult to find the optimal threshold for image multi-threshold segmentation in a short time, and the algorithm exploration and development capabilities are insufficient, resulting in difficult acceptance of the calculation amount and time.

Method used

The improved whale optimization algorithm is adopted, including the shrinkage encirclement stage, the spiral update position stage and the random search stage. The optimal segmentation threshold of the image is obtained through population initialization, objective function calculation, position update, combined variation operation and desimilation operation.

Benefits of technology

Finding the optimal threshold for image multi-threshold segmentation in a short time improves the algorithm's development ability, balances exploration and development capabilities, and avoids the algorithm from falling into local optimality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540272A_ABST
    Figure CN119540272A_ABST
Patent Text Reader

Abstract

The invention discloses an image multi-level threshold segmentation method based on an improved whale optimization algorithm, and belongs to the technical field of image processing. The method comprises the following steps: initializing a population; calculating a target function value, and finding out the optimal whale position Xbest of the population; updating the position of the whale in the population; performing combined mutation operation based on individual fitness values; similarity removal operation is carried out, and similar individuals are judged according to the difference between the target function values and the distances corresponding to the two individuals; the fitness value of the whale is recalculated, the optimal individual Xbest of the population is updated, and an optimal threshold value is obtained; outputting a global optimal threshold, and segmenting the image by using the global optimal threshold; and outputting the segmented image. The method has the beneficial effects that the development capability of the algorithm is improved by adaptively adjusting the parameters # imgabs0 # and # imgabs1 # in the contraction surrounding stage; the problem that the whale in the population in the later iteration stage is not subjected to position updating in the random search stage is solved, and the algorithm is prevented from falling into local optimum.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image processing, in particular to an image multi-level threshold segmentation method based on an improved whale optimization algorithm. Background Art

[0002] Image segmentation is the process of dividing an image into several regions with different characteristics and extracting the target region of interest. It is the premise of image processing and pattern recognition. At present, image segmentation technology is widely used in remote sensing satellites, intelligent transportation, agriculture, medical health, aerospace technology and other fields. Commonly used image segmentation methods include: threshold segmentation method, region extraction method, clustering segmentation method and deep learning-based segmentation method. The threshold segmentation method has become the most basic and widely used image segmentation technology in image segmentation due to its simple calculation, high computational efficiency and stable performance. The threshold segmentation method can be divided into two methods according to the number of thresholds: single threshold segmentation and multi-threshold segmentation. Single threshold segmentation only requires one threshold to segment the image into target and background; multi-threshold segmentation requires determining multiple thresholds to segment the image into multiple regions. Since the threshold directly affects the result of image segmentation, the threshold also directly affects the final effect of image processing and pattern recognition. Therefore, the difficulty and key of the threshold segmentation method lies in solving the optimal threshold.

[0003] Multi-threshold segmentation is a complex optimization problem. In order to improve the effect of image threshold segmentation, the number of thresholds is often large. The calculation amount and calculation time of the traditional optimization method to solve the optimal threshold are unacceptable. However, the intelligent optimization algorithm can obtain the approximate optimal solution of multiple thresholds in a short time. Therefore, in recent years, intelligent optimization methods have been widely used in image threshold segmentation. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide an image multi-level threshold segmentation method based on an improved whale optimization algorithm, which can obtain the optimal threshold in a relatively short time and better balance the exploration and development capabilities of the algorithm in view of the shortcomings of the prior art.

[0005] The technical problem to be solved by the present invention is achieved through the following technical scheme. The present invention is a method for multi-level threshold segmentation of an image based on an improved whale optimization algorithm, which is characterized by: inputting an image to be segmented, and obtaining the optimal segmentation threshold of the image using the improved whale optimization algorithm; the improved whale optimization algorithm includes a shrinking and surrounding stage, a spiral position update stage and a random search stage, and specifically includes the following steps:

[0006] Step 1: Population initialization, assuming that the population size is n and the i-th individual in the population is X i =(x i1 ,x i2 ,…,x ij ,…,xid ) T (i=1,2,…,n;j=1,2,…,d), d is the dimension of the variable;

[0007] Step 2: Calculate the objective function value and find the best whale position X in the population best ;

[0008] Step 3: Update the position of whales in the population: Generate a random number P and determine the range of the random number P; if the random number P < 0.5, select an operator to determine whether the whale chooses to update its position in the shrinking and encircling phase or the random search phase; if the random number P ≥ 0.5, select the spiral position update phase to update the whale's position;

[0009] The selection operator is to set a probability coefficient p1 that changes from small to large. When the generated random number P is less than p1, the whale updates its position according to the random search stage, otherwise it updates its position according to the shrinking and encircling stage. The calculation formula of the probability coefficient p1 is as follows:

[0010]

[0011] In the formula, t is the current iteration number, T is the maximum iteration number, and p max is the maximum probability coefficient, p min is the minimum probability coefficient, usually p max =0.5, p min =0.25;

[0012] Step 4: Based on the combined mutation operation of individual fitness values, when the iteration number t = 1, the i-th (i = 1, 2, ..., n) whale in the population uses formula X i '(t) = X r1 (t)+λ(X r2 (t)-X r3 (t)) is mutated. If the fitness value of the ith whale after mutation is better than before mutation, then b i =1; otherwise, let b i =0; when the number of iterations t>1, if b i = 1, the i-th whale in the population chooses to use X i '(t) = X r1 (t)+λ(X r2 (t)-X r3 (t)) to mutate; otherwise, if bi = 0, choose to use X i '(t) = X best (t)+λ(X r1 (t)-X r2(t)) to mutate; if the fitness value of the ith whale after mutation is better than before mutation, then let b i =1; otherwise, let b i =0;

[0013] Step 5, the desimilarity operation, determines similar individuals by the difference between the objective function value and the distance corresponding to the two individuals. The desimilarity operation includes the following steps:

[0014] ① Sort the whales in the population according to the objective function value from small to large;

[0015] ②Calculate individual X i and X j The corresponding objective function value f i and f j Difference and distance Dist ij

[0016] f i -f j |i=1,2,…,n-1; j=i+1,i+2,…,n

[0017]

[0018] In the formula, n is the population size, X i =(x i1 ,x i2 ,…,x id ), X j =(x j1 ,x j2 ,…,x jd ), ε1 and ε2 are two smaller constants;

[0019] ③If |f i -f j |≤ε1,Dist ij ≤ε2, then X i and X j For similar individuals, keep X i , X j Randomly generated;

[0020] Step 6: Recalculate the fitness value of the whale and update the optimal individual X of the population best , obtain the optimal threshold;

[0021] Step 7: If the termination condition is not met, return to step 1, otherwise, proceed to the next step;

[0022] Step 8: Output the global optimal threshold and use it to segment the image;

[0023] Step 9: Output the segmented image.

[0024] The technical problem to be solved by the present invention can also be further achieved by the following technical solution. The position update formula in the shrinking and surrounding stage determines the local search capability of the whale optimization algorithm. The position update formula in the shrinking and surrounding stage is:

[0025]

[0026]

[0027] Where t is the current iteration number, and is the coefficient vector, Represents the multiplication of the elements at the same position of two vectors.

[0028] The technical problem to be solved by the present invention can also be further achieved by the following technical solution: in the position update formula of the shrinking and surrounding stage, the parameter and Adopting adaptive adjustment method, after adjustment The range of each component in is [-1,1]. The range of each component in is [0,1].

[0029] The technical problem to be solved by the present invention can also be further achieved by the following technical solution. The position update formula in the spiral update stage is:

[0030]

[0031] Where μ is the scaling factor, b is a constant used to define the shape of the logarithmic spiral, and l is a random number between [-1,1]. is the distance between the ith whale and its prey, Represents the multiplication of the elements at the same position of two vectors.

[0032] Compared with the prior art, the present invention has the following beneficial effects:

[0033] (1) The reasons why the position update formulas in the shrinking and encircling phase and the spiral updating phase lead to weak algorithm development capabilities are analyzed. To address these reasons, the parameters of the shrinking and encircling phase are adjusted. and Adaptive adjustments were made to improve the algorithm's development capabilities.

[0034] (2) Through a combined mutation operator based on the advantages and disadvantages of individual fitness values, the algorithm's exploration and development capabilities are better balanced.

[0035] (3) A selection operator is proposed to choose between the two position update formulas, which solves the problem that whales in the population do not update their positions in the random search phase in the late iteration and avoids the algorithm from falling into local optimality.

[0036] (4) A method for judging similar individuals based on the difference and distance between the objective function values ​​of two individuals is proposed, which avoids the misjudgment of similar individuals, helps to better maintain the diversity of the population, and increases the possibility of producing excellent offspring. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is the overall flow chart of the present invention. DETAILED DESCRIPTION

[0038] The specific technical solutions of the present invention are further described below to help those skilled in the art further understand the present invention without limiting the rights thereof.

[0039] An image multi-level threshold segmentation method based on an improved whale optimization algorithm is characterized in that it includes inputting an image to be segmented and using the improved whale optimization algorithm to obtain the optimal image segmentation threshold; the improved whale optimization algorithm includes a shrinking and surrounding stage, a spiral position update stage and a random search stage, and the optimization process of the whale optimization algorithm is to randomly generate n whales in the search space to form an initial population; secondly, randomly generate a random number to determine whether the whale is performing a spiral position update, shrinking and surrounding, or randomly searching for food;

[0040] The specific steps include:

[0041] Step 1: Population initialization, assuming that the population size is n and the i-th individual in the population is X i =(x i1 ,x i2 ,…,x ij ,…,x id ) T (i=1,2,…,n;j=1,2,…,d), d is the dimension of the variable.

[0042] Step 2: Calculate the objective function value and find the best whale position X in the population best .

[0043] Step 3: Update the position of whales in the population: Generate a random number P and determine the range of the random number P; if the random number P < 0.5, select an operator to determine whether the whale chooses to update its position in the shrinking and encircling phase or the random search phase; if the random number P ≥ 0.5, select the spiral position update phase to update the whale's position;

[0044] The selection operator is to set a probability coefficient p1 that changes from small to large. When the generated random number P is less than p1, the whale updates its position according to the random search stage, otherwise it updates its position according to the shrinking and encircling stage. The calculation formula of the probability coefficient p1 is as follows:

[0045]

[0046] In the formula, t is the current iteration number, T is the maximum iteration number, and p max is the maximum probability coefficient, p min is the minimum probability coefficient, usually p max =0.5, p min =0.25.

[0047] Since the value of p1 decreases nonlinearly from 0.5 to 0.25 as the number of iterations increases, the probability of random search in the early stage of iteration is greater than that in the later stage of iteration, which better balances the global exploration and development capabilities of the algorithm.

[0048] Step 4: Based on the combined mutation operation of individual fitness values, when the iteration number t = 1, the i-th (i = 1, 2, ..., n) whale in the population uses formula X i '(t) = X r1 (t)+λ(X r2 (t)-X r3 (t)) is mutated. If the fitness value of the ith whale after mutation is better than before mutation, then b i =1; otherwise, let b i =0; when the number of iterations t>1, if b i = 1, the i-th whale in the population chooses to use X i '(t) = X r1 (t)+λ(X r2 (t)-X r3 (t)) to mutate; otherwise, if bi = 0, choose to use X i '(t) = X best (t)+λ(X r1 (t)-X r2 (t)) to mutate; if the fitness value of the ith whale after mutation is better than before mutation, then let b i =1; otherwise, let b i =0; where λ is the step size, r1,r2,r3∈{1,2,…,n}, and r1≠r2≠r3≠i, X best (t) is the optimal whale in the t-th generation population. The calculation formula of λ is: Where t is the current iteration number and T is the maximum iteration number.

[0049] The combined mutation operator based on the individual fitness value does not need to judge when the algorithm is in the early and late stages of the iteration. Instead, it adaptively selects a single mutation operator based on the historical contribution of the single mutation operator, that is, the improvement of the solution. Except for the first iteration, each whale in the population may use a different single mutation operator in each iteration.

[0050] Step 5: De-similarity operation, judging similar individuals by the difference between the objective function value and the distance between two individuals. The de-similarity operation includes the following steps:

[0051] ① Sort the whales in the population from small to large according to the objective function value.

[0052] ②Calculate individual X i and X j The corresponding objective function value f i and f j Difference and distance Dist ij

[0053] f i -f j |i=1,2,…,n-1; j=i+1,i+2,…,n

[0054]

[0055] In the formula, n is the population size, X i =(x i1 ,x i2 ,…,x id ), X j =(x j1 ,x j2 ,…,x jd ), ε1 and ε2 are two smaller constants;

[0056] ③If |f i -f j |≤ε1,Dist ij ≤ε2, then X i and X j For similar individuals, keep X i , X j Randomly generated.

[0057] Step 6: Recalculate the fitness value of the whale and update the optimal individual X of the population best , get the optimal threshold.

[0058] Step 7: If the termination condition is not met, return to step 1; otherwise, proceed to the next step.

[0059] Step 8: Output the global optimal threshold and use it to segment the image.

[0060] Step 9: Output the segmented image.

[0061] Since the prey is the best individual in the population, whales that are close to the prey are more likely to improve the quality of the solution. After the whale updates its position, it should try to keep its position around the prey. The position of the whale in space after the position update in the shrinking and surrounding phase is related to the coefficient and The absolute values ​​of the components in the product are related. and If the absolute value of each component in the product is large, the updated position of the whale will be far away from the prey, and the local search ability of the algorithm will be weak; otherwise, the updated position of the whale will be close to the prey, and the local search ability of the algorithm will be strong. Therefore, the position update formula in the shrinking and encircling stage determines the local search ability of the algorithm.

[0062] The position update formula in the shrinking and encircling phase determines the local search capability of the whale optimization algorithm. Let X * is the location of the prey, that is, the location of the best whale individual in the population, X i is the position of the i-th whale in the population, and the position update formula in the shrinking and encircling stage is

[0063]

[0064]

[0065] Where t is the current iteration number, and is the coefficient vector, Represents the multiplication of the elements at the same position of two vectors.

[0066] In the position update formula of the shrinking and encircling stage, the parameter and Adopting adaptive adjustment method, after adjustment The range of each component in is [-1,1]. The variation range of each component in is [0,1]; the specific adaptive parameter adjustment formula is as follows:

[0067]

[0068]

[0069]

[0070] Where t is the current iteration number, T is the maximum iteration number, and r1 and r2 are random vectors between [0,1].

[0071] In the position update formula of the random search phase, X r is a whale randomly selected from the population, X i Force whale X after updating position j Leave the prey and head towards a randomly selected whale X r Moving towards the prey instead of moving towards the prey improves the algorithm's exploration ability and reduces the possibility of the algorithm falling into a local optimum. Since the roulette wheel selection operator can select whales with large fitness values ​​from the population with a high probability, the roulette wheel selection operator is used to randomly select a whale X from the population. r Participate in position update. The position update formula in the random search phase is:

[0072]

[0073]

[0074] In the formula, X r is the rth whale randomly selected from the population, and r≠i.

[0075] In order to explain the position of the whale after the spiral update, let the whale whose position needs to be updated be X. i , the best whale in the population, i.e. prey, is X best If l is a constant, after updating X i The position is at X i and X best If l is connected to X i The same dimension of the phasor, X i The updated positions are distributed in the search space, not just in X i and X best In addition, The absolute value of each component in X i The updated position distribution also has a great impact. i The distribution of whales in the search space after the updated position introduces a scaling factor μ, which is calculated as follows:

[0076]

[0077] In the formula, μ max is the maximum scaling factor, μ min is the minimum scaling factor, t is the current number of iterations, and T is the maximum number of iterations.

[0078] After introducing the scaling factor μ, the improved spiral position update formula is as follows:

[0079]

[0080] Where b is a constant used to define the shape of the logarithmic spiral, l is a random vector between [-1,1], is the distance between the ith whale and its prey.

[0081] When solving the problem of multi-level threshold segmentation of an image, the maximum inter-class variance (Otsu) and the maximum entropy value (Kapur) are used as the objective function for solving the optimal threshold. The evaluation indicators for evaluating the image segmentation effect are: peak signal-to-noise ratio (PSNR), mean square error (MSE), structural similarity (SSIM), and feature similarity (FSIM). The larger the values ​​of PSNR and SSIM, the lower the degree of distortion of the segmented image and the higher the quality of the segmented image. The lower the MSE value, the larger the FSIM value, and the lower the misclassification rate.

Claims

1. A multi-level threshold segmentation method for images based on an improved whale optimization algorithm, characterized in that: The method includes inputting an image to be segmented and obtaining an optimal segmentation threshold of the image using an improved whale optimization algorithm; the improved whale optimization algorithm includes a shrinking and encircling stage, a spiral position update stage and a random search stage; and specifically includes the following steps: Step 1: Population initialization, assuming that the population size is n and the i-th individual in the population is X i =(x i1 ,x i2 ,…,x ij ,…,x id ) T (i=1,2,…,n;j=1,2,…,d), d is the dimension of the variable; Step 2: Calculate the objective function value and find the best whale position X in the population best ; Step 3: Update the position of whales in the population: generate a random number P and determine the range of the random number P; if the random number P < 0.5, determine whether the whale chooses to update its position in the shrinking and encircling phase or the random search phase by selecting an operator; If the random number P ≥ 0.5, the spiral position update phase is selected to update the whale position; The selection operator is to set a probability coefficient p1 that changes from small to large. When the generated random number P is less than p1, the whale updates its position according to the random search stage; otherwise, it updates its position according to the shrinking and surrounding stage. The calculation formula of the probability coefficient p1 is as follows: In the formula, t is the current iteration number, T is the maximum iteration number, and p max is the maximum probability coefficient, p min is the minimum probability coefficient, p max =0.5, p min =0.25; Step 4: Based on the combined mutation operation of individual fitness values, when the iteration number t = 1, the i-th (i = 1, 2, ..., n) whale in the population uses formula X i '(t) = X r1 (t)+λ(X r2 (t)-X r3 (t)) is mutated. If the fitness value of the ith whale after mutation is better than before mutation, then b i =1; otherwise , let b i =0; when the number of iterations t>1, if b i = 1, the i-th whale in the population chooses to use X i '(t) = X r1 (t)+λ(X r2 (t)-X r3 (t)) to mutate; otherwise, if bi = 0, choose to use X i '(t) = X best (t)+λ(X r1 (t)-X r2 (t)) to mutate; if the fitness value of the ith whale after mutation is better than before mutation, then let b i =1; Otherwise, let b i =0; Step 5: De-similarity operation, judging similar individuals by the difference between the objective function value and the distance corresponding to two individuals. The de-similarity operation includes the following steps: ① Sort the whales in the population according to the objective function value from small to large; ②Calculate individual X i and X j The corresponding objective function value f i and f j Difference and distance Dist ij |f i -f j |i=1,2,…,n-1;j=i+1,i+2,…,n In the formula, n is the population size, X i =(x i1 ,x i2 ,…,x id ), X j =(x j1 ,x j2 ,…,x jd ), ε1 and ε2 are two smaller constants; ③If |f i -f j |≤ε1,Dist ij ≤ε2, then X i and X j For similar individuals, keep X i , X j Randomly generated; Step 6: Recalculate the fitness value of the whale and update the optimal individual X of the population best ; Step 7: If the termination condition is not met, return to step 1; otherwise, proceed to the next step; Step 8: Output the global optimal threshold and use it to segment the image; Step 9: Output the segmented image.

2. The image multi-level threshold segmentation method based on the improved whale optimization algorithm according to claim 1 is characterized in that: The position update formula in the shrinking and surrounding stage is: Where t is the current iteration number, and is the coefficient vector, Represents the multiplication of the elements at the same position of two vectors.

3. The image multi-level threshold segmentation method based on the improved whale optimization algorithm according to claim 2 is characterized in that: In the position update formula of the shrinking and encircling stage, the parameter and Adopting adaptive adjustment method, after adjustment The range of each component in is [-1,1]. The range of each component in is [0,1].

4. The image multi-level threshold segmentation method based on the improved whale optimization algorithm according to claim 1 is characterized in that: The position update formula in the spiral update phase is: Where μ is the scaling factor, b is a constant used to define the shape of the logarithmic spiral, and l is a random number between [-1,1]. is the distance between the ith whale and its prey, Represents the multiplication of the elements at the same position of two vectors.

Citation Information

Cited By

  • Method, device and equipment for determining segmentation threshold value of part image

    CN120198457A