An image segmentation method based on improved melolontha optimization algorithm
By combining the improved dung beetle optimization algorithm with Otsu entropy thresholding, and utilizing non-standard Tent chaotic mapping and adaptive weight opposition learning strategy, the problem of poor image segmentation performance in multi-threshold segmentation is solved, achieving higher quality and faster image segmentation results.
Patent Information
- Application Number
- CN202410438414.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-12
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2044-04-12
AI Technical Summary
Existing image segmentation methods struggle to achieve high-quality segmentation results while simultaneously finding the optimal threshold in multi-threshold segmentation, especially when the background is rich or there are many target elements, resulting in a significant drop in segmentation performance.
By combining the improved dung beetle optimization algorithm with the Otsu entropy thresholding method, the population is initialized through a non-standard Tent chaotic mapping. A nonlinear decreasing strategy and an adaptive weighted opposition learning strategy are introduced to optimize the search process of the dung beetle optimization algorithm and find the optimal threshold for the image.
It improves the quality and speed of image segmentation, enhances the robustness and solution accuracy of the algorithm, and can better avoid local optima, thus achieving higher quality image segmentation.
Smart Images

Figure CN118379310B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image segmentation technology, specifically relating to an image segmentation method based on an improved dung beetle optimization algorithm. Background Technology
[0002] Image segmentation is a key technology in computer vision, aiming to divide digital images into different regions or objects, making the image content easier to understand and analyze. In today's digital age, image segmentation technology plays a vital role in fields such as medical imaging, autonomous driving, and security monitoring. By segmenting images into regions with semantic context, useful information is extracted for tasks such as target detection, tracking, diagnosis, and analysis. The quality of image segmentation determines the final image processing result, and the quality of the segmentation algorithm has a significant impact on the segmentation outcome.
[0003] Otsu's technique, proposed by Japanese scholars in 1975, has been applied to image segmentation. Its core idea is to separate the foreground and background of an image based on its grayscale characteristics. A larger inter-class variance indicates a greater pixel difference between the foreground and background, leading to a more accurate segmentation threshold and better segmentation quality. Thresholding segmentation achieves segmentation by setting a threshold. However, inappropriate threshold selection can result in the inability to distinguish between foreground and background, hindering the extraction of the target segment. Furthermore, the segmentation effect significantly degrades when the background is rich or there are too many target elements. Increasing the number of thresholds, however, leads to richer image detail and higher segmentation quality, but also drastically increases the difficulty of image segmentation. Therefore, a method is needed in multi-threshold segmentation to ensure high-quality image segmentation while simultaneously finding the optimal threshold, a problem worthy of further research. Summary of the Invention
[0004] To address the aforementioned problems, this invention provides an image segmentation method based on an improved dung beetle optimization algorithm. This method combines the improved dung beetle optimization algorithm with the Otsu entropy thresholding method, using the improved dung beetle optimization algorithm to find the optimal threshold for image segmentation, thereby improving the segmentation quality and speed.
[0005] 1. An image segmentation method based on the improved dung beetle optimization algorithm (DADBO), the steps of which include the following:
[0006] S1. Obtain the image to be segmented, and convert the obtained non-grayscale image into a grayscale image;
[0007] S2. Initialize the initial population size N based on the dung beetle optimization algorithm, the maximum number of iterations M, and set the threshold number Dim for segmentation.
[0008] S3. Based on the set threshold number Dim, randomly generate N dung beetle individuals in the grayscale image search space. The information carried by each dung beetle individual is the threshold number Dim of the segmented image. Use non-standard Tent chaotic mapping to initialize the dung beetle population position so that it is evenly distributed in the search space. Divide the dung beetle population into four groups: rolling dung beetle, female dung beetle, small dung beetle, and thieving dung beetle.
[0009] S4. Optimize the image grayscale value with the maximum inter-class variance as the objective function based on the improved dung beetle optimization algorithm; calculate the fitness value of each dung beetle and record the positions of the best and worst dung beetle individuals; the formula for calculating the maximum inter-class variance is:
[0010]
[0011] Where σ 2 For the maximum inter-class variance, ω i μ represents the proportion of each grayscale value in the image, and μ is the overall average grayscale value of the grayscale image. i Let L be the average gray value within the i-th threshold segmentation, where L is the maximum gray level of the image.
[0012] S5. A non-linear decreasing strategy is introduced to adjust the search boundaries of small dung beetles and female dung beetles, thereby accelerating the search speed in the early stages of the algorithm.
[0013] S6. An adaptive weighted opposition learning strategy and a greedy selection strategy are introduced to update the optimal food source location for the dung beetle, increasing its chances of escaping local optima.
[0014] S7. Determine if the maximum number of iterations has been reached. If yes, output the optimal threshold based on the information carried by the optimal dung beetle individual optimized by the dung beetle, and perform image segmentation based on the obtained optimal threshold to output the best multi-threshold segmentation image; otherwise, proceed to S4.
[0015] Furthermore, in step S3, the initial population is treated using a non-standard Tent chaotic mapping formula as follows:
[0016]
[0017] Where the parameter η = 0.3, x i Let x be the normalized value of the i-th dung beetle individual. i+1 The value after performing a non-standard Tent chaotic mapping on the (i+1)th dung beetle individual.
[0018] Furthermore, in step S5, a nonlinear decreasing strategy is introduced to update the search boundaries for the female dung beetle and the dung beetle. This strategy aims to optimize the search process of the algorithm by rapidly reducing the search boundary speed in the early stages of iteration to accelerate the search; while gradually increasing the boundary weight in the later stages of the algorithm, thereby prompting the female dung beetle and the dung beetle to explore the search space more fully, so as to achieve convergence to the global optimum. The formula for the nonlinear decreasing strategy is:
[0019] R = exp((-7) × t) / (2 × M))
[0020] Where t is the current iteration number and M is the maximum iteration number of the dung beetle optimization algorithm.
[0021] Furthermore, in step S6, an adaptive weighted opposition learning strategy and a greedy selection strategy are introduced to steal the dung beetle's optimal food source for updating. The adaptive weighted opposition learning strategy borrows from the basic opposition learning strategy, integrating the concept of opposition into the search process of the image segmentation task. By introducing opposition learning elements, the algorithm can simultaneously consider candidate solutions and their opposition learning solutions, thereby achieving a more comprehensive and in-depth exploration in the search space. This opposition learning mechanism can not only accelerate the convergence speed of the algorithm, but also help the algorithm better avoid local optima, thereby improving the quality and accuracy of the image segmentation results. The formula for the adaptive weighted opposition learning strategy is as follows:
[0022] X OD =X + w × p × (q × X0 - X)
[0023] Where parameters p and q are random numbers between [0,1] following a normal distribution, weight w is a random integer between [0,5], X is the original individual, X0 is the position of the standard complementary solution generated by the candidate solution X, and X... OD An adaptive weighted opposition learning solution is generated for the candidate solution X;
[0024] The specific formula for the greedy selection strategy is as follows:
[0025]
[0026] Where Gbest represents the optimal dung beetle individual generated in a certain iteration of the dung beetle optimization algorithm. OD The optimal dung beetle for this iteration is the optimal dung beetle updated after adaptive weight opposition learning, where fit(Gbest) and fit(Gbest) are the optimal dung beetle individuals. OD Calculate the Gbest value for individual dung beetles and the Gbest value for individual dung beetles respectively. OD The fitness value of the dung beetle individual Gbest OD If the fitness value of a dung beetle is less than that of the dung beetle individual Gbest, then the best dung beetle individual is updated; otherwise, no update is performed.
[0027] Compared with the prior art, the beneficial effects of this invention are as follows:
[0028] First, this invention uses a non-standard Tent chaotic mapping to perform chaotic mapping on the initial population of the dung beetle optimization algorithm, which can improve the distribution uniformity of the initial population, thereby improving the algorithm's development capability; the convergence curves of female dung beetles and small dung beetles are modified to make them decrease non-linearly, increasing the exploration time of both during the exploration phase, while improving the overall convergence speed of the algorithm.
[0029] Secondly, an adaptive opposition learning method for generating optimal opposition solutions is proposed, which can expand the search range of optimal solutions, increase the robustness and accuracy of the algorithm, and enable the dung beetle optimization algorithm to find better solutions.
[0030] Finally, this invention combines the improved dung beetle optimization algorithm with the Otsu threshold segmentation method, using the improved dung beetle optimization algorithm to help find the optimal threshold for the image, thereby improving the segmentation quality of the image. Attached Figure Description
[0031] Figure 1 The flowchart of the improved algorithm proposed in this invention
[0032] Figures 2a-2e The images show the segmentation results of the "Lena" image using five algorithms: DADBO, DBO, SOA, WOA, and GWO, with a threshold of 6.
[0033] Figures 3a-3e The images show the segmentation results of the "car" image using five algorithms: DADBO, DBO, SOA, WOA, and GWO, with a threshold of 6.
[0034] Figures 4a-4e The images show the segmentation results of the "lighthouse" image using five algorithms: DADBO, DBO, SOA, WOA, and GWO, with a threshold of 6.
[0035] Figures 5a-5e The images show the segmentation results of the "Lena" image using five algorithms: DADBO, DBO, SOA, WOA, and GWO, with a threshold of 8.
[0036] Figures 6a-6e The images show the segmentation results of the "car" image using five algorithms: DADBO, DBO, SOA, WOA, and GWO, with a threshold of 8.
[0037] Figures 7a-7e The images show the segmentation results of the "lighthouse" image using five algorithms: DADBO, DBO, SOA, WOA, and GWO, with a threshold of 8. Implementation
[0038] To enable those skilled in the art to better understand the technical solution of the present invention, the technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0039] 1. Image segmentation based on an improved dung beetle optimization algorithm, the steps of which include the following:
[0040] S1. Obtain the image to be segmented, and convert the obtained non-grayscale image into a grayscale image;
[0041] S2. Initialize the initial population size N and the maximum number of iterations M based on the dung beetle optimization algorithm, and set the threshold number Dim to be segmented;
[0042] S3. Based on the set threshold number Dim, randomly generate N dung beetle individuals in the grayscale image search space [0, L-1]. The information carried by each dung beetle individual is the threshold for segmenting the image. Use a non-standard Tent chaotic mapping to initialize the dung beetle population position so that it is evenly distributed in the search space. Divide the dung beetle population into four groups. The proportions of the four groups are 20% rolling dung beetle, 20% female dung beetle, 30% small dung beetle, and 30% thieving dung beetle.
[0043] Initialize dung beetle population: X i ={X1,X2,...,X N};
[0044] Where i = {1, 2, ..., N}, the dung beetle population positions are initialized using a non-standard Tent chaotic map; the formula for the non-standard Tent chaotic map is:
[0045]
[0046] Where the parameter η = 0.3, x i Let x be the normalized value of the i-th dung beetle individual. i+1 The value after performing a non-standard Tent chaotic mapping on the (i+1)th dung beetle individual.
[0047] S4. Optimize the improved dung beetle optimization algorithm using the maximum inter-class variance as the objective function; calculate the fitness value of each dung beetle individual and record the positions of the best and worst dung beetle individuals; the formula for calculating the maximum inter-class variance is:
[0048]
[0049] Where σ 2 For the maximum inter-class variance, ω i μ represents the proportion of each grayscale value in the image, and μ is the overall average grayscale value of the grayscale image. i The average gray value within the i-th threshold is used for segmentation, where L is the maximum gray level of the image;
[0050] S5. A nonlinear decreasing strategy is introduced to adjust the search boundary for both dung beetles and female dung beetles. This strategy aims to optimize the algorithm's search process by rapidly reducing the search boundary speed in the early stages of iteration to accelerate the search; while gradually increasing the boundary weight in the later stages of the algorithm, thereby encouraging female and dung beetles to explore the search space more thoroughly to achieve convergence to the global optimum. The search boundary strategy for female and dung beetles is changed to:
[0051] R = e (((-7)×t) / (2×M))
[0052] Where t is the current iteration number, and M is the maximum iteration number of the dung beetle optimization algorithm;
[0053] S6. An adaptive weighted opposition learning strategy and a greedy selection strategy are introduced to update the algorithm by stealing the dung beetle's optimal food source. The adaptive weighted opposition learning strategy borrows from the basic opposition learning strategy, cleverly integrating the concept of opposition into the search process of the image segmentation task. By introducing opposition learning elements, the algorithm can simultaneously consider candidate solutions and their opposition-learned solutions, thereby achieving a more comprehensive and in-depth exploration in the search space. This opposition learning mechanism not only accelerates the convergence speed of the algorithm but also helps the algorithm better avoid local optima, thus improving the quality and accuracy of the image segmentation results. The formula for the adaptive weighted opposition learning strategy is as follows:
[0054] X OD =X + w × p × (q × X0 - X)
[0055] Where parameters p and q are random numbers between [0,1] following a normal distribution, weight w is a random integer between [0,5], X is the original dung beetle individual, X0 is the position of the standard complementary solution generated by the candidate solution X, and X... OD An adaptive weighted opposition learning solution is generated for the candidate solution X;
[0056] The specific formula for the greedy selection strategy is as follows:
[0057]
[0058] Where Gbest represents the optimal dung beetle individual generated in a certain iteration of the dung beetle optimization algorithm. OD The optimal dung beetle for this iteration is the optimal dung beetle updated through adaptive weight opposition learning, where fit(Gbest) and fit(Gbest) are the optimal dung beetles. OD Calculate the Gbest value for individual dung beetles and the Gbest value for individual dung beetles respectively. OD The fitness value of the dung beetle individual Gbest ODIf the fitness value of a dung beetle is less than that of the dung beetle individual Gbest, then the best dung beetle individual is updated; otherwise, no update is performed.
[0059] S7. Determine if the maximum number of iterations has been reached. If yes, output the optimal threshold based on the information carried by the optimal individual of the dung beetle optimization, and perform image segmentation based on the obtained optimal threshold to output the best multi-threshold segmented image. If no, proceed to S4.
[0060] Simulation Experiment
[0061] To objectively evaluate the segmentation effect of this invention, this embodiment uses the improved Dung Beetle Optimization Algorithm (DADBO), Dung Beetle Optimization Algorithm (DBO), Seagull Optimization Algorithm (SOA), Whale Optimization Algorithm (WOA), and Gray Wolf Optimization Algorithm (GWO) to segment the three images "Lena", "car", and "lighthouse" with thresholds of 6 and 8 respectively. Peak Signal-to-Noise Ratio (PSNR) and Feature Similarity (FSIM) are used as evaluation indicators for the image segmentation results. Peak Signal-to-Noise Ratio (PSNR) reflects the difference between the real image and the segmented image based on pixel statistical information. It is the ratio of the maximum signal power to noise that affects signal fidelity and is an objective standard for evaluating images at the pixel level. The higher the PSNR value, the better the image segmentation effect. FSIM focuses on measuring the structural similarity between the original image and the segmented image, while considering the structural and texture information of the image. The closer the FSIM values of two images are to 1, the more similar the two images are.
[0062] Tables 1 and 2 present the segmentation PSNR and FSIM values of the five algorithms when the threshold is 6 and 8, respectively. The bolded data in the tables represents the data values obtained by the optimal algorithm among the five algorithms. It is worth noting that the best fitness value "-" in the tables indicates that the algorithm did not complete image segmentation and is not considered for ranking. Observing Tables 1 and 2, we can see that when the threshold is 6, DADBO completes the segmentation task for all three images. For the "Lenna" image, the other four algorithms, except for DADBO, failed to complete the segmentation task, indicating that the DADBO algorithm has a certain advantage in high-threshold image segmentation. When the threshold is 8, DADBO completes the segmentation task in all three images, and its PSNR and FSIM values are higher than the other four algorithms in two of the images. GWO completes the segmentation task in "lighthouse" but fails in the remaining two images. The SOA, WOA, and GWO algorithms all fail to complete the segmentation task in the 8-threshold segmentation, demonstrating the superiority of the proposed algorithm in image segmentation.
[0063] To more clearly observe the segmentation effect of the DADBO algorithm, Figures 2 to 7 show the segmentation results of the five algorithms on the three images "Lena", "car", and "lighthouse" with threshold numbers of 4 and 8, respectively. Subfigures a to e show the segmentation results of the five algorithms: DADBO, DBO, SOA, WOA, and GWO. From Figures 2 and 5, it is clear that DADBO significantly outperforms other algorithms in segmenting the woman's face, hair, hat, and feathers on the hat, while other algorithms show varying degrees of image loss. When the threshold number increases to 8, the image quality of the segmented image produced by the algorithm of this invention becomes more detailed, and the segmentation effect becomes better, while other algorithms suffer more severe image loss.
[0064] Comparing Figures 3 and 6, it can be seen that DADBO achieves very clear segmentation results for vehicle license plates, headlights, tire textures, and interior conditions. SOA, WOA, and GWO algorithms all exhibit significant image information loss in these areas. When the threshold number is 8, the image loss in the DBO algorithm becomes even more pronounced. As the threshold number increases, the algorithm of this invention achieves better local contrast segmentation, resulting in a more refined overall image and higher segmentation quality.
[0065] Comparing Figures 4 and 7, it can be seen that DADBO has a stronger sense of layering and detail in the segmentation of lighthouses, houses, and sky, and the segmentation is more delicate and clear. The other four algorithms all show some loss of images in these areas, and the higher the threshold, the more serious the loss. In contrast, the algorithm of this invention segments the sky and lighthouse with different brightness levels, resulting in better layering, clarity, and a closer resemblance to the original image.
[0066] Table 1. Segmentation results with a threshold of 6.
[0067]
[0068] Table 2 shows the segmentation results with a threshold of 8.
[0069]
[0070] Contents not described in detail in this specification are existing technologies known to those skilled in the art. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the technical principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An image segmentation method based on an improved dung beetle optimization algorithm, characterized in that, Includes the following steps: S1. Obtain the image to be segmented, and convert the obtained non-grayscale image into a grayscale image; S2. Initialize the initial population size N and the maximum number of iterations M based on the dung beetle optimization algorithm, and set the threshold number Dim to be segmented; S3. Based on the set threshold number Dim, randomly generate N dung beetle individuals in the grayscale image search space. The information carried by each dung beetle individual is the threshold number Dim of the segmented image. Use non-standard Tent chaotic mapping to initialize the dung beetle population position so that it is evenly distributed in the search space. Divide the dung beetle population into four groups: rolling dung beetle, female dung beetle, small dung beetle, and thieving dung beetle. S4. Use the maximum inter-class variance as the fitness function of the adaptive weighted opposition learning and dynamic search boundary dung beetle optimization algorithm; calculate the fitness value of each dung beetle individual and record the positions of the best and worst dung beetle individuals; the formula for calculating the maximum inter-class variance is: Where σ 2 For the maximum inter-class variance, ω i μ represents the proportion of each grayscale value in the image, and μ is the overall average grayscale value of the grayscale image. i The average gray value within the i-th threshold is used for segmentation, where L is the maximum gray level of the image; S5. A non-linear decreasing strategy is introduced to adjust the search boundaries of small dung beetles and female dung beetles, thereby accelerating the search speed in the early stages of the algorithm. S6. An adaptive weighted opposition learning strategy and a greedy selection strategy are introduced to update the optimal food source location for the dung beetle, increasing its chances of escaping local optima. S7. Determine if the maximum number of iterations has been reached. If yes, output the optimal threshold based on the information carried by the optimal dung beetle individual optimized by the dung beetle, and perform image segmentation based on the obtained optimal threshold to output the best segmented image. If no, proceed to S4.
2. The image segmentation method based on the improved dung beetle optimization algorithm according to claim 1, characterized in that: Step S3 uses non-standard Tent chaos to initialize the dung beetle population location. The non-standard Tent chaos mapping rule is as follows: Where the parameter η = 0.3, x i Let x be the normalized value of individual dung beetle i. i+1 The value after performing a non-standard Tent chaotic mapping on individual dung beetle i.
3. The image segmentation method based on the improved dung beetle optimization algorithm according to claim 1, characterized in that: In step S5, a nonlinear decreasing strategy is introduced to update the search boundary for female and dung beetles. This strategy aims to optimize the algorithm's search process by rapidly reducing the search boundary speed in the early iterations to accelerate the search; and then gradually increasing the boundary weight in the later stages of the algorithm, thereby encouraging the female and dung beetles to explore the search space more thoroughly, thus achieving convergence to the global optimum. The nonlinear decreasing strategy is as follows: R=e (((-7)×t) / (2×M)) Where t is the current iteration number and M is the maximum number of iterations for the dung beetle optimization algorithm.
4. The image segmentation method based on the improved dung beetle optimization algorithm according to claim 1, characterized in that: The adaptive weighted opposition learning strategy and greedy selection strategy introduced in step S6 are used to update the optimal food source for stealing dung beetles; in The adaptive weighted opposition learning strategy draws on the basic opposition learning strategy and incorporates the concept of opposition into the search process of the image segmentation task. By introducing an opposition learning element, the algorithm can simultaneously consider candidate solutions and their adaptive weight opposition-learned solutions, thereby achieving a more comprehensive and in-depth exploration in the search space. This opposition learning mechanism not only accelerates the convergence speed of the algorithm but also helps it better avoid local optima, thus improving the quality and accuracy of image segmentation results. The formula for the adaptive weight opposition learning strategy is as follows: X OD =X+w×p×(q×X0-X) Where parameters p and q are random numbers between [0,1] following a normal distribution, weight w is a random integer between [0,5], X is the original individual, X0 is the position of the standard complementary solution generated by the candidate solution X, and X... OD An adaptive weighted opposition learning solution is generated for the candidate solution X; The greedy choice strategy formula is as follows: Where Gbest is the optimal solution generated in a certain iteration of the dung beetle optimization algorithm. OD The optimal solution for this iteration is the optimal solution after adaptive weight opposition learning update, _fit(Gbest)_ and _fit(Gbest)_. OD Calculate Gbest and Gbest respectively. OD The fitness value when Gbest OD If the fitness value is less than Gbest, the best individual is updated; otherwise, no update is performed.
Citation Information
Patent Citations
Wireless sensor network coverage optimization method based on improved white top chicken algorithm
CN116528252A
Ship thrust distribution method based on improved dung beetle algorithm
CN117131782A
