Abstract
As one of the most popular image segmentation techniques, multi-level thresholding is widely used. Much work has been done to improve the efficiency of multi-level thresholding, but satisfied affect is hard to achieve. In this paper, a multi-level image segmentation method using between-class variance (Otsu) based on improved bat algorithm (DWBA) with dynamically adjusting inertia weight and velocity stratification theory is proposed. DWBA algorithm has strong global search ability at the beginning. Then, the local search capability is enhanced with numbers increasing of iterations. More importantly, the performance of DWBA further improved, because bats with different fitness values have diverse velocities. Furthermore, an improved local search strategy is proposed to avoid the current best solution being replaced during iterations. The experimental results established that the proposed DWBA algorithm obtains better outcome than other algorithms.
Keywords
Introduction
Image segmentation is an indispensable and difficult step in image processing, which isolates objects of interest from the background [1]. Among all the segmentation methods, thresholding is one of the simplest but effective ways. Nowadays, nonparametric methods are widely used in selecting of optimal thresholds [2]. Such methods employed between-class variance (Otsu) method [3] and entropy measures [4, 5]. Multi-level thresholding is expanded from bi-level thresholding, which is used to split the image into more than two classes. In multi-level thresholding, computation amount of nonparametric methods increases fast with increasing of thresholds number [6]. In order to solve this problem, scholars are interested with applying optimization algorithms to multi-level image segmentation. Gao H, Fu Z, Pun C M, et al. [7] applied an improved artificial bee colony (ABC) algorithm to multi-level thresholding image segmentation. Furthermore, the algorithm’s efficiency and effectiveness were proved by experiments. Liu W, Shi H, He X, et al. [8] proposed a novel thresholding image segmentation method using fireworks algorithm based on Otsu to segment the cement scanning electron microscope (SEM) image, the method showed its advantages in convergence and stability. Khairuzzaman A K M and Chaudhury S [9] studied grey wolf optimizer (GWO) and used Otsu and Kapur’s entropy as objective function. What’s more, the experimental results proved the\enlargethispage 2pt algorithm was stable and efficient. Kwong S T W, Gao H, Pun C M, et al. [10] introduced two updating equations to improve the artificial bee colony algorithm. A novel search direction mechanism was proposed. Then, the new algorithm was used in image segmentation. Pare S, Bhandari A K, Kumar A, et al. [11] suggested a novel technique with modified fuzzy entropy as objective function. Furthermore, Levy flight was used to improve firefly algorithm (FA). The efficient and effective of the new method were verified by simulation results.
Bat algorithm (BA) was proposed based on the behavior of bat by Yang [12], which was widely used in vehicle path planning, knapsack problem, phasor measurement units (PMU) placement optimization, quadratic assignment and wind speed forecasting [13–17]. However, the basic BA algorithm is far to be perfect. The basic BA algorithm did not have strong global research capability as taking real number encoding way, which leads the algorithm easily falling into local optimal solution [18, 19].
In order to improve the exploration and exploitation of basic BA algorithm further, an improved version of BA algorithm (DWBA) is proposed. Please note that multi-level thresholding is the maximum problem. Therefore, the DWBA algorithm is all used for maximum problem in this paper. Comparing with the basic BA algorithm, the improvements of DWBA algorithm are as follows.
(a) In DWBA algorithm, dynamically adjusting inertia weight guarantees the population has strong search capability at the beginning of iterations. With the numbers increasing of iterations, the bats fly speed descent to prevent the missing of the best solution.
(b) Velocity stratification theory is able to adjust the fly speeds of bats based on its fitness values. This mechanism makes the bats adjust the speed in a better way.
(c) Improved local search strategy is a helpful tool for avoiding bats with higher fitness are replaced during local search operation.
The remainder of the paper is structured as follows: Section 2 briefly presents the Otsu method and basic BA algorithm. Section 3 carefully describes the proposed DWBA algorithm. Section 4 presents experimental results and discussions. Section 5 concludes our work.
Related work
Otsu algorithm
Suppose the image gray levels ranging 0 to L - 1, which contains N pixels, the probability can be calculated as follows:
Where h i is the number of pixels of ith level.
We use m thresholds segment the image into m + 1 parts. Each part of gray levels can be represented C0 for [0, … t1 - 1] , …, C
m
for [tm,…,L - 1]. According to Otsu method, the objective function can be expressed as follows:
Where
Let the dimension of search space is D, the new positions
Where β is constant ranging from 0 to 1, x* is the optimal positon at the current, fmax indicates the maximum pulse frequency, fmin is the minimum pulse frequency.
For the local search part, the velocity update based on following Equation.
Where ɛ ∈ [-1, 1] represents random numeral, A t is the average loudness.
In addition, loudness A
t
(i) and pulse emission rate R
t
(i) can be described by:
Where α is constant ranging from 0 to 1, r > 0 is constant controls exploration and exploitation.
Dynamically adjusting inertia weight
The performance of particle swarm optimization (PSO) had improved obviously by using inertia weight [20]. Therefore, scholars applied inertia weight to BA algorithm. Yilmaz S and Kucuksille E U [21] proposed an inertia weight method to improve the performance of BA algorithm. In the design of passive power filters set, Yang N C and Le M D [22] used BA algorithm. More importantly, the effects of different inertia weights including constant inertia weights, linearly time-varying inertia weights, non-linearly time-varying inertia weights and exponentially time-varying inertia weights were studied.

