Applied Artificial Intelligence, 28:47–65, 2014 Copyright © 2014 Taylor & Francis Group, LLC ISSN: 0883-9514 print/1087-6545 online DOI: 10.1080/08839514.2014.862773
FUZZY FA: A MODIFIED FIREFLY ALGORITHM
Tahereh Hassanzadeh and Hamidreza Rashidy Kanan Department of Electrical, Computer and IT Engineering, Qazvin Branch, Islamic Azad University, Qazvin, Iran
The firefly algorithm (FA), which is usually used in optimization problems, is a stochastic, population-based algorithm inspired by the intelligent, collective behavior of fireflies in nature. In the standard FA, each firefly in each neighborhood is compared with other fireflies, and the less-bright firefly moves toward the brighter one (in the maximization optimization). In fact, in the standard FA, firefly movement is based on the local optima, and the global optima do not have any effect on the movement of fireflies. So, the exploration rate of the FA decreases. In this study, we propose a new, fuzzy-based, modified version of the standard FA—the fuzzy firefly algorithm (FFA)—to increase the exploration and improve the global search of the FA. In the FFA, to improve the speed of finding the global optima, in each iteration the global optima and some brighter fireflies have influence on the movement of fireflies. The effect of each firefly depends on its attractiveness, which is considered as a fuzzy variable in the FFA. In order to evaluate the proposed FFA, seven well-known benchmark functions, including Sphere, Rastrigin, Rosenbrock, Step, Schwefel’s P2.22, Ackly, and the Xin-She Yang functions are used in 10-, 20-, and 30-dimensional spaces. Also, to indicate the effectiveness of the proposed FFA, we utilize our approach in a multilevel image-thresholding application, which is one of the most important and challenging issues in image segmentation, and we propose the FFA-Otsu method. The experimental results show that our proposed method can be effective to find the global optima and can improve the global search and the exploration rate of the standard FA. Moreover, the obtained thresholding results show that the proposed FFA-Otsu algorithm is more efficient when compared with other benchmark approaches for image segmentation.
INTRODUCTION Collective intelligence is a type of artificial intelligence that is based on collective behavior of agents in decentralized and selforganized systems. These systems are usually organized from simple agents that cooperate locally with other elements and environments. Address correspondence to Hamidreza Rashidy Kanan, Department of Electrical, Computer and IT Engineering, Qazvin Branch, Islamic Azad University, Qazvin, Iran. E-mail:
[email protected]
48
T. Hassanzadeh and H. R. Kanan
However, there is not any centralized mechanism on the agents’ behaviors. So, nature-inspired metaheuristic algorithms are becoming more powerful algorithms for solving optimization problems (Baeck, Fogel, and Michalewicz 1997; Bonabeau, Dorigo, and Theraulaz 1999; Kennedy, Eberhart, and Shi 2001; Yang 2005; Liu and Passino 2005). There are different methods for solving optimization problems. Particle swarm optimization (PSO; Kennedy and Eberhart 1995), ant colony optimization (ACO; Darigo, Birattari, and Stutzle 2006), artificial fish swarm algorithm (AFSA; Li, Shao, and Qian 2002) and bee colony (Pham et al. 2006) are the most well-known algorithms that have been proposed for optimization. By idealizing some of the flashing characteristics of the fireflies, the firefly algorithm (FA) was recently introduced by Yang at Cambridge University (Yang 2008). This swarm intelligence optimization technique is based on the assumption that the solution of an optimization problem can be shown as a firefly, which glows proportionally to its quality in a considered problem setting. Consequently, each brighter firefly attracts its partners, which makes the search space being explored. Yang used the FA for nonlinear design problems (Yang 2010a) and multimodal optimization problems (Yang 2009) and showed the efficiency of the FA for finding global optima in two-dimensional environments. Yang also introduced a new version of the FA (Levy FA), which combined Levy flight with the search strategy via the firefly for improving the randomization of FA (Yang 2010b). The discrete firefly algorithm was also introduced recently by Sayadi, Ramezanian, and Ghafari-Nasb (2010). The Yang optimization results imply that the FA is potentially more powerful than other existing algorithms such as PSO (Yang 2010a). Some characteristics of the FA that make it suitable for solving optimization problems are that the FA is superior to both PSO and genetic algorithms (GA) in terms of efficiency and convergence (Yang 2009). In this article, we introduce a fuzzy firefly algorithm (FFA) for improving the global search of FA. In the proposed algorithm, to improve the convergence rate of the FA, more than one firefly representing the global optima and some brighter fireflies have an effect on other fireflies’ movements to search the landscape and find the global best. The degree of effectiveness of each k-best firefly in the movement of other fireflies in each iteration depends on their attractiveness, which is considered as a fuzzy variable in FFA. Image segmentation is one the most difficult and challenging issues in image processing. It is often the first preprocessing step in many image-processing applications. Segmentation is defined as separating objects from background, or objects that have distinct gray levels, from each other. Image thresholding is widely used for image segmentation.
Fuzzy FA: A Modified Firefly Algorithm
49
There are two thresholding methods: bi-level thresholding and multilevel thresholding. Bi-level threshholding is a division of the pixels into two groups: one group contains those pixels with gray levels higher than a certain threshold, and the other group includes the rest. Multilevel thresholding is a division of the pixels into several clusters, and the pixels are assigned to a cluster based on their gray level and the specified threshold values. Some objective functions, which are very efficient for the bi-level thresholding purpose, are not suitable for multilevel thresholding because of the exponential growth of computational complexity. Images of gray-level histograms are considered as efficient tools for improvement of the image-segmentation algorithms. The objective is to find the gray-level values, called thresholds, and then segment the pixels according to the thresholds. The simplest way is a bi-level thresholding problem in which only one threshold value is to be found. However, the problem gets more and more complex when we try to achieve segmentation with more details by employing multilevel thresholding in which more than one threshold are to be found. Several algorithms have so far been proposed in the literature to address the issue of histogram thresholding (Otsu 1979; Liao, Chen, and Chung 2011; Kapur, Sahoo, and Wong 1985; Pun 1981; Saha and Udupa 2001; Hu, Hou, and Nowinski 2006; Cheng, Chen, and Li 1998; Cheng and Lui 1997; Brink 1995). Many of them handle the bi-level thresholding; others have considered the multilevel problem. Methods based on optimizing an objective function include maximization of posterior entropy to measure homogeneity of segmented classes (Kapur, Sahoo, and Wong 1985; Pun 1981; Saha and Udupa 2001; Cheng and Lui 1997; Lim and Lee 1990) and maximization of the measure of separability on the basis of between-class variance (Otsu 1979). Several algorithms such as the Kapur (Kapur, Sahoo, and Wong 1985) and Otsu (Otsu 1979) methods were originally developed for bi-level thresholding and later extended to multilevel thresholding. The disadvantage of these methods is that with the increase in the number of thresholds, the computation rate and total runtimes, because of the exhaustive search employed, also increased. In order to solve the problem of optimizationbased approaches, we also introduced the FFA-Otsu method, which is more efficient. We evaluate our proposed FFA by using seven famous benchmark functions (i.e., Sphere, Rastrigin, Rosenbrock, Step, Schwefel’s P2.22, Ackly, and Xin-She Yang) in 10-, 20-, and 30-dimensional spaces and comparing the results with the standard FA. The experimental results indicate the better performance of the proposed algorithm to find the global optima and to improve the global search and the exploration
50
T. Hassanzadeh and H. R. Kanan
rate of the standard FA, especially in high-dimensional and complex environments. Also, the obtained thresholding results show that our proposed FFA-Otsu method is more efficient in comparison with other image-segmentation benchmarks algorithms. In the following, “Firefly Algorithm” briefly presents the FA. This is followed bysections that decribe the “Proposed Fuzzy Firefly Algorithm” and “Application of the Proposed FFA in Multilevel Thresholding.” In “Experimental Results,” the proposed method is extensively examined under various dimensions and compared with seven benchmark approaches. This section also presents the experimental results of the proposed FFA-Otsu algorithm in image segmentation. The “Conclusions” section summarizes the article. FIREFLY ALGORITHM Most fireflies produce short and rhythmic flashes, and fireflies use these flashes for communicating and attracting their potential prey. Yang used this behavior of fireflies and introduced the firefly algorithm (FA) in 2008 (Yang 2008). In the FA algorithm, there are three idealized rules: (1) All fireflies are unisex. So, one firefly will be attracted to other fireflies regardless of their sex. (2) Attractiveness is proportional to their brightness. Thus, for any two flashing fireflies, the less bright one will move toward the brighter one. The attractiveness is proportional to the brightness, and they both decrease in attractiveness as their distance increases. If there is no brighter one than a particular firefly, it will move randomly. (3) The brightness of a firefly is affected or determined by the landscape of the objective function. For a maximization problem, the brightness can simply be proportional to the value of the objective function (Yang 2008). In the firefly algorithm, there are two important issues for variation of light intensity and the formulation of the attractiveness. For simplicity, it is assumed that the attractiveness of a firefly is determined by its brightness, which is associated with the objective function of the optimization problem. Because a firefly’s attractiveness is proportional to the light intensity seen by adjacent fireflies, we can now define the attractiveness of a firefly by (r ) = 0 e −r , 2
(1)
where 0 is the attractiveness at r = 0 and is the light absorption coefficient at the source. It should be noted that the ri,j , which is described by Equation (2), is the Cartesian distance between any two
Fuzzy FA: A Modified Firefly Algorithm
51
fireflies i and j at xi and xj , where, xi and xj are the spatial coordinates of the fireflies iand j , respectively. d 2 ri, j = xi − xj = xi, k − xj , k (2) k=1
The movement of a firefly i, which is attracted to another moreattractive firefly j , is determined by 1 −r 2 Xi = xi + 0 e ij xj − xi + rand − , (3) 2 where the second term is the attraction and the third term is randomization including randomization parameter and the random number generator “rand” which numbers are uniformly distributed in interval [0,1]. For most cases of implementations, 0 = 1 and ∈ [0, 1] (Yang 2010a) The parameter characterizes the variation of the attractiveness and its value is important to determine the speed of the convergence and how the FA behaves. In the most applications, it typically varies from 0.01 to 100 (Yang 2010a). THE PROPOSED FUZZY FIREFLY ALGORITHM (FFA) In this study, a new FFA is proposed. In the standard FA, in each iteration the brighter firefly (local optima) exerts its influence over other fireflies and attracts them toward itself in maximization optimization. In fact, in the standard FA, fireflies move regardless of the global optima, which can increase the number of iterations to find the global best and decrease exploration of the firefly algorithm. In this study, to eliminate the weaknesses of the standard FA and to improve the collective movement of fireflies, we propose a fuzzy-based modified version of FA in which some fireflies in each iteration can influence others and their movements. It should be mentioned that, in the standard FA, only one firefly in each iteration can affect others and attract its neighbors. The attractiveness of each firefly depends on its brightness. The level of attractiveness of each k-best firefly is represented as a fuzzy variable. In the proposed algorithm, the k-brighter fireflies in each iteration are selected to be candidates, where k is a user-set parameter and it depends on the complexity and the population size of the problem. The numbers of alternatives are possible for the attractiveness membership function. In this research, we use the Cauchy function as a membership
52
T. Hassanzadeh and H. R. Kanan
function of the proposed algorithm. Let h be one of the k-brighter fireflies in each iteration, and f (pg ) refers to the fitness of the local optima (a firefly that is brighter than the compared one) in each iteration. We compute the attractiveness (h) of firefly h as (h) = f
1 (ph )−f (pg )
,
(4)
where f(ph ) is the fitness function of k-brighter fireflies. To avoid dependence on the scale of the fitness function, we set f pg = , (5) where is a user-specified parameter. For a fixed f(ph ), the larger the value of , the smaller the attractiveness (h). In the FFA, we use Cartesian distance to compute the distance of fireflies (same as the standard FA), but for movement of the firefly, Equation (3) is replaced by
k 1 2 −rij2 −rih (xh − xi ) rand − Xi = xi + 0 e xj − xi + , (6) (h) 0 e 2 h=1 where xi is the spatial coordinate of the less brighter firefly, second term is due to the attraction of the brighter firefly, and the third term is a fuzzy variable that shows the level of attractiveness of k-brighter fireflies (in all n fireflies) in the movement of fireflies. APPLICATION OF THE PROPOSED FFA IN MULTILEVEL THRESHOLDING In this section, to show the capability of the proposed algorithm, the combination of the proposed FFA and the Otsu method (Otsu 1979) has been used for image segmentation. Otsu introduced a method that maximizes the between-class variance to separate the segmented classes as far apart as possible in order to find the optimal threshold for segmentation. When partial background is mistakenly taken as a target, variance of intracluster will lessen; therefore, the largest Otsu means the least probability of a mistake occurrence. This between-class variance measure is called Otsu’s multithreshold measure and is used as the objective function in the FFA. It is formulated as follows: Assume the image size is M × N and the number of its gray levels is L ranging from 0 to (L − 1). The number of pixels with gray level i is
Fuzzy FA: A Modified Firefly Algorithm
53
ni . Thus, the number of image pixels is: L−1
n=
ni = M × N
(7)
i=0
So, the normalized histogram and the probability distribution are pi =
ni , n
L−1
pi = 1
(8)
i=0
The image is divided into two classes with the standard threshold t . The class c1 includes the pixels i ≤ t , and the class c2 includes the pixels i ≥ t . Cumulative probabilities of c1 and c2 are 1 =
t
pi = (t ),
(9)
i=0
2 =
L−1
pi = 1 − (t )
(10)
i=t +1
The mean level and the variances of class c1 and c2 are 1 =
t ipi i=0
t ipi , = 1 (t ) i=0
L−1 L−1 ipi ipi , = 2 = 2 i=t +1 1 − (t ) i=t +1
(11)
(12)
12
t (i − 1 )2 pi = , 1 i=0
(13)
22
L−1 (i − 2 )2 pi = 2 i=t
(14)
Based on the above equations, the intercluster and the intracluster variances are as follows, respectively:
2 = 1 12 + 2 22 ,
(15)
B2 = 1 ( 1 − T )2 + 2 ( 2 − T )2 ,
(16)
where, the T is the mean intensity of whole original image. The best threshold value T should satisfy the following condition (the is our
54
T. Hassanzadeh and H. R. Kanan
fitness function that must be optimized):
B2 = max 2
(17)
When the image has a complex target area, the Otsu method should be extended to two or more thresholds. In the proposed method, we used Equation (17) as a fitness function to find optimal thresholds. The proposed method can be summarized as follows: Step 1: Initialize fireflies and set parameters. Step 2: Compute the variance of each segment of the image according to threshold value and compare the computed value with other fireflies’ values. Step 3: Move firefly to a new position according to the updating mechanism of fireflies’ position and fitness in FFA. Step 4: Check whether the iteration number has reached the maximum value. If so, deduction ends, otherwise, jump to Step 2. Step 5: Finally, segment the image by optimal thresholds. For evaluation of the segmentation results, we use uniformity measure U =1−2×c ×
c
(fi − j )2 /N /(fmax − fmin )2 ,
(17)
i=0 i∈Ri
where c is the number of thresholds, Rj is the j th segmented region, N is the total number of pixels in the given image, fi is a gray level of pixel i, j is a mean gray level of pixels in the j th region, and fmax and fmin are the maximum and minimum gray levels of pixels in the given image, respectively. The value of this uniformity measure U should be a positive fraction, in other words, it should be between 0 and 1. A large value of U indicates that there is better uniformity in the segmented image, representing a better quality of thresholding. Conversely, a smaller value of U indicates worse quality of the thresholding procedure. EXPERIMENTAL RESULTS In this part, at first we evaluate the proposed FFA algorithm according to the seven benchmark functions and then show the results of the proposed image-segmentation algorithm.
55
Fuzzy FA: A Modified Firefly Algorithm
Experimental Results of FFA In this section, at first the parameters of the FA are studied and tried in order to set the proper parameters to improve the results. One of the most important parameters of FA is which is important for controlling the distance of the random walks. So, it should be linked with scales of the problem variables. In the standard FA, is set in interval [0,1], and it is recommended to set 0.2 (Yang 2008). Considering that, the nature of the firefly algorithm is exploitive. So, increasing can improve the exploration rate of the fireflies as well as the random motion of particles. In order to find the optimal value of , several experiments were performed. For example, we evaluated the effect of different values of this parameter to find the global optima of the Ackly function in 10-dimensional spaces. For this experiment, the number of fireflies is set as 60; also, we set = 1 and 0 = 1. Experiments were repeated 30 times, and the best, mean, and standard deviations have been shown in Table 1. As Table 1 shows, tuning in interval [0,1] cannot be a very effective way to find global optima of function in high-dimensional spaces. The results indicate that by increasing this parameter to 20, the results are improved, and then they decrease again. It shows that the random walk of fireflies shouldn’t be so large. In general, we can say that by increasing to 20, we could improve the motions of individual fireflies. Following this section, seven functions, all of which are standard test functions, are utilized for evaluation of the proposed FFA algorithm. This test functions, together with their search space ranges, are presented in Table 2. It should be mentioned that the global optimum solution of the above functions is 0. In this study, for evaluation of the proposed algorithm, we execute the standard FA and the proposed FFA 30 times and the largest iteration numbers are set as 30 for the seven functions. TABLE 1 The Best, Mean, and Standard Deviation Values of the Ackly Function for Different Values of Parameter 0 0.2 0.5 1 10 20 50 100
Best
Mean
St. D.
18.3996 16.7709 18.5360 16.1968 0.0019 2.7244e-005 5.3304e-005 9.4723e-005
19.5385 19.4312 19.5548 19.3277 0.0169 0.0062 0.0060 0.0069
0.5520 0.6706 0.3279 0.7975 0.0146 0.0046 0.0063 0.0078
56
T. Hassanzadeh and H. R. Kanan
TABLE 2
Seven Standard Test Functions Used for Evaluation of the Proposed FFA
Test Function f0 (x) = f1 (x) = f2(x) = f3(x) = f4(x) =
D
xi2
i=1 D
2 − 10 cos (2 xi ) + 10 xi=1
i=1 D
2 2
100 xi+1 − xi
i=1 D
+ (xi − 1)2
2
xi + 0.5
Name of the Function
[−100, 100]D
Sphere
[−5.12, 5.12]D
Rastrigin
[−50, 50]D [−100, 100]D
i=1 D i=1
Search Space
xi − D xi i=1
−0.2
1 n
D
xi2
i=1 f5 (x) = 20 −e D+ e − 20e 2 xi exp − sin x f6 (x) = i
1 2
D i=1
cos(2 xi )
Rosenbrock Step
[−10, 10]D
Schwefel’s P2.22
[−32, 32]D
Ackly
[−2 , 2 ]D
Xin-She Yang
i=1
We test the mentioned functions in 10, 20-, and 30-dimensional spaces. The population size for 10-D is 60, 20-D is 80, and 30-D is 100. Selection of appropriate k is one of the most important issues in FFA; k must be selected based on the population size and the problem complexity. The algorithm computation rate will be increased by increasing the k; therefore, it must be selected carefully. In this article, for the proposed algorithm based on the population size, k is determined to be 3 and is set as 2.6 for evaluation. Also, we set = 1, = 0.2 and = 1 for standard FA as well as FFA; but for FFA we set = 20. Experiments were repeated 30 times and the best, mean, variance, standard deviation and the worst case that is obtained from the standard run in 10, 20-, and 30-dimensional spaces on Sphere, Rastrigin, Rosenbrock, Step, Schwefel’s P2.22, Ackly and Xin-She Yang functions are shown in Table 3. As Table 3 indicates, the results of the FFA in all cases are better than FA in 10-, 20-, and 30-dimensional spaces, and it shows the capability of the proposed algorithm to find optimal solutions. In the proposed algorithm, we improved FA using k number of the brighter fireflies for searching in the function landscape for finding the best solution. Especially in high-dimensional spaces, the proposed method can be more effective. For example, we execute FA and FFA for finding the global minimum of Ackly, Rosenbrock, Step, and Rastrigin functions in 20- and 30dimensional spaces for 30 iterations and show the best result of each iteration in Figure 1. As shown in Figure 1, results show that FFA considerably improves the performance and increases the exploration of FA. The main reasons are
57
Fuzzy FA: A Modified Firefly Algorithm TABLE 3 Comparison of FA and FFA on Sphere, Rastrigin, Rosenbrock, Step, Schwefel’s P2.22, Ackly, and Xin-She Yang Functions Functions Sphere
Dim
Criteria
FA
FFA
10
Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ace-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst
8.5209e+003 1.4268e+004 ± 2.7545e+003 1.9374e+004 2.5357e+004 3.7581e+004 ± 5.4730e+003 4.7557e+004 4.1740e+004 6.1742e+004 ± 6.4849e+003 7.2753e+004 78.3042 101.3838 ± 12.2943 130.3316 202.4528 229.8796 ± 10.9620 258.5239 290.5845 344.3529 ± 18.7868 380.4754 3.2885e+007 1.9619e+008 ± 6.3834e+007 3.3092e+008 4.1349e+008 8.4050e+008 ± 1.5957e+008 1.1528e+009 8.8931e+008 1.5378e+009 ± 2.6574e+008 1.9420e+009 7300 1.3533e+004 ± 2.6312e+003 19727 25525 3.3836e+004 ± 4.4869e+003 43046 48933 60208 ± 5.9982e+003 68721 17.1649 273.1700. ± 210.3776 1.0883e+003 348.7049 8.5961e+004 ± 1.6933e+005 7.8424e+005 6.1213e+006 6.6711e+008 ± 1.4707e+009 7.8695e+009 17.6020 19.4884 ± 0.6590 20.4976
2.5733e-007 0.0044 ± 0.0020 0.0202 6.0267e-009 1.9182e-004 ± 2.3168e-004 0.0010 5.9783e-008 0.0017 ± 0.0054 0.0295 4.1854e-008 1.4209e-004 ± 2.2340e-004 7.9454e-004 4.7334e-008 1.7819e-004 ± 2.9563e-004 0.0013 1.2830e-008 1.1047e-004 ± 2.1046e-004 9.0623e-004 6.8779e-006 0.0035 ± 0.0024 0.0138 5.0295e-010 0.0050 ± 0.0022 0.0250 4.5868e-007 0.0017 ± 0.0012 0.0071 0 0 0 0 0 0 0 0 0 2.6460e-005 0.0022 ± 0.0022 0.0079 1.3751e-004 0.0016 ± 0.0020 0.0057 4.5672e-005 0.0020 ± 0.0021 0.0098 9.2498e-006 0.0039 ± 0.0034 0.0177
20
30
Rastrigin
10
20
30
Rosenbrock
10
20
30
Step
10
20
30
Schwefel’s P2.22
10
20
30
Ackly
10
(Continued)
58
T. Hassanzadeh and H. R. Kanan
TABLE 3
Continued
Functions
Dim
Criteria
FA
FFA
20
Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst Best Ave-StD Worst
18.4265 19.4587 ± 0.4046 20.1893 20.1876 20.4837 ± 0.1032 20.6449 0.0062 0.0518 ± 0.0478 0.2121 1.1453e-005 9.6701e-005 ± 6.3480e-005 2.8123e-004 7.6017e-008 6.6962e-007 ± 6.7683e-007 3.0630e-006
2.8628e-005 0.0012 ± 0.0011 0.0041 9.5211e-007 0.0011 ± 0.0010 0.0034 2.2364e-004 5.4339e-004 ± 8.6301e-005 5.6608e-004 5.1533e-008 7.4727e-008 ± 8.8267e-008 3.9944e-007 3.5124e-012 4.5214e-012 ± 5.5261e-012 3.3780e-011
30
Xin-She Yang
10
20
30
that the proposed algorithm uses more than one firefly to move other fireflies. Therefore, during execution of the algorithm, the capability of the proposed FFA in global searching is improved and could find optimal solution efficiently and more quickly than the standard FA. Experimental Results of Multilevel Thresholding In this part, we present the results of the proposed FFA-Otsu imagesegmentation algorithm. In our experiments, we set 0 = 1 and = 20. Rand is a random number generator uniformly distributed in [0–1]. The parameter , which characterizes the variation of the attractiveness and whose value is important in determining the speed of the convergence and how the FA behaves, is set as 1. Population size is set to 50. The fireflies are initialized as a gray value ranging in intervals of [0–255], and the largest truncated generation is 50. The dimension of input vectors depends on the number of threshold levels that we use for segmentation. In this article, we use different threshold levels from 2 to 5. We evaluate the proposed algorithm on some benchmark images including: “Lena,” “Peppers,” “Bird,” “Cameraman,” and “Gold hill.” These original test images and their histograms are shown in Figure 2. As mentioned before, to evaluate the proposed FFA-Otsu segmentation method, we used uniformity measure. The obtained thresholds, uniformity measure, and the objective value on the above images for 2 to 5 threshold levels are shown in Table 4. The uniformity values of the proposed method are compared with the results of FA-Otsu, Gaussian smoothing (Lim and Lee 1990),
Fuzzy FA: A Modified Firefly Algorithm
59
FIGURE 1 Comparison of the best results obtained from 30 performances of the standard FA and the proposed FFA on different benchmark functions: (a) and (b), Ackly; (c) and (d), Rosenbrock; (e) and (f), Step; (g) and (h), Rastrigin functions in 20- and 30-dimensional space for 30 iterations.
symmetry-duality method (Yin and Chen 1993), improved GA-based algorithm (Yin 1999), the hybrid cooperative-comprehensive learningbased PSO algorithm (HCOCLPSO; Madhubanti and Amitava 2008), and a new social and momentum component adaptive PSO algorithm (SMCAPSO; Akhilesh, Amitava, and Patrick 2011) on the “Lena” and “Peppers” images and are shown in Table 5. As is shown, the obtained
60
T. Hassanzadeh and H. R. Kanan
FIGURE 2 The test images and the corresponding histograms: (a) “Lena,” (b) “Peppers,” (c) “Bird,” (d) “Cameraman,” and (e) “Gold hill.
uniformity measures of the proposed method are better than other methods, and it proves the proposed FFA-Otsu method is very effective in image segmentation; in all cases, the uniformity measures are in the upper 98%. In Table 6, we show the obtained objective value on the “Lena” and “Peppers” images and compare them with HCOCLPSO (Madhubanti and Amitava 2008) and GA-learning Kapur (Yin 1999) algorithms. As Table 6 shows, the results of the proposed method are better than the two other methods in many cases. Only in two cases for three-level thresholding, TABLE 4 Obtained Thresholds and Fitness Values for Test Images for the Proposed FFA-Otsu Algorithm Benchmark Image
c
Threshold
Uniformity
Objective Value
Lena (512×512)
2 3 4 5 2 3 4 5 2 3 4 5 2 3 4 5 2 3 4 5
63, 121 53, 99, 165 42, 74, 97, 143 45, 68, 105, 132, 165 70, 134 57, 124, 165 70, 111, 134, 186 47, 83, 116, 165, 191 97, 149 57, 108, 158 58, 115, 158, 183 59, 77, 130, 164, 200 64, 141 59, 121, 158 35, 95, 136, 174 38, 46, 96, 137, 166 88, 161 87, 140, 172 55, 94, 153, 181 59, 87, 94, 138, 202
0.9823 0.9821 0.9847 0.9932 0.994 0.9898 0.9893 0.9891 0.9906 0.9898 0.9909 0.9905 0.9920 0.9965 0.9935 0.9939 0.9830 0.9840 0.9888 0.9891
13 15 18.01 28 13 15 18.5 25 7 12 15 20 16 23 34 38 6 10 13 17
Peppers (512×512)
Bird (256×256)
Camera (256×256)
Gold hill (256×256)
61
Fuzzy FA: A Modified Firefly Algorithm
TABLE 5 Comparison of Uniformity for FFA-Otsu, FA-Otsu, HCOCLPSO, GA Learning-Kapur, Gaussian Smoothing and Symmetry Duality Algorithms Uniformity
Image
FFAOtsu
FAOtsu
0.9823 0.9821 0.9847 0.9932 0.994 0.9898 0.9893 0.9891
0.9643 0.9670 0.9712 0.9710 0.9600 0.9714 0.9721 0.9732
c
Lena (512×512)
2 3 4 5 Peppers (512×512) 2 3 4 5
GA Gaussian Symmetry Learning- Smoothing Duality SMCAPSO HCOCLPSO Kapur Method Method 0.9694 0.9587 0.9541 0.9843 0.9565 0.9768 0.9739 0.9733
0.9682 0.9760 0.9792 0.9799 0.9647 0.9728 0.9738 0.9779
0.8844 0.9164 0.9198 0.9269 0.8659 0.8970 0.9054 0.9080
0.7782 0.8752 0.9143 0.9062 0.8485 0.8713 0.8386 0.8802
0.8174 0.8476 0.9223 0.9277 0.8494 0.8702 0.8371 0.8771
the objective values of the proposed method are lower than the two other methods. Also, in Table 7, we compare the obtained thresholds of the proposed algorithm for “Lena” and “Peppers” images in 2 to 5 threshold levels with three other methods. Another important goal in our research is to decrease the time complexity of the Otsu methods. As mentioned earlier, by increasing the number of thresholds, the time and computational complexity will be increased with the Otsu method. To overcome this problem, a recursive Otsu algorithm has been proposed in Liao, Chen, and Chung (2011). In this method, the time complexity of the Otsu method is partially decreased. In our proposed method, we could reduce the time complexity of Otsu and recursive Otsu algorithms. The mean runtimes of the conventional and recursive Otsu methods and the proposed TABLE 6 Comparison of Objective Values for FFA-Otsu, HCOCLPSO, GA Learning-Kapur Algorithms Objective Values Image
c
FFA-Otsu
HCOCLPSO
GA Learning-Kapur
Lena (512×512)
2 3 4 5 2 3 4 5
13 15 18.01 28 13 15 18.5 25
12.35 15.31 17.99 20.54 12.64 15.70 18.49 21.28
12.10 14.99 17.60 20.12 12.39 15.36 18.08 20.84
Peppers (512×512)
62
T. Hassanzadeh and H. R. Kanan
TABLE 7 Comparison of the Obtained Optimal Thresholds for FFA-Otsu, HCOCLPSO, GA Learning-Kapur Algorithms Optimal Thresholds Image
c
FFA-Otsu
FA-Otsu
HCOCLPSO
GA LearningKapur
Lena (512×512)
2 3 4 5
Peppers (512×512)
2 3 4 5
63, 121 53, 99, 165 42, 74, 97, 143 45, 68, 105, 132, 165 70, 134 57, 124, 165 70, 111, 134, 186 47, 83, 116, 165, 191
69, 175 52, 118, 172 44, 98, 161, 224 25, 74, 123, 152, 221 79, 162 58, 129, 211 41, 78, 124, 210 22, 82, 116, 173, 223
100, 166 79, 125, 176 74, 114, 149, 186 69, 104, 137, 169, 197 75, 145 62, 113, 166 46, 80, 126, 172 43, 78, 118, 154, 193
105, 176 90, 131, 176 75, 105, 143, 181 74, 103, 133, 166, 195 84, 150 72, 119, 167 57, 90, 132, 174 56, 88, 121, 157, 194
FFA-Otsu algorithm were calculated and are listed in Table 8. As indicated in Table 8, the mean runtimes of the conventional Otsu method and the recursive Otsu algorithm increase significantly when the threshold level c increases; but the runtime of the proposed method is independent of the number of threshold levels. As a subjective evaluation, we show the obtained segmented images in Figure 3. As shown, the obtained thresholds could cluster the pixels properly. In the segmented images, different clusters displayed with different colors. The pixels located into different clusters according to their colors. One of the criteria of a good segmentation algorithm is that the obtained segmented image would be more similar to the original image when the number of threshold levels is increased. As shown in Figure 3, the obtained segmented images become much more similar to the original images with increase in the number of threshold levels. TABLE 8 Comparison of the Mean Runtimes for Three Methods with Classes c = 4, 5, and 6 Mean Runtime (s) Image
c
The Proposed FFA-Otsu Method
Otsu*
Recursive Otsu*
Lena
4 5 6 4 5 6
1.5233 1.5298 1.5306 1.4822 1.4925 1.5024
9.672 660.7 54168 9.687 651.1 48599
0.284 19.59 1024 0.292 19.64 1036
Peppers
The values with * are from (Huang and Wang 2009).
Fuzzy FA: A Modified Firefly Algorithm
63
FIGURE 3 The obtained segmented images based on the proposed FFA-Otsu method with different threshold levels.
CONCLUSION In this study, to improve the global search and the exploration rate of the standard firefly algorithm (FA), we have presented a fuzzy-based modified version of the firefly algorithm (FFA). In this research, we used more than one firefly representing the global optima and some brighter fireflies in each iteration to influence other fireflies’ movements, depending on their degrees of brightness, which is considered as a fuzzy variable to improve the collective motion of fireflies. Also, we investigated the proper value of parameter to improve the random movement of fireflies. Our experimental results on seven standard benchmark functions including Sphere, Rastrigin, Rosenbrock, Step, Schwefel’s P2.22, Ackly, and Xin-She Yang functions in 20- and 30dimensional spaces indicate that our proposed algorithm improves performance of FA especially in high-dimensional spaces. Then, we combined the FFA with the Otsu method and proposed the FFA-Otsu algorithm for image segmentation. The different objective and subjective
64
T. Hassanzadeh and H. R. Kanan
evaluation strategies are utilized to evaluate the obtained results. The proposed segmentation method was compared with different well-known segmentation methods. The experimental results demonstrate significant enhancement in performance compared with several other popular, contemporary image segmentation methods. REFERENCES Akhilesh, C., C. Amitava, and S. Patrick. 2011. A new social and momentum component adaptive pso algorithm for image segmentation. Expert Systems with Applications 38:4998–5004. Baeck, T., D. B. Fogel, and Z. Michalewicz. 1997. Handbook of evolutionary computation. New York, NY, USA/London, UK: Taylor & Francis. Bonabeau, E., M. Dorigo, and G. Theraulaz. 1999. Swarm intelligence: From natural to artificial systems. New York, NY: Oxford University Press. Brink, A. D. 1995. Minimum spatial entropy threshold selection. IEEE Proceedings–Vision Image and Signal Processing 142:128–132. Cheng, H. D., J. Chen, and J. Li. 1998. Threshold selection based on fuzzy c-partition entropy approach. Pattern Recognition 31:857–870. Cheng, H. D., and Y. M. Lui. 1997. Automatic bandwidth selection of fuzzy membership function. Information Sciences 103:1–27. Darigo, M., M. Birattari, and T. Stutzle. 2006. Ant colony optimization. IEEE Computational Intelligence Magazine 1 (4): 28–39. Hu, Q., Z. Hou, and W. Nowinski. 2006. Supervised range-constrained thresholding. IEEE Transactions on Image Processing 15:228–240. Huang, D. Y., and C. H. Wang. 2009. Optimal multi-level thresholding using a two-stage otsu optimization approach. Pattern Recognition Letters 30 (3): 275–284. Kapur, J. N., P. K. Sahoo, and A. K. C. Wong. 1985. A new method for gray-level picture thresholding using the entropy of the histogram. Computer Vision Graphics Image Processing 29 (3): 273–285. Kennedy, J., and R. C. Eberhart. 1995. Particle swarm optimization. In IEEE international conference on neural networks, 4:1942–1948. Perth, Australia. Kennedy, J., R. Eberhart, and Y. Shi. 2001. Swarm intelligence. San Francisco, CA: Academic Press. Li, L. X., Z. J. Shao, and J. X. Qian. 2002. An optimizing method based on autonomous animate: Fish swarm algorithm. In Proceedings of System Engineering Theory and Practice 11:32–38. Liao, P. S., T. S. Chen, and P. C. Chung. 2011. A fast algorithm for multi-level thresholding. Journal of Information and Science Engineering 17 (5): 713–727. Lim, Y. K., and S. U. Lee. 1990. On the color image segmentation algorithm based on the thresholding and the fuzzy c-means techniques. Pattern Recognition 23:935–952. Liu, Y., and K. M. Passino. 2005. Swarm intelligence: A survey. In Proceedings of the 4th international conference of swarm intelligence. Madhubanti, M., and A. Amitava. 2008. A hybrid cooperative-comprehensive learning based algorithm for image segmentation using multilevel thresholding. Expert Systems with Applications 34:1341–1350. Otsu, N. 1979. A threshold selection method from gray-level histogram. IEEE Transactions Systems, Man and Cybernetics 9 (1): 62–66. Pham, D. T., A. Ghanbarzadeh, E. Koc, S. Otri, S. Rahim, and M. Zaidi. 2006. The bees algorithm–A novel tool for complex optimization problems. In Proceedings of innovative production machines and systems 2006 conference, 454–461. Oxford, UK: Elsevier. Pun, T. 1981. Entropy thresholding: A new approach. Computer Vision, Graphics, and Image Processing 16:210–239. Saha, P. K., and J. K. Udupa. 2001. Optimum image thresholding via class uncertainty and region homogeneity. IEEE Transactions on Pattern Analysis and Machine Intelligence 23:689–706.
Fuzzy FA: A Modified Firefly Algorithm
65
Sayadi, M. M., R. Ramezanian, and N. Ghafari-Nasb. 2010. A discrete firefly meta-heuristic with local search for make span minimization in permutation flow shop scheduling problem. International Journal of Industrial Engineering Computations. (1): 1–10. Yang, X. S. 2005. Biology-derived algorithms in engineering optimization. (Chapter 32). In Handbook of bioinspired algorithms and applications, eds. S. Olarius and A. Y. Zomaya. Boca Raton, FL: Chapman & Hall/CRC. Yang, X. S. 2008. Nature-inspired metaheuristic algorithms. Frome, UK: Luniver Press. Yang, X. S. 2009. Firefly algorithm for multimodal optimization in stochastic algorithms, foundations and applications. In Stochastic algorithms: Foundations and applications, SAGA Lecture Notes in Computer Sciences 5792: 169–178, eds. O. Watanabe and T. Zeugmann. Berlin, Heidelberg: Springer. Yang, X. S. 2010a. Firefly algorithm, stochastic test functions and design optimization. International Journal of Bio-Inspired Computation 2 (2): 78–84. Yang, X. S. 2010b. Firefly algorithm, Levy flight and global optimization. In Research and development in intelligent systems XXVI, eds. M. Bramer, R. Ellis, and M. Petridis. 209–218. London, UK: Springer. Yin, P. Y. 1999. A fast scheme for optimal thresholding using genetic algorithms. Signal Processing 72:85–95. Yin, P. Y., and L. H. Chen. 1993. New method for multilevel thresholding using the symmetry and duality of the histogram. Journal of Electronics and Imaging 2:337–344.