Harris Hawk Optimization Algorithm for Image Segmentation Based on Bamboo Law and Entropy
By introducing the Harris Eagle mechanism based on bamboo law and entropy in the image segmentation technology, the problem of slow convergence speed and easy to fall into local optimal solutions in the existing technology is solved, and a more efficient and accurate image segmentation effect is achieved.
Patent Information
- Application Number
- CN202211544646.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-03
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-12-03
AI Technical Summary
The existing image segmentation technology based on group intelligence has problems such as slow convergence speed, low convergence accuracy and easy to fall into local optimal solutions.
The Harris Eagle mechanism based on bamboo law and entropy is adopted to improve prey energy by using bamboo law in the transition stage and mutating the Harris Eagle population globally in the global exploration stage to improve convergence speed and accuracy.
It achieves faster convergence speed, higher convergence accuracy and better robustness, significantly improving the segmentation accuracy and efficiency of image segmentation.
Smart Images

Figure CN115937493B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a K - means clustering image segmentation method based on the bamboo law and the entropy of Harris hawk mechanism, belonging to the field of image processing. Background Art
[0002] Image segmentation is a technology and process of dividing an image into several specific regions with unique properties and extracting the target of interest. It is a key step from image processing to image analysis. The existing image segmentation methods are mainly classified into the following categories: threshold - based segmentation methods, region - based segmentation methods, edge - based segmentation methods, and segmentation methods based on specific theories, etc. From a mathematical perspective, image segmentation is a process of dividing a digital image into non - overlapping regions. The process of image segmentation is also a labeling process, that is, pixels belonging to the same region are assigned the same number. Common image segmentation methods include the Otsu method, the maximum entropy method, the minimum cross - entropy method, and the K - means clustering method, etc. In recent years, image segmentation technologies based on various swarm intelligence methods have gradually emerged, and such methods have greatly improved the speed, segmentation effect, and robustness of image segmentation. Therefore, designing a high - precision image segmentation method with a fast convergence speed, high convergence accuracy, and strong robustness has important theoretical value and significance.
[0003] After searching the literature, Li Haiyang et al. proposed an image segmentation method based on random weight particle swarm optimization and K-means clustering in "Image Segmentation Based on Random Weight Particle Swarm and K-Means Clustering" published in 《Journal of Graphics》(2014, Vol.35, No.05, pp.755-761). While making full use of the advantages of K-means clustering, such as simplicity and high real-time performance, it improved the disadvantage of being easily trapped in local optimal solutions and achieved relatively ideal segmentation results. However, since the particle swarm algorithm is a swarm intelligence algorithm proposed earlier, there are obvious deficiencies in its convergence speed and convergence accuracy. Even if the algorithm is improved accordingly, it still cannot find the optimal initial clustering value. Li Peng et al. proposed an improved fruit fly optimization algorithm using Logistic chaotic mapping and Gaussian walk strategy and applied the algorithm to the Otsu threshold segmentation method for image segmentation in "Optimized Otsu Image Segmentation Method Based on Logistic Mapping Fruit Fly Algorithm" published in 《Foreign Electronic Measurement Technology》(2022, Vol.41, No.7, pp.9-17). This method improved the fruit fly algorithm and applied the improved algorithm to the traditional Otsu image segmentation method, which improved the defects of low segmentation accuracy and poor real-time performance of the traditional Otsu method to a certain extent. However, since the Otsu method is a traditional threshold-based image segmentation method that only uses gray scale as the segmentation standard in its segmentation principle, there are problems such as poor segmentation effect when the ratio of the background to the target size is extremely different and sensitivity to noise. Leena Samantaray et al. proposed a fusion algorithm that combines the Harris hawks algorithm and the cuckoo algorithm to improve the Otsu method and the Kapur entropy method for image segmentation respectively, and achieved good segmentation results in "A New Harris Hawks-Cuckoo Search Optimizer for Multilevel Thresholding of Thermogram Images" published in 《Revue d'Intelligence Artificielle》(2020, Vol.34, No.5, pp.541-551). The hybrid algorithm that combines the Harris hawks algorithm and the cuckoo algorithm improves the original Harris hawks algorithm by combining two relatively new swarm intelligence algorithms. The improved algorithm has some improvements in convergence speed and convergence accuracy, but this method does not consider the spatial features of the image, so the segmentation effect still needs to be improved.
[0004] Existing literature shows that in multi-threshold segmentation methods, it is relatively common to combine some traditional swarm intelligence methods such as the grey wolf method, sparrow method, and whale method or their improved methods with widely used basic image segmentation methods such as Otsu, maximum entropy method, Tsallis entropy method, etc., and extend the single-threshold segmentation method to multi-threshold. These methods all have problems such as slow convergence speed and less than ideal segmentation accuracy when applied to the field of image segmentation. Introducing some swarm intelligence methods proposed in recent years, such as the Harris hawk method, into the field of image segmentation will improve the above problems. However, since some newly proposed methods themselves also have the above problems, effective improvements in many aspects need to be made for the problems that occur when they are applied to image segmentation. Although the clustering-based image segmentation method improves the segmentation accuracy, the selection of the initial clustering center has a great impact on the segmentation effect and is prone to falling into a local optimal solution. At the same time, the iterative process of clustering prolongs the time required for image segmentation. To achieve the goals of fast convergence of intelligent optimization methods and high image segmentation accuracy, it is necessary to design some new evolutionary methods and invent a feasible and effective high-precision image segmentation method. The present invention is based on the K-means clustering method for image segmentation, and designs a Harris hawk mechanism based on the bamboo law and entropy for selecting the initial value of the K-means clustering method, thereby proposing a new method for image segmentation. Summary of the Invention
[0005] The purpose of the present invention is to solve the problems of insufficient segmentation accuracy and slow convergence speed in the existing swarm intelligence-based image segmentation technology, and further provide a Harris hawk mechanism based on the bamboo law and entropy with a faster convergence speed, higher effectiveness, and wider application that can solve engineering problems. The present invention combines the bamboo law and the Harris hawk mechanism and uses them to design the energy equation in the transition stage of the Harris hawk mechanism, making the solution mechanism more in line with the hunting laws of natural organisms, and achieving a more effective balance in both the global exploration and local exploitation stages. In the global exploration stage, entropy is used to mutate the Harris hawk population to reduce the possibility of falling into a local optimal solution. Compared with some existing traditional swarm intelligence-based image segmentation methods, the designed Harris hawk mechanism-based image segmentation method based on the bamboo law and entropy has a faster convergence speed, higher convergence accuracy, higher segmentation accuracy, and better robustness.
[0006] The purpose of the present invention is achieved as follows: The steps are as follows:
[0007] Step 1: Input an image, grayscale the image and convert it into a pseudo-color image;
[0008] Step 2: Set the number of clusters and perform the modeling of the K-means clustering method;
[0009] Step 3: Initialize the positions and prey energies of each individual in the Harris hawk population. Use the loss function of the K-means clustering method as the fitness function of the Harris hawk mechanism based on the bamboo law and entropy, calculate the fitness values, and obtain the initial position of the prey.
[0010] Step 4: In the transition stage, improve the energy of the prey using the bamboo law, and determine whether the Harris hawk population will enter the global exploration stage or the local exploitation stage based on the prey energy.
[0011] Step 5: In the global exploration stage, utilize entropy to mutate the global positions of the Harris hawk population. Each Harris hawk searches for the optimal solution within a given interval range.
[0012] Step 6: In the local exploitation stage, in the local exploitation stage, the Harris hawk will select one of the four different siege strategies: soft siege, hard siege, progressive rapid dive soft siege, and progressive rapid dive hard siege, based on the energy E t of the prey and the probability of the prey escaping.
[0013] Step 7: Calculate the fitness of each Harris hawk after updating its position, and update the prey position.
[0014] Substitute the position of the i-th Harris hawk in the (t + 1)-th iteration into the fitness function to calculate the corresponding fitness value, and record the optimal position of the Harris hawk in the (t + 1)-th iteration. If the fitness value of the optimal position of the Harris hawk in the (t + 1)-th iteration is better than the fitness value of the t-th prey, then the prey position in the (t + 1)-th iteration is equal to the optimal position of the Harris hawk in the (t + 1)-th iteration; otherwise, the prey position in the (t + 1)-th iteration is equal to the prey position in the t-th iteration.
[0015] Step 8: Determine whether the maximum iteration number T has been reached. If not, set t = t + 1 and return to Step 4 to continue the iteration; otherwise, output the optimal position.
[0016] Step 9: Use the prey position of the last generation as the initial clustering center of the K-means clustering method, perform clustering using the model described in Step 2, reconstruct the image by replacing all pixel points in each cluster with the gray value of its clustering center to achieve image segmentation, and convert the segmented gray image into a pseudo-color image according to the mapping rule in Step 1.
[0017] Further, Step 1 is specifically as follows: Extract the number of pixel points R ow × C ol and the number of channels C type in the gray image. Assume that the gray level value range is [0, M - 1], and the i-th pixel point is represented as m i , where Row and C ol respectively represent the number of rows and columns of the pixel points in the image, M represents the number of gray levels, and L = R ow ×C ol represents the total number of pixel points; convert the image data type to double-precision floating-point type and normalize it to between [0, 1]; each channel converts the grayscale image to a pseudo-color image by using different mapping functions for different gray levels.
[0018] Further, step two is specifically as follows: set the number of clusters to K, and the cluster center of the th loop of K-means clustering is is the number of loops in the clustering model;
[0019] (1) Let the sample set be I = [m 1 , m 2 , …, m L , set the maximum number of loops in this model to T 1 , the allowable maximum error to be E max , the jth cluster be C j , j = 1, 2, …, K, and initialize the cluster to as an empty set;
[0020] (2) For calculate the Euclidean distance between the th pixel point sample and the jth cluster center : Let mark the category corresponding to the smallest in the th loop as λ, λ ∈ {1, 2, …, K}, then update C λ , let
[0021] (3) Recalculate the cluster center j of the th loop for all sample points in C C j is the number of samples contained in the jth cluster C j , calculate the error
[0022] (4) If or end the clustering and output the clustering result C = {C 1 , C 2 , …, C K}, otherwise let return to (2) and continue to loop until the clustering end condition is met.
[0023] Further, step three is specifically as follows: Set the number of Harris hawk individuals in the Harris hawk population to N, the maximum number of iterations to T, the lower bound R = [R 1 , R 2 ,..., R D , the upper bound U = [U 1 , U 2 ,..., U D , where D is the maximum dimension, D = K × C type ; Define as the position of the i-th Harris hawk at the t-th iteration, and initialize the position of the i-th Harris hawk in the first generation at the d-th dimension as where is a random number between (1, N), d = 1, 2,..., D, U d is the upper bound of the d-th dimension, and R d is the lower bound of the d-th dimension;
[0024] Select one pixel point every l pixel points from the sample set described in step two as the clustering candidate points, and set the set of clustering candidate points as That is, and l are positive integers,
[0025] Take the loss function of the K-means clustering method as the fitness function; is the formula for calculating the fitness value of the Harris hawk individual, i = 1, 2,..., N, t ∈ [1, T]; is the position of the prey at the t-th iteration, which represents the position where the optimal solution is located at the t-th iteration; Substitute the position of the Harris hawk individual into the above fitness calculation formula to obtain the initial fitness value of each Harris hawk. The smaller the fitness value, the better. Set the position of the Harris hawk with the optimal fitness value in the initial population as the initial position of the prey.
[0026] Further, step four is as follows: Divide the energy change of the prey into two stages: the exponential decay stage and the rising-stable stage; Obtain from the time relationship between three years and six weeks that the former stage accounts for 97% of the total number of iterations, and the latter stage accounts for 3% of the total number of iterations. When the first stage ends, the iteration is about to end. At this time, because the prey is about to be preyed on by the Harris hawk, it will stimulate an instinctive desire to survive, and the energy of the prey will increase slightly. Set the energy of the prey in the latter stage to increase linearly; However, the energy growth of the prey is limited. Therefore, after reaching a certain threshold, the energy of the prey will remain stable until the iteration ends; The energy of the prey is defined by the following expression: In the formula, E t is the energy of the prey at the t-th iteration, is a random number between (0, 1) selected at the t-th iteration, which changes with the number of iterations; when E t ≥ 1, the Harris hawk enters the global exploration stage, otherwise the Harris hawk enters the local exploitation stage.
[0027] Furthermore, step five is as follows: In the global exploration stage, the Harris hawk population will search for prey within the defined interval. Before the iteration starts, the positions of each Harris hawk in the entropy mutation Harris hawk population are utilized to improve the global exploration ability. The specific mutation method is as follows:
[0028] Calculate the fitness probability of the i-th Harris hawk in the t-th generation Obtain the entropy of the Harris hawk population in the t-th generation as After obtaining the entropy of the Harris hawk population, set the mutation step size according to the value of the entropy, and change the position of each Harris hawk; set the mutation step size The calculation formula is: where H max =log 2 N, exp() represents the exponential function with the natural constant e as the base. The position of the i-th Harris hawk after mutation is where and are random numbers between (0, α 1 ) and (0, α 2 ) selected at the t-th iteration respectively, and α 3 is a constant between (0, 1);
[0029] After completing the mutation of the position of each Harris hawk individual, update the position of the i-th Harris hawk according to the following rules: where is the position of the i-th Harris hawk at the (t + 1)-th iteration, and are random numbers generated within the interval (0, 1), β 1 is a constant between (0, 1), abs() is a function that takes the absolute value of each dimensional variable in the parentheses, is the position of the m-th Harris hawk randomly selected at the -th iteration, is the -th iteration average position of the Harris hawk population, and its expression is:
[0030] Furthermore, step six is as follows: The Harris hawk selects four different siege methods to hunt the prey according to the energy and escape probability of the prey: |E t |≥α 4 When the prey has enough energy to escape, α 4is the energy control constant. The Harris hawk performs a soft siege; otherwise, the Harris hawk performs a hard siege. For the \(i\)-th Harris hawk in the \(t\)-th iteration, a uniform random number between \((0, 1)\) is generated If at this time, the prey is likely to escape, and \(\alpha\) 5 is the escape probability control constant; conversely, the prey is not likely to escape;
[0031] When and \(|E\) t | \(\geq \alpha\) 4 at this time, the \(i\)-th Harris hawk performs a soft siege and updates its position as follows: where represents the difference between the prey position and the \(i\)-th Harris hawk position in the \(t\)-th iteration, is the weight parameter, is a random number between \((0, 1)\), and \(J\) t is used to simulate the jumping intensity of the rabbit;
[0032] When and \(|E\) t | \(\lt \alpha\) 4 at this time, the \(i\)-th Harris hawk performs a hard siege and updates its position as follows:
[0033] When \(|E\) t | \(\geq \alpha\) 4 and at this time, the \(i\)-th Harris hawk performs a progressive rapid dive soft siege and updates its position as follows: where is the \(i\)-th random position, and the \(d\)-th dimension of the \(i\)-th random position in the \(t\)-th iteration is a random number selected between \((1, D)\), \(d = 1, 2, \cdots, D\), and \(L\) f (D) is the levy flight function;
[0034] When \(|E\) t | \(\lt \alpha\) 4 and at this time, the \(i\)-th Harris hawk performs a progressive rapid dive hard siege and updates its position as follows:
[0035] Compared with the prior art, the beneficial effects of the present invention are as follows: the traditional Harris Hawk mechanism has problems such as slow convergence speed, low convergence accuracy, and easy to fall into local optimal solutions. In view of these problems, the present invention proposes an improved method based on the bamboo law and entropy, and improves the Harris Hawk mechanism from multiple aspects. In the transition stage, the bamboo law is used to improve the energy of the prey when escaping. The present invention changes the decreasing law of the prey energy of the original method from linear to exponential, and introduces the bamboo law to improve the prey escape energy in sections. In the first stage of the iteration process, the prey energy decreases exponentially. When the iteration enters the end, the prey is about to be preyed by the Harris Hawk. At this time, the survival instinct of the prey is stimulated. Entering the latter stage of the iteration, the prey energy will be linearly increased by a small amplitude until it remains stable after a peak value. This energy calculation method makes the present invention more in line with the law of predators chasing prey in nature, and it has been verified by simulation that it can increase the convergence of the method. In the global exploration stage, entropy is used to perform global mutation on the Harris Hawk population. The mutation operator is designed by using the characteristics of entropy. When the entropy of the Harris Hawk population is low, a larger step size mutation is performed, which increases the diversity of the population, which is conducive to the Harris Hawk population jumping out of the local optimal area and better searching the potential area; when the entropy of the Harris Hawk population is high, a smaller step size mutation is performed, thereby increasing the search speed and avoiding missing the optimal solution. Traditional image segmentation methods are generally single threshold segmentation. The method of generalizing single threshold segmentation to multi-threshold segmentation has problems such as high time complexity and unstable segmentation effect. Although the K-means clustering analysis method has a good segmentation effect when used for image segmentation, since the initial cluster center is randomly selected, it takes a long time to calculate and converges slowly to achieve a smaller error, and it is easy to fall into the local optimal solution. After optimization by swarm intelligence method, its convergence speed is significantly improved. Under the condition that the K-means clustering method sets the same maximum number of iterations, the Harris Hawk mechanism based on the bamboo law and entropy shows better segmentation results than the original Harris Hawk mechanism and some classic swarm intelligence optimization methods such as the particle swarm mechanism in terms of peak signal-to-noise ratio, root mean square error and structural similarity. This shows that the present invention has a relatively strong practical value in the field of image segmentation. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 :Flowchart of Harris Hawk mechanism image segmentation method based on bamboo law and entropy;
[0037] Figure 2 : Convergence performance comparison curve of different methods under the same image;
[0038] Figure 3 : Grayscale image of the 2-cluster segmentation effect of different methods on the same image;
[0039] Figure 4: Pseudo-color map of the 2-cluster segmentation effect of different methods under the same picture;
[0040] Figure 5 : Grayscale map of the 8-cluster segmentation effect of different methods under the same picture;
[0041] Figure 6 : Pseudo-color map of the 8-cluster segmentation effect of different methods under the same picture. Specific implementation manner
[0042] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.
[0043] The overall process of the image segmentation method based on the bamboo law and the Harris hawk mechanism of entropy of the present invention is as Figure 1 shown. The technical solution of the present invention includes the following steps:
[0044] Step 1: Input an image, grayscale the image and convert it into a pseudo-color image.
[0045] Extract the number of pixel points R ow ×C ol and the number of channels C type in the grayscale image. Let the grayscale level value range be [0, M-1], and the th pixel point is represented as m i . where R ow and C ol respectively represent the number of rows and columns of pixel points in the image, M represents the number of grayscale levels, and L = R ow ×C ol represents the total number of pixel points. Convert the image data type to double-precision floating-point type and normalize it to between [0, 1]. Each channel converts the grayscale image into a pseudo-color image by using different mapping functions for different grayscale levels, so as to evaluate the segmentation effect of the segmented image subsequently.
[0046] Step 2: Set the number of clusters and perform modeling of the K-means clustering method.
[0047] Set the number of clusters to K, and the cluster center of the th cycle of K-means clustering is is the number of cycles in the clustering model.
[0048] (1) Let the sample set be I = [m 1 , m 2 , …, m L . Set the maximum number of cycles in this model to T 1 , the allowable maximum error to E max , and the jth cluster is C j, for \(j = 1, 2, \cdots, K\), initialize the clustering clusters as an empty set.
[0049] (2) For calculate the Euclidean distance between the th pixel point sample and the \(j\)th clustering center : Let mark the category corresponding to the minimum in the \(t\)th iteration as \(\lambda\), where \(\lambda\in\{1, 2, \cdots, K\}\), then update \(C\) by making λ
[0050] (3) Recalculate the clustering center of the \(t\)th iteration for all sample points in \(C\) j where is the number of samples contained in the \(j\)th clustering cluster \(C\) and calculate the error j j
[0051] (4) If or end the clustering and output the clustering result \(C=\{C\) 1 , C\) 2 , \cdots, C\) K \}\), otherwise let return to (2) and continue the loop until the clustering end condition is met.
[0052] Step 3: Initialize the positions and prey energies of each individual in the Harris hawk population. Use the loss function of the K - means clustering method as the fitness function of the Harris hawk mechanism based on bamboo law and entropy, calculate the fitness value, and obtain the initial position of the prey.
[0053] Set the number of Harris hawk individuals in the Harris hawk population as \(N\), the maximum number of iterations as \(T\), the lower bound \(R = [R\) 1 , R\) 2 , \cdots, R\) D \), the upper bound \(U = [U\) 1 , U\) 2 , \cdots, U\) D \), where \(D\) is the maximum dimension and \(D = K\times C\) type . Define as the position of the \(i\)th Harris hawk at the \(t\)th iteration, and initialize the \(d\) - dimensional position of the \(i\)th Harris hawk in the first generation as where is a random number between \((1, N)\), \(d = 1, 2, \cdots, D\), and \(U\) d is the upper bound of the d-th dimension, R d is the lower bound of the d-th dimension.
[0054] Select one pixel point every l pixel points from the sample set described in Step 2 as the clustering candidate points, and let the set of clustering candidate points be That is and l are positive integers,
[0055] Since the purpose of introducing the bamboo law and the entropy-based Harris hawk mechanism is to select the most suitable pixel points among the clustering candidate points as the initial clustering centers of the K-means clustering method, the loss function of the K-means clustering method is used as the fitness function. is the formula for calculating the fitness value of the Harris hawk individual, i = 1, 2,..., N, t ∈ [1, T]. is the position of the prey at the t-th iteration, which represents the position where the optimal solution is located at the t-th iteration. Substitute the position of the Harris hawk individual into the above fitness calculation formula to obtain the initial fitness value of each Harris hawk. The smaller the fitness value, the better. Set the position of the Harris hawk with the optimal fitness value in the initial population as the initial position of the prey.
[0056] Step 4: Transition stage. Use the bamboo law to improve the energy of the prey, and judge whether the Harris hawk population will enter the global exploration stage or the local exploitation stage according to the prey energy.
[0057] In the original Harris hawk mechanism, the energy of the prey shows a linear decrease from the highest value to the lowest value, which does not conform to the corresponding law of predators chasing prey in nature. The energy of the prey determines whether the Harris hawk population will conduct global exploration or local exploitation next. In order to maintain the balance between global exploration and local exploitation of the Harris hawk, it is necessary to reasonably optimize the calculation method of the prey energy. Therefore, first change the linear decrease method of the prey energy to an exponential decrease method, and then introduce the bamboo law to further optimize the energy change of the prey.
[0058] Introducing the bamboo law into the calculation of the prey energy can make the following optimizations: The growth of bamboo can be divided into two periods, the first three years and the last six weeks. According to this inspiration, the energy change of the prey can be divided into two stages: the exponential decrease stage and the rising-stable stage. From the time relationship between three years and six weeks, it can be obtained that the previous stage accounts for 97% of the total number of iterations, and the latter stage accounts for 3% of the total number of iterations. When the first stage ends, the iteration is about to end. At this time, the prey will stimulate its instinctive desire to survive due to being about to be preyed by the Harris hawk, and the energy of the prey will have a small increase. The energy of the prey in the latter stage can be set to linear growth. However, the energy growth of the prey has a certain limit, so after reaching a certain threshold, the energy of the prey will remain stable until the iteration ends. The energy of the prey can be defined by the following expression: where E t is the energy of the prey at the t-th iteration, is a random number between (0, 1) selected at the t-th iteration, which changes with the number of iterations. When E t ≥1, the Harris hawk enters the global exploration stage; otherwise, the Harris hawk enters the local exploitation stage.
[0059] Step 5: Global exploration stage. Utilize the global positions of the Harris hawk population with entropy mutation. Each Harris hawk searches for the optimal solution within a given interval.
[0060] In the global exploration stage, the Harris hawk population will search for the prey within the defined interval. Before the iteration starts, first utilize the positions of each Harris hawk in the Harris hawk population with entropy mutation to improve the global exploration ability. The specific mutation method is as follows:
[0061] Calculate the fitness probability of the i-th Harris hawk in the t-th generation Obtain the entropy of the Harris hawk population in the t-th generation as After obtaining the entropy of the Harris hawk population, set the mutation step size according to the value of the entropy, and change the position of each Harris hawk. When the entropy of the Harris hawk population is large, a smaller mutation step size should be adopted for mutation to avoid missing the optimal solution; when the entropy of the Harris hawk population is small, a larger mutation step size should be adopted for mutation to increase the global exploration ability and avoid falling into the local optimal solution. To sum up, the mutation step size can be set with the calculation formula: where H max = log 2 N, exp() represents the exponential function with the natural constant e as the base. The position of the i-th Harris hawk after mutation is where and are respectively random numbers between (0, α 1 ) and (0, α 2 ) selected at the t-th iteration, and α 3 is a constant between (0, 1).
[0062] After completing the mutation of the position of each Harris hawk individual, update the position of the i-th Harris hawk according to the following rules: where is the position of the i-th Harris hawk at the (t + 1)-th iteration, and are random numbers generated within the interval (0, 1), β 1 is a constant between (0, 1), abs() is a function that takes the absolute value of each dimensional variable in the parentheses, is the The position of the m-th Harris hawk randomly selected at the k-th iteration is the average position of the Harris hawk population at the
[0063] Step 6: Local exploitation stage. In the local exploitation stage, the Harris hawk will select one of four different siege strategies: soft siege, hard siege, progressive rapid dive soft siege, and progressive rapid dive hard siege, according to the energy E t of the prey and the probability of the prey's escape.
[0064] The Harris hawk will choose four different siege methods to hunt the prey according to the energy of the prey and the escape probability. When |E t | ≥ α 4 the prey has enough energy to escape, where α 4 is the energy control constant, and the Harris hawk executes a soft siege; otherwise, the Harris hawk executes a hard siege. For the i-th Harris hawk at the t-th iteration, a uniform random number between (0, 1) is generated If the prey is easy to escape, where α 5 is the escape probability control constant; otherwise, the prey is not easy to escape.
[0065] When and |E t | ≥ α 4 the i-th Harris hawk conducts a soft siege and updates its position as follows: where represents the difference between the prey's position and the i-th Harris hawk's position at the t-th iteration, is the weight parameter, is a random number between (0, 1), and J t is used to simulate the jumping intensity of the rabbit.
[0066] When and |E t | < α 4 the i-th Harris hawk conducts a hard siege and updates its position as follows:
[0067] When |E t | ≥ α 4 and the i-th Harris hawk conducts a progressive rapid dive soft siege and updates its position as follows: where is the i-th random position, and the d-th dimension of the i-th random position at the t-th iteration is a random number between the selected (1, D), d = 1, 2,..., D, L f (D) is the Levy flight function.
[0068] When |E t | < α 4 and at this time, the i-th Harris hawk performs a progressive rapid dive hard siege, and the position is updated as follows:
[0069] Step 7: Calculate the fitness of each Harris hawk after updating the position, and update the prey position.
[0070] Substitute the position of the i-th Harris hawk in the (t + 1)-th iteration into the fitness function to calculate the corresponding fitness value, and record the optimal position of the Harris hawk in the (t + 1)-th iteration. If the fitness value of the optimal position of the Harris hawk in the (t + 1)-th iteration is better than the fitness value of the t-th prey, then the prey position in the (t + 1)-th iteration is equal to the optimal position of the Harris hawk in the (t + 1)-th iteration; otherwise, the prey position in the (t + 1)-th iteration is equal to the prey position in the t-th iteration.
[0071] Step 8: Determine whether the maximum number of iterations T has been reached. If not, set t = t + 1 and return to Step 4 to continue the iteration; otherwise, output the optimal position.
[0072] Step 9: Use the prey position of the last generation as the initial clustering center of the K-means clustering method, perform clustering using the model described in Step 2, replace all pixel points in each clustering cluster with the gray value of its clustering center to reconstruct the image for image segmentation, and convert the segmented gray image into a pseudo-color image according to the mapping rule in Step 1.
[0073] For the sake of description, the bamboo law and entropy-based Harris hawk mechanism proposed in the present invention are briefly denoted as BLEHHO, and the search mechanisms for comparison are the Harris hawk mechanism and the particle swarm mechanism, which are briefly denoted as HHO and PSO respectively.
[0074] To comprehensively compare the performance of the three methods, the same initialization is performed on BLEHHO and HHO, and the parameters of the bamboo law and entropy-based Harris hawk mechanism are set as l = 10, α 1 = 0.5, α 2 = 0.1, α 3 = 0.5, α 4 = 0.5, α 5 = 0.5, β 1= 0.5. The position of the prey is the position of the individual with the highest fitness value in the initial Harris hawk population, and the energy of the prey is infinite. The relevant parameters of PSO can be found in "Image Segmentation Based on Random Weight Particle Swarm and K-Means Clustering" published by Li Haiyang et al. in Journal of Graphics (2014, Vol.35, No.05, pp.755-761). The population sizes, maximum iteration numbers, upper bounds, and lower bounds of the three mechanisms are the same, and their values are N = 30, T = 300, U d = 1, R d = 0. Set the maximum iteration number of the K-means model to T 1 = 5, allowing the maximum error to be E max = 10 -6 . Each method is independently run 30 times, and the average fitness value of the 30 runs is taken to plot the fitness curve. The optimal fitness individual of the 30 independent runs is used as the initial clustering center for image segmentation.
[0075] The simulation results of the fitness curves when the number of clusters is 2 for the same picture with the same initial values are as Figure 2 shown, and the average value of 30 runs is taken for plotting.
[0076] The grayscale images and pseudo-color images of the 2-cluster segmentation results when the same picture is independently run 30 times by three different methods and the average value is taken as the initial clustering center with the same initial values are respectively as Figure 3 and Figure 4 shown.
[0077] The grayscale images and pseudo-color images of the 8-cluster segmentation results when the same picture is independently run 30 times by three different methods and the average value is taken as the initial clustering center with the same initial values are respectively as Figure 5 and Figure 6 shown.
[0078] It can be seen from Figure 2 that compared with HHO and PSO, BLEHHO has the advantages of fast convergence speed and high convergence accuracy, fully demonstrating that BLEHHO has more excellent convergence.
[0079] Figures 3 to 6 Since it is difficult to distinguish the quality of the segmentation effects shown by the naked eye, three indicators, namely peak signal-to-noise ratio, root mean square error, and structural similarity, are selected to comprehensively measure the quality of the segmentation results. The English representations of the three indicators are PSNR, RMSE, and SSIM respectively.
[0080] PSNR is one of the most commonly and widely used objective image evaluation metrics, which is the dB form of the mean squared error. It is based on the error between corresponding pixel points, that is, an image quality evaluation based on error sensitivity. Although it has a wide range of applications, it does not consider the visual characteristics of the human eye, so there are often situations where the evaluation results are inconsistent with people's subjective feelings. Therefore, two other metrics, RMSE and SSIM, are selected in the evaluation metrics. RMSE is the result of taking the square root of MSE and is sensitive to the pixel differences between two images. SSIM measures the similarity between two images from three aspects: brightness, contrast, and structure, and is a full-reference objective image evaluation metric.
[0081] The evaluation results of the three metrics for the 4-cluster, 8-cluster, and 12-cluster segmentation of the same image by the three methods are shown in Table 1, and the evaluation results of the three metrics for the 2-cluster segmentation of different images by the three methods are shown in Table 2. Among them, the larger the value of PSNR, the better the segmentation result; the smaller the value of RMSE, the better the segmentation result; and the closer the value of SSIM is to 1, the better the segmentation result. When calculating the segmentation result of the pseudo-color image, the average value of the three channels is taken, and the bold font indicates the optimal result among the three methods.
[0082] Table 1
[0083]
[0084] Table 2
[0085]
[0086] As can be seen from Table 1 and Table 2, among the 63 groups of data tested under the same conditions, there is 1 group of data where the comparison method is better than the method described in the present invention, and 1 group of data with the same test data as the present invention. Therefore, the following conclusion can be drawn: The image segmentation result of the Harris hawk image segmentation method based on the bamboo law and entropy is significantly better than the image segmentation methods of the Harris hawk method and the particle swarm method. Therefore, the method described in the present invention has strong robustness, and the image segmentation method using the Harris hawk mechanism optimized by the bamboo law and entropy to improve the initial value of K-means is also a more reasonable and accurate image segmentation method.
Claims
1. Harris Hawk mechanism image segmentation method based on bamboo law and entropy, Characterized in that, The steps are as follows: Step 1: Input an image, grayscale the image and convert it into a pseudo-color image; Step 2: Set the number of clusters and perform modeling using the K-means clustering method; Step 3: Initialize the position and prey energy of each individual in the Harris hawk population, use the loss function of the K-means clustering method as the fitness function of the Harris hawk mechanism based on bamboo law and entropy, calculate the fitness value, and obtain the initial position of the prey; Step 4: In the transition stage, use the bamboo law to improve the energy of the prey, and judge whether the Harris hawk population will enter the global exploration stage or the local exploitation stage based on the prey energy; Step 5: In the global exploration stage, use entropy to mutate the global positions of the Harris hawk population, and each Harris hawk searches for the optimal solution within a given range; Step 6: Local exploitation stage. In the local exploitation stage, the Harris hawk will perform according to the energy |E of the prey t | and the probability of the prey's escape to select four different siege strategies: soft siege, hard siege, progressive rapid dive soft siege, and progressive rapid dive hard siege; Step 7: Calculate the fitness of each Harris hawk after updating its position and update the prey position; The position of the $i$-th Harris hawk in the $(t + 1)$-th iteration Substitute it into the fitness function to calculate the corresponding fitness value, and record the optimal position of the Harris hawks in the $(t + 1)$-th iteration; if the fitness value of the optimal position of the Harris hawks in the $(t + 1)$-th iteration is better than the fitness value of the $t$-th prey, then the prey position in the $(t + 1)$-th iteration is equal to the optimal position of the Harris hawks in the $(t + 1)$-th iteration; otherwise, the prey position in the $(t + 1)$-th iteration is equal to the prey position in the $t$-th iteration; Step 8: Judge whether the maximum iteration number T is reached. If not, let t = t + 1, and return to Step 4 to continue the iteration; otherwise, output the optimal position; Step 9: Use the prey position of the last generation as the initial clustering center of the K-means clustering method, perform clustering using the model in Step 2, replace all pixel points in each clustering cluster with the gray value of its clustering center to reconstruct the image to achieve image segmentation, and convert the segmented gray image into a pseudo-color image according to the mapping rule in Step 1.
2. The Harris hawk mechanism image segmentation method based on bamboo law and entropy according to claim 1, Characterized in that, Step 1 specifically includes: extracting the number of pixels R ow ×C ol and the number of channels C type , assuming the gray level value range is [0, M - 1], the th pixel is represented as where R ow and C ol respectively represent the number of rows and columns of pixels in the image, M represents the number of gray levels, and L = R ow ×C ol represents the total number of pixels; convert the image data type to double-precision floating-point type and normalize it to between [0, 1]; each channel converts the grayscale image into a pseudo-color image by using different mapping functions for different gray levels.
3. The Harris hawk mechanism image segmentation method based on bamboo law and entropy according to claim 1, Characterized in that, Step 2 is specifically as follows: Set the number of clusters to K, and the cluster center of the -th iteration of the K-means clustering is where is the number of iterations in the clustering model; (1) Let the sample set be \(I = [m 1 , m 2 , \ldots, m L \), set the maximum number of iterations in this model to \(T 1 , allow the maximum error to be \(E max , the \(j\)-th cluster is \(C j , j = 1, 2, \ldots, K\), and initialize the clusters as the empty set; (2) For calculating the nth pixel point sample and the Euclidean distance to the jth cluster center : Let mark the category corresponding to the minimum in the nth loop as λ, where λ ∈ {1, 2,..., K}, then update C λ , and let (3) For C j Recalculate the cluster center of the th iteration for all sample points in where j is the number of samples contained in the j-th cluster C (4) If or the clustering ends, output the clustering result C = {C 1 , C 2 , …, C K}, otherwise let return to (2) and continue the loop until the condition for ending the clustering is met.
4. The Harris hawk mechanism image segmentation method based on bamboo law and entropy according to claim 1, Characterized in that, Step 3 specifically is as follows: Set the number of Harris hawk individuals in the Harris hawk population to N, the maximum number of iterations to T, the lower bound R = [R 1 , R 2 ,..., R D , the upper bound U = [U 1 , U 2 ,..., U D , where D is the maximum dimension, D = K × C type ; Define as the position of the i-th Harris hawk at the t-th iteration, and initialize the position of the i-th Harris hawk in the d-th dimension in the first generation as where is a random number between (1, N), d = 1, 2,..., D, U d is the upper bound of the d-th dimension, and R d is the lower bound of the d-th dimension; Select one pixel point every l pixel points from the sample set in step two as the clustering candidate points, and let the set of clustering candidate points be That is where l is a positive integer Take the loss function of the K-means clustering method as the fitness function; The formula for calculating the fitness value of Harris hawk individuals, where i = 1, 2,..., N and t ∈ [1, T]; It is the position of the prey at the t-th iteration, which represents the position where the optimal solution is located at the t-th iteration; substitute the position of the Harris hawk individual into the above fitness calculation formula to obtain the initial fitness value of each Harris hawk. The smaller the fitness value, the better. Set the position of the Harris hawk with the optimal fitness value in the initial population as the initial position of the prey.
5. The Harris hawk mechanism image segmentation method based on bamboo law and entropy according to claim 1, Characterized in that, Step 4 is to divide the energy change of the prey into two stages: an exponential decline stage and a rising-stable stage; from the time relationship between three years and six weeks, it is obtained that the former stage accounts for 97% of the total number of iterations, and the latter stage accounts for 3% of the total number of iterations; when the first stage ends, the iteration is about to come to an end. At this time, because the prey is about to be preyed on by the Harris hawk, an instinctive desire to survive will be stimulated, and the energy of the prey will increase slightly. The energy of the prey in the latter stage is set to linear growth; however, the energy growth of the prey has a certain limit. Therefore, after reaching a certain threshold, the energy of the prey will remain stable until the iteration ends; the energy of the prey is defined by the following expression: where E t is the energy of the prey at the t-th iteration, is a random number between (0, 1) selected at the t-th iteration, which changes with the number of iterations; when |E t | ≥ 1, the Harris hawk enters the global exploration stage, otherwise the Harris hawk enters the local exploitation stage.
6. The Harris hawk mechanism image segmentation method based on bamboo law and entropy according to claim 1, Characterized in that, Step 5 is: In the global exploration stage, the Harris hawk population will search for the prey within the defined range. Before the iteration starts, use entropy to mutate the position of each Harris hawk in the Harris hawk population to improve the global exploration ability. The specific mutation method is as follows: Calculate the fitness probability of the $i$-th Harris hawk in the $t$-th generation Obtain the entropy of the Harris hawk population in the $t$-th generation as After obtaining the entropy of the Harris hawk population, set the mutation step size according to the value of the entropy, and change the position of each Harris hawk; set the mutation step size The calculation formula is: where $H$ max $=\log$ 2 $N$, $\exp()$ represents the exponential function with the natural constant $e$ as the base, and the position of the $i$-th Harris hawk after mutation is where and are the random numbers selected in the $t$-th iteration between $(0, \alpha$ 1 ) and $(0, \alpha$ 2 ) respectively, and $\alpha$ 3 is a constant between $(0, 1)$; After the mutation of the position of each Harris hawk individual is completed, the position of the $i$-th Harris hawk is updated according to the following rules: where is the position of the $i$-th Harris hawk at the $(t + 1)$-th iteration, and are random numbers generated in the interval $(0, 1)$, $\beta$ 1 is a constant between $(0, 1)$, and $abs()$ is a function that takes the absolute value of each variable in the parentheses, is the position of the $m$-th Harris hawk randomly selected at the -th iteration, is the average position of the Harris hawk population at the -th iteration, and its expression is:
7. The Harris hawk mechanism image segmentation method based on bamboo law and entropy according to claim 1, Characterized in that, Step six is: The Harris hawk selects four different siege methods according to the energy and escape probability of the prey to hunt the prey:|E t |≥α 4 When the prey has enough energy to escape, α 4 is the energy control constant, and the Harris hawk executes a soft siege; otherwise, the Harris hawk executes a hard siege. For the i-th Harris hawk in the t-th iteration, a uniform random number between (0, 1) is generated If When the prey is easy to escape, α 5 is the escape probability control constant; otherwise, the prey is not easy to escape; When and |E t | ≥ α 4 At this time, the i-th Harris hawk performs a soft siege and updates its position in the following way: where represents the difference between the prey position and the position of the i-th Harris hawk in the t-th iteration, is the weight parameter, is a random number between (0, 1), and J t is used to simulate the jumping intensity of the rabbit; When and |E t | < α 4 At this time, the i-th Harris hawk conducts a hard siege and updates its position in the following way: When |E t | ≥ α 4 and at this time, the i-th Harris hawk performs a progressive fast dive soft siege and updates its position in the following way: where is the i-th random position, and the d-th dimension of the i-th random position at the t-th iteration is a random number selected between (1, D), d = 1, 2,..., D, L f (D) is the levy flight function; When |E t | < α 4 and , the i-th Harris hawk performs a progressive rapid dive hard siege and updates its position as follows:
Citation Information
Patent Citations
Image segmentation method based on Harris eagle optimization algorithm
CN110827299A
Pressure vessel structure optimization method based on improved Harris eagle optimization algorithm
CN111832135A