Principle of dynamically adjusting inertia weight.
In this paper, we proposed a novel dynamically adjusting inertia weight to improve the basic BA algorithm. In general, the inertia weight decreases along with the increases of the iterations number. Comparing with linearly time-varying inertia weights, the period of strong global search capacity lasts longer, which helps the algorithm avoids falling into local solution. Furthermore, the local search capacity is enhanced, which contributes to the improving of search accuracy. In a word, the DWBA algorithm has a strong global search capacity at the beginning and good local search ability at the end. The principle is showed in Fig. 1. The novel dynamically adjusting inertia weight is defined as follows:
Where w
star
is the initial inertia weight, w
end
is the end inertia weight, w
middle
is the average of w
star
and w
end
, Tmax is the maximum value of running time, T
middle
is half of the Tmax. The velocity update is given by:

Principle of velocity stratification theory.
In basic BA algorithm, the velocities are updated with same equation without considering the fitness values of each bat. The bats with higher fitness values indicate the positions are near the best positions. Respectively, the bats with lower fitness values means the positons are far from the best positions. Therefore, a velocity stratification theory is proposed to adjust the velocities in a more reasonable way. According to the stratification theory, bats with low fitness values have high fly speeds. Bats with low fitness values fly in high speeds. The principle is presented in Fig. 2, and can be calculated as Equation 11.
Where lp is adjust coefficient.

