Computational Intelligence and Metaheuristic Algorithms with Applications
View this Special IssueResearch Article  Open Access
Adis Alihodzic, Milan Tuba, "Improved Bat Algorithm Applied to Multilevel Image Thresholding", The Scientific World Journal, vol. 2014, Article ID 176718, 16 pages, 2014. https://doi.org/10.1155/2014/176718
Improved Bat Algorithm Applied to Multilevel Image Thresholding
Abstract
Multilevel image thresholding is a very important image processing technique that is used as a basis for image segmentation and further higher level processing. However, the required computational time for exhaustive search grows exponentially with the number of desired thresholds. Swarm intelligence metaheuristics are well known as successful and efficient optimization methods for intractable problems. In this paper, we adjusted one of the latest swarm intelligence algorithms, the bat algorithm, for the multilevel image thresholding problem. The results of testing on standard benchmark images show that the bat algorithm is comparable with other stateoftheart algorithms. We improved standard bat algorithm, where our modifications add some elements from the differential evolution and from the artificial bee colony algorithm. Our new proposed improved bat algorithm proved to be better than five other stateoftheart algorithms, improving quality of results in all cases and significantly improving convergence speed.
1. Introduction
Image segmentation is process of subdivision of an image into homogeneous and disjoint sets sharing similar properties such as intensity, color, and contours. Homogeneous sets are introduced with respect to a certain criterion of homogeneity. Image segmentation usually represents the first step in image understanding and representation and the results obtained by segmentation are used for further highlevel methods such as feature extraction, semantic interpretation, image recognition, and classification of objects. In general, image segmentation simplifies the process of dividing an image into regions that are used for further specific applications. Several practical applications cover character recognition [1], detection of video changes [2], medical imaging [3, 4], automatic target recognition [5], and so forth. Over the last few decades a lot of algorithms for image segmentation, either for gray level or color images, were presented in the literature. Good review of these algorithms can be found in [6]. In general, image segmentation algorithms can be grouped into thresholding, edgebased, regiongrow, and clustering.
Image thresholding is one of the most widespread segmentation techniques that performs image segmentation based on the information contained in the global gray value of the image histogram. Thresholding is called bilevel thresholding in the case that an image is separated into two classes, one including those pixels with gray levels above a specified threshold and the other including the rest. Unlike bilevel thresholding, multilevel thresholding performs subdivision of an image into several classes. In this case the pixels belonging to the same class take gray levels from the intervals defined by successive thresholds. Multiple pixels belonging to the same class are not always homogeneous and may be represented by different feature values. Selection or computing of the multilevel thresholds is crucial in image segmentation since proper segmentation depends on adequately computed thresholds.
There are many different methods for computing the thresholds for an image such as maximizing the gray level variance [7], entropy [8], similarity [9], and measure of fuzziness [10]. In general, thresholding methods can be divided into parametric and nonparametric methods. Using parametric methods, such as a novel image thresholding method based on Parzen window estimate [11], nonsupervised image segmentation based on multiobjective optimization [12], a multilevel thresholding approach using a hybrid optimal estimation algorithm [13], and optimal multithresholding using a hybrid optimization approach [14], may involve the solution of nonlinear equations which increases of the computational complexity. Therefore, the nonparametric methods [15] are introduced for finding the thresholds by optimizing some discriminating criteria. Among the mentioned different thresholding criteria, the entropy is the most popular optimization method. Using the entropy of the histogram, Pun was the first to introduce a new method for gray level image thresholding [8]. Later, this method was corrected and improved by Kapur et al. [16], since Kapur found some artifacts in Pun’s method. Sahoo used Shanon’s concept of entropy, considering two probability distributions for background and foreground objects. He has proposed a thresholding technique based on Renyi’s entropy [17]. Information about the gray value of each pixel and the average value of its immediate neighborhood are obtained by twodimensional entropy which is calculated by twodimensional histogram.
Another important group of methods based on discriminant analysis is the clusteringbased methods [18]. In these methods, gray values are clustered into several classes, so that there is a similarity of gray values within the class and dissimilarity between classes. To perform the separation of classes, Otsu has developed a thresholding method for computing the optimal thresholds by maximizing the betweenclass variance using an exhaustive search [7]. It has been shown that this method gives acceptable results when the number of pixels in each class is close to each other. For bilevel image thresholding, the abovementioned methods are effective. However, for the optimal multilevel thresholding, the existing conventional methods are being hindered by an exhaustive search when the number of thresholds is increased. To overcome this problem, powerful metaheuristics are used to search for the optimal thresholds in order to achieve a fast convergence and reduce the computational time.
Metaheuristics are optimization methods that orchestrate an interaction between local improvement procedures and higher level strategies to create a process capable of escaping from local optima and performing a robust search of a solution space [19, 20]. Several metaheuristic algorithms derived from the behavior of biological and physical systems in the nature have been proposed as powerful methods for searching the multilevel image thresholds. Since magic algorithm that works for all problems does not exist [21], different approaches have been developed for different classes of problems such as combinatorial or continuous, with additions for constrained optimization problems [22]. Original versions of metaheuristic algorithms are often modified or hybridized in order to improve performance on some classes of problems. The most popular natureinspired algorithms for optimization, with improvements, adjustments, and hybridizations, include particle swarm optimization (PSO) [23], differential evolution (DE) [24], firefly algorithm (FA) [25, 26], cuckoo search (CS) [27–29], ant colony optimization [30–33], artificial bee colony algorithm [34–38], bat algorithm (BA) [39, 40], and human seeker optimization (HSO) [41–43].
DE algorithm has been adapted for searching the optimal multilevel thresholds [44]. PSO algorithm modified by Yin to search for the thresholds can be found in [45]. Akay presented a comprehensive comparative study of the ABC and PSO algorithms for finding multilevel thresholds using Kapur’s and Otsu’s criteria [46]. Maitra and Chatterjee proposed an improved variant of PSO algorithm for the task of image multilevel thresholding [47]. The results showed that the ABC algorithm with both the betweenclass variance and the entropy criterion can be efficiently used in multilevel thresholding. Hammouche focused on solving the image thresholding problem by combining betweenclass variance criterion with metaheuristic techniques such as GA, PSO, DE, ACO, SA, and TS [48].
In this paper, we adapted the bat algorithm for multilevel image thresholding. Bat algorithm is simple to implement and produces good results. However, based on our experiments, it is powerful in intensification, but at times it may get trapped into local optima when it is applied to some difficult problems. Therefore, we propose an improved version of bat algorithm adopted to search for multilevel thresholds using Kapur and Otsu criteria. Our proposed modification merges three approaches to produce a new improved batinspired (IBA) algorithm according to the principle of bat algorithm, differential evolution, and some scout technique taken from the ABC algorithm. We compared our proposed algorithm with stateoftheart algorithms from [49]. The experimental results show that the proposed IBA algorithm always gives better results compared to PSO, DE, CS, FA, and BA algorithms, considering both accuracy and, especially, convergence speed.
The remainder of the paper is organized as follows. Section 2 describes the multilevel thresholding problem and presents Kapur’s and Otsu’s objective functions. Section 3 and Section 4 describe the original BA and IBA algorithms adopted to search for the optimal multilevel thresholds, respectively. Section 5 shows the experimental and comparative results of applying PSO, DE, CS, FA, BA, and IBA to multilevel segmentation to standard benchmark images. Finally, our conclusions are discussed in Section 6.
2. Multilevel Image Thresholding
Thresholding technique performs image segmentation based on the information contained in the image histogram. If we consider a grayscale input image as a set of pixels , multilevel thresholding can be defined as a method of dividing the set into disjoint subsets by some numbers such that where is a pixel defined by coordinates and in the Cartesian coordinate system, presents a gray level value of pixel , and the takes values in the range . The aim of multilevel thresholding is to compute the optimal threshold values . The sets may represent different regions of the object. It is clear that , and their union presents the whole input image .
Optimal threshold selection for bilevel thresholding is not computationally expensive, while for multilevel thresholding, computing more than few optimal threshold values is an expensive and time consuming operation. The optimal threshold values can be determined by optimizing some criterion functions defined from the histogram of image. In this paper, we use two popular threshold criteria: Kapur’s entropy criterion and Otsu’s betweenclass variance criterion.
2.1. Kapur’s Thresholding Method
Entropy is a measure of uncertainty proposed by Shannon [50], later widely used [51]. Let be a discrete random variable taking values with probabilities , , respectively. Then its entropy is defined by
The Kapur’s method [16] based on the entropy is used to perform multilevel thresholding. For this method, the threshold criteria can be formulated as follows. Assume that an image contains pixels with gray levels belonging to the set . Let present the number of pixels at gray level , and is the probability of occurrences of gray level in the image . The subdivision of an image into classes can be considered as a dimensional optimization problem for the calculation of optimal thresholds . The optimal thresholds are obtained by maximizing the objective function: where the entropies are defined by
2.2. Otsu’s Thresholding Method
Otsu’s method [7] based on the maximization of the betweenclass variance is one of the most popular methods proposed for image thresholding. The algorithm for this method can be described as follows. Assume that an image can be represented by gray levels. The probabilities of pixels at level are denoted by so and . Cumulative probabilities for classes , , can be defined as where are the thresholds separating these classes. For classes , , the goal is to maximize the objective function: where the sigma functions are defined by
3. Bat Algorithm Adapted for Multilevel Image Thresholding
Bat algorithm is a recent metaheuristic introduced by Yang [39], based on socalled echolocation of the bats. In this algorithm, bats detect prey and avoid the obstacles by using the echolocation. Bat algorithm was successfully applied to a number of very different problems like largescale optimization problems [52], global engineering optimization [53], fuzzy clustering [54], parameter estimation in dynamic biological systems [55], multiobjective optimization [56], image matching [57], economic load and emission dispatch problems [58], data mining [59], scheduling problems [60], neural networks [61], and phishing website detection [62].
In the bat algorithm, bats navigate by using time delay from emission to the reflection. The pulse rate can be simply determined in the range from to , where means that there is no emission and means that the bat’s emitting is at maximum. Apart from the control parameters, such as the population size and maximum iteration number which are common control parameters for all nature inspired algorithms, the BA has few important parameters such as frequency tuning parameter similar to the key feature used in the PSO and HS, parameter for automatically zooming into a region where the promising solutions have been found, and the control parameter for automatically switching from exploration to exploitation. This gives advantage to the BA over other metaheuristic algorithms in the literature.
In order to implement the bat algorithm, the following three idealized rules are used [39]: (i) all bats use echolocation to sense distance, and they also “know” the surroundings in some magical way; (ii) bats fly randomly with velocity at position with a fixed frequency , varying wavelength , and loudness to search for prey. They can automatically adjust the wavelength of their emitted pulses and adjust the rate of pulse emission from , depending on the proximity of their target;(iii) although the loudness can vary in many ways, it is assumed that the loudness varies from a positive large value to a minimum constant value .
The proposed bat algorithm tries to select threshold values which maximize the fitness functions which are described by (3) and (6), respectively. The details of the developed BA approach for multilevel image thresholding are given as follows.
Step 1 (generate initial population of solutions). The bat algorithm generates a randomly distributed initial population of solutions (bats) , where each solution has dimensions. All solutions can be presented by matrix : where is the component value that is restricted to and for all . The fitness values for all solutions are evaluated and variable is set to one. The bat algorithm detects the most successful solution as before starting iterative search process.
Step 2 (calculation of new solutions). Calculation of a new solution is performed by moving virtual bats according to equation where denotes the bat velocity of movement, and it is calculated by formula In (10), denotes the frequency and denotes the current global best solution. The frequency can be calculated as where is a random vector generated by a uniform distribution belonging to the closed interval . For min and max frequency, the recommended values and are used. In this computation step, the bat algorithm controls the boundary conditions of the calculated new solution . In the case that the value of a variable overflows the allowed search space limits, then the value of the related variable is updated with the value of the closer limit value to the related variable.
Step 3 (improving the current best solution). For each solution apply the next operator which is defined by where is a uniform random number in range , is a scaling factor drawn from uniform distribution in the range , is the average loudness of all bats at the computation step , and is the pulse rate function. The pulse rate function is defined by where is a constant and are initial pulse rates in the range . It can be seen from (12) that this function controls the intensive local search depending on the value of uniform variable and the rate . Also, at this step, the BA controls the boundary conditions at each iteration.
Step 4 (acceptation of a new solution by flying randomly). In this step, the solution obtained in Step 3 is accepted as a new solution and as a new objective function value by using where is a uniform random number in range and is the loudness function defined by where is a constant and plays a similar role as the cooling factor of a cooling schedule in the simulated annealing. Therefore, if the solution has the higher objective function value compared to the old solution and the loudness is more than , then the new solution is accepted, the old fitness value is updated, and functions defined by (13) and (15) are updated, too. Otherwise, the new solution is abandoned, and the old best solution is kept.
Step 5 (memorize the best current solution). Record the best solution so far (), that is, the solution with the highest objective function value.
Step 6 (check the stopping criteria). If the termination criterion is met or the variable is equal to the maximum number of iterations, then the algorithm is finished. Otherwise, increase the variable by one and go to Step 2.
4. Our Proposed Improved Bat Algorithm: IBA
As described in the previous section, we selected the BA for multilevel image thresholding. BA is simple to implement and it produces good results when the number of thresholds is small. However, based on our experiments, the BA algorithm often fails when the number of thresholds is larger, especially for the Kapur’s objective function. Therefore, an adjustment of the bat algorithm was required. In this paper, the improved hybridized bat algorithm (IBA) is proposed to overcome the mentioned drawback of the pure bat algorithm. It combines two different solution search equations of the bat algorithm and DE algorithm [24]. The IBA algorithm includes differential operators mutation and crossover from DE algorithm, with the aim of speeding up convergence and to achieve a good balance between intensification and diversification. Mutation and crossover operators are used to improve the original BA generation of a new solution for each bat so that the IBA can more efficiently explore and exploit the new search space and avoid being trapped into local optima.
In the pure BA, exploration and exploitation are controlled by pulse rate function (13). Analyzing this function we noticed that the algorithm loses exploration capability as iterations progress. The form of this function makes switching from the exploration to exploitation and vice versa possible. In this way, the exploration capability of BA can be modified by inserting differential operators for crossover and mutation [24] instead of (12) and for the exploitation capability (12) continues to be used for a good intensification. Therefore, a good balance is established between intensification and diversification.
Although the above modification can improve many solutions, some solutions will still remain stuck in some local optimum. In order to fix this lack of the former modification, we introduced the second modification which is inspired by launch of the scouts in the scout phase of the ABC algorithm. When some solution gets trapped in a local optimum after a certain number of iterations, it will eventually exceed the predetermined number of allowed trials called “limit.” When a solution exceeds the “limit” trials unchanged, it is redirected to search new space by using the random walk.
In the proposed IBA algorithm, bats form a population of threshold values. The threshold values produced by the bat are noted as , . All bats perform searching in the solution search space with the aim to optimize the objective functions described by (3) or (6). The details of the proposed IBA approach for multilevel thresholding are given as follows.
Step 1 (generate the initial population of solutions). The IBA begins by randomly generating population with dimensions as in the case of the proposed BA approach for multilevel thresholding. Each threshold value of the matrix generated by the bat is restricted to set and for all holds . Also, at this step initialization is done for the parameter limit which presents the number of allowed attempts to improve a bat, the initial loudness and pulse rate , as well as the initial values of the parameters in the DE algorithm such as the differential weight and crossover probability . After generation of the initial population, the fitness value for each solution is evaluated. Then the IBA algorithm detects the most successful solution as , before starting iterative search process. After that it sets the variable to one.
Step 2 (calculate the new population). Calculation of a new threshold is performed by moving virtual bats according to (9). The velocity and frequency are calculated by (10) and (11), respectively. At this computation step, the IBA controls the boundary conditions of the calculated new solution . In the case that the value of the is less than or is more than , then the value of the is updated with the value of the closer limit value to the variable .
Step 3 (improving the current best solution by differential operators). For each solution apply the next operator which is defined by where is randomization term in the range , is the pulse rate function defined by (13), is the differential operator for mutation and crossover, and is the operator based on the local search in the BA. The differential mutation and crossover operations are performed by where , , and are three randomly chosen different vectors in the range at the cycle , is the differential weight that scales the rate of modification, is the crossover probability in the interval , is randomly selected in the range , and is a uniform variable in the range . Inside the implementation of the differential operator , the boundary conditions for all are controlled. As an important improvement of the proposed method, the binomial “DE/rand/1/bin” scheme is used in order to increase the diversity of the bats and achieve both the precision and search efficiency. The local search is performed by where is defined by
As in the ordinary BA, parameters and denote the scaling factor and the loudness function, respectively. Also, inside the local search operator , the boundary conditions for all are checked. In our proposed approach, we found that it is beneficial to replace (13) by . It will be shown in experimental study that the best results are obtained for initial pulse rates , initial loudness , and .
Step 4 (acceptation of a new solution by flying randomly). In this step, the solution obtained in Step 3 is accepted as a new solution and as a new objective function value by using where is a random number in the range , is a vector recording the number of attempts through which solution could not be improved at cycle , and is defined by (15). In the above equation, if the solution cannot be improved, then the new solution is abandoned and the element of the trial vector tr is increased by one. Also, after certain number of cycles determined by the variable limit, if the solution cannot be further improved, it is abandoned and replaced by randomly generated solution. In this case, the element of the trial vector is set to . This modification can improve the exploration process and it will help to avoid trapping into some local optima. Also, it will improve the solution quality and speed convergence.
Step 5 (memorize the best current solution). Record the best solution so far (), that is, the solution with the highest objective function value.
Step 6 (check the stopping criteria). If the termination criterion is met or the variable is equal to the maximum number of iterations, then the algorithm is finished. Otherwise, increase the variable by one and go to Step 2.
5. Experimental Results
The multilevel image thresholding problem deals with finding optimal thresholds within the range that maximize the functions defined by (3) and (6). The dimension of the optimization problem is the number of thresholds , and the search space is . In this study our proposed IBA algorithm was compared against four other standard population based metaheuristic techniques: PSO, DE, CS, and FA from [49] and pure BA.
The experiments were conducted on 6 standard images, the same as used in [49], in order to make comparison of the obtained results simpler. Images used in this paper, namely, Barbara, Living room, Boats, Goldhill, and Lake, are of size and Aerial has size . Barbara and Boats images are available at http://decsai.ugr.es/~javier/denoise/test_images/. The Living room and Lake images were chosen from http://www.imageprocessingplace.com/root_files_V3/image_databases.htm. The Goldhill image can be found at https://ece.uwaterloo.ca/~z70wang/research/quality_index/demo.html. The Aerial image was taken from the University of Southern California Signal and Image Processing Institute’s image database at http://sipi.usc.edu/database/database.php?volume=misc. These original images and their gray level histograms are depicted in Figures 1 and 2, respectively.
(a)
(b)
(c)
(d)
(e)
(f)
(a)
(b)
(c)
(d)
(e)
(f)
For the Kapur’s and Otsu’s thresholding methods, the exhaustive search method was conducted first to derive the optimal solutions, the corresponding optimal objective function values, and the processing time for comparison with the results generated by the PSO, DE, CS, FA, BA, and IBA algorithms. These results generated by the exhaustive search for Kapur’s and Otsu’s criterion are presented in Tables 1 and 2, respectively. It is obvious that computational times increase exponentially and for more than 5 thresholds become unacceptable. We did not implement optimal use of multicore processor, but improvements would not be significant.