Pseudocode of DWBA algorithm.
In basic BA algorithm, the local search strategy realizes function by random walk. For each bat if rand > r i , the bat will enter the local search part. The strategy plays an important role in balancing exploration and exploitation. However, if the bat with better fitness values enter the local search part, the superior position is likely to be replaced. Therefore, an improved local search strategy is proposed. The bats enter the local search part needs meet the two requirements: rand > r i and f (x i ) < ave. ave is the average fitness values of all bats. The operation is able to avoid the missing of the superior positions.
The pseudocode of DWBA is showed in Fig. 3.
Results and discussion
In order to show the advantages of DWBA algorithm, a series of experiments is carried on. The experiments are implemented on a personal computer with 8GB of RAM, Core (TM) i5-4590 CPU of 3.30 GHz and with the language of Matlab R2015a, under Windows 7 system. The four algorithms segment the standard image named “Building”, “Mountain”, “Lake”, “Carriage” and the sizes are 512×512 [23].
Four algorithms are used including representativeness and recent ones: differential evolution algorithm (DE) [24], particle swarm optimization (PSO) [25], whale optimization algorithm (WOA) [26] and bat algorithm (BA) [19]. The parameters setting of the five algorithms are showed in Tables 1–5.
Parameters setting in DE algorithm
Parameters setting in DE algorithm
Parameters setting in PSO algorithm
Parameters setting in WOA algorithm
Parameters setting in BA algorithm
Parameters setting in DWBA algorithm
Selected thresholds using the five algorithms based on Otsu algorithm
To evaluate the quality of the segmented image, a widely used indicator peak-signal-to-noise ratio (PSNR) is introduced. PSNR can be expressed [27]:
Here, x (i, j) is the original image, y (i, j) is the segmented image. The image size is M * N.
In the current work, we use DWBA based on Otsu to segment the four images. To make a fair comparison, each of the process runs 20 times. Furthermore, similar process is repeated by DE, PSO, WOA and BA. The best fitness value and its optimal thresholds, PSNR values are recorded in Tables 6–8.
Fitness values based on Otsu using the five algorithms
Figures 4– 7 express the standard images, corresponding histograms and segmented images using five algorithms at different levels. As we can see from the Figures, the DWBA-based method can extract object from the background clearly. The images using DWBA looks better than DE, PSO and BA when m = 5. Taking image “Building” for an example, the detail of river bank can be segmented by DWBA-based method and DE, PSO, BA losing the details. The visual results in Figs. 5– 7 are consistent with those in Fig. 4.
PSNR value of the five algorithms

(a) Original image of “Building”; (b) Histogram Then, the first column is segmented image using DE algorithm. The second column is segmented image using PSO algorithm. The third column is segmented image using WOA algorithm. The third column is segmented image using BA algorithm. The fifth column is segmented image using DWBA algorithm. (c)-(g) m = 2; (h)-(l) m = 3; (m)-(q) m = 4; (r)-(v) m = 5.

(a) Original image of “Mountain”; (b) Histogram Then, the first column is segmented image using DE algorithm. The second column is segmented image using PSO algorithm. The third column is segmented image using WOA algorithm. The third column is segmented image using BA algorithm. The fifth column is segmented image using DWBA algorithm. (c)-(g) m = 2; (h)-(l) m = 3; (m)-(q) m = 4; (r)-(v) m = 5.

(a) Original image of “Lake”; (b) Histogram Then, the first column is segmented image using DE algorithm. The second column is segmented image using PSO algorithm. The third column is segmented image using WOA algorithm. The third column is segmented image using BA algorithm. The fifth column is segmented image using DWBA algorithm. (c)-(g) m = 2; (h)-(l) m = 3; (m)-(q) m = 4; (r)-(v) m = 5.

(a) Original image of “Carriage”; (b) Histogram Then, the first column is segmented image using DE algorithm. The second column is segmented image using PSO algorithm. The third column is segmented image using WOA algorithm. The third column is segmented image using BA algorithm. The fifth column is segmented image using DWBA algorithm. (c)-(g) m = 2; (h)-(l) m = 3; (m)-(q) m = 4; (r)-(v) m = 5.
Table 7 shows that PSO, WOA, BA and DWBA are able to obtain the best fitness values after 20 runs with m = 2. When m = 3, both DWBA and WOA have higher best fitness values than DE, PSO and BA. According to m = 4 and m = 5, DWBA algorithm shows superior performance than other algorithms. It is established that DWBA achieves better fitness values than other algorithms. According to the PSNR values showed in Table 8, it is obvious that DWBA is superior to DE, PSO, WOA and BA.
According to Figs. 8– 11, it is obvious that the standard deviation of DWBA is less than DE, PSO, WOA and BA. When m = 4 and m = 5, the advantages are remarkable. Therefore, it can be claimed that the DWBA has better experimental results than other algorithms.

Box-and-whisker of maximum fitness values after running 20 times independently when m = 2. (a) Building; (b) Mountain; (c) Lake; (d) Carriage.

Box-and-whisker of maximum fitness values after running 20 times independently when m = 3. (a) Building; (b) Mountain; (c) Lake; (d) Carriage.

Box-and-whisker of maximum fitness values after running 20 times independently when m = 4. (a) Building; (b) Mountain; (c) Lake; (d) Carriage.

Box-and-whisker of maximum fitness values after running 20 times independently when m = 5. (a) Building; (b) Mountain; (c) Lake; (d) Carriage.

Comparison of convergence curves for DE algorithm, PSO algorithm, WOA algorithm, BA algorithm and DWBA algorithm for m = 2. (a) Building; (b) Mountain; (c) Lake; (d) Carriage.
In order to confirm the significance of the results in a further way, we use Wilcoxon statistical test to analysis the data which obtained by 20 independent runs [28, 29]. If p-values are less than 0.05, in indicates the statistically significant of the results. As we can see above, the best algorithm is DWBA. Therefore, comparisons are done between DWBA/DE, DWBA/PSO, DWBA/WOA, DWBA/BA for each image.
Tables 9–12 depict the p-values for m = 2, m = 3, m = 4 and m = 5. As we can see the p-values in Table 9, the DWBA shows remarkable advantages than DE and PSO because all the p-values are much smaller than 0.05. However, comparing with WOA and BA, the superiority of DWBA is not obvious. The p-values represented in Table 10 show that the results are significantly better than DE, PSO, WOA and BA. The p-values reported in Table 11 illustrate that the results of image “Mountain” are not remarkable. However, except the case all of the results proof the superiority of DWBA. According to Table 12, the performance of DWBA and WOA is similar on the image of “Lake”. Nevertheless, the p-values are much smaller than 0.05 for image “Building”, “Mountain” and “Carriage”. To sum up, we can conclude that the DWBA is significantly better than other algorithms.
Comparing with m = 3, m = 4 and m = 5, for m = 2 the five algorithms have minimum difference in search accuracy. Hence, we use m = 2 to study the convergence speed in the current work. The convergence curves of the DE, PSO, WOA, BA and DWBA are represented in Fig. 12. It should be noted that all the convergence curves are averaged curves which are achieved by the average of the best fitness values gained so far in each iteration by 20 runs. As we can from the Fig. 11, it is established that the DWBA has the fastest convergence rate than other algorithms. Figure 11 also shows that the number of iterations with DWBA is almost decreased 30% than basic BA. \enlargethispage 3ptThe remarkable improvement is due to the three strategies which proposed in this paper. Initially, the DWBA algorithm has a low possibility for falling into local optimal as the strong exploration ability at the beginning by using dynamically adjusting inertia weight. What’s more, velocity stratification theory plays an important role in the convergence rate improving because the bats with higher fitness search the optimal position with a small step which reduces the possibility of missing the optimal solution. Finally, the current best positions are always retained by using improved local search strategy. Overall, the DWBA algorithm has obvious advantages in convergence speed.
Results of the p-values Wilcoxon rank-sum test for m = 2
Results of the p-values Wilcoxon rank-sum test for m = 3
Results of the p-values Wilcoxon rank-sum test for m = 4
Results of the p-values Wilcoxon rank-sum test for m = 5
Above all, the proposed DWBA algorithm shows superior performance than other algorithms in the experiments. The statistical results and discussions proved the modifications are effective.
For multi-level image segmentation problem, a novel DWBA algorithm is proposed. The new DWBA algorithm adopts dynamic adjustment of inertia weight and has strong global search ability and local search ability. Furthermore, velocity stratification theory plays an important role in promoting algorithm performance. In addition, improved local search strategy is introduced to further enhance the performance of DWBA algorithm. The proposed DWBA algorithm is tested on benchmark images. The experiments results show that the DWBA algorithm not only has obvious advantages in searching precision and running stability, but also has characteristic of fast convergence speed. We conclude that the DWBA algorithm is a powerful tool in multi-level image segmentation.