The number of thresholds explored in the experiments were 2, 3, 4, and 5. Since metaheuristic algorithms have stochastic characteristics, each experiment was repeated times for each image and for each value. Each run of an algorithm was terminated when the fitness value of the best solution reached the known optimal value (from the exhaustive search) of the objective function , that is, , where was a tolerance for the accuracy of the measurement. Hence, the stopping condition for all algorithms was the value of the fitness, unless optimum could not be reached within 2000 iterations.
The proposed IBA method has been implemented in programming language, as the rest of the algorithms. Results for CS and FA are from [49]. All tests were done on an Intel Core i73770K @3.5 GHz with 16 GB of RAM running under the Windows 8 x64 operating system. The PSO and DE algorithms have been implemented in their basic versions, while the BA and IBA have been implemented as it was described in the previous two sections.
5.1. Parameters Setup
To compare the proposed IBA algorithm with PSO, DE, CS, FA [49], and BA algorithms, the objective function evaluation was computed times, where is the population size and is the maximum number of generations (unless optimum was reached earlier). The population size in all algorithms was set to and the number of generation is set to for all algorithms, as in [49]. Besides these common control parameters, each of mentioned algorithms has additional control parameters that directly improve their performance. For both the proposed IBA and pure BA algorithms, the additional control parameters and were set to and , respectively. The initial values for parameters and loudness were set to and , respectively. The constant was set to . Instead of the average loudness of all bats, we found that the value was acceptable for all images. In the proposed IBA algorithm, control parameters introduced from DE algorithm, such as differential weight and crossover probability , were set to and , respectively. Also, in the IBA method, the parameter limit was set to .
5.2. Quality and Computational Analysis of the Results
The mean and standard deviations for 50 runs for six tested metaheuristic algorithms have been calculated and are presented in Table 3 for the experiments based on Kapur’s entropy and in Table 4 for the experiments based on Otsu’s objective function. These mean values can be compared to the optimal values of the corresponding objective functions found by an exhaustive search from Tables 1 and 2.

