An Optimization Based Fast Multi-level Thresholding Technique Jayadev Acharya1, G. Sreechakra1, Ajoy K. Ray1, Jaideva Goswami2 1 Indian Institute Of Technology Kharagpur 2 Schlumberger Technology Corporation

Abstract: Otsu’s method is one of the best image thresholding techniques, but its complexity increases tremendously with the number of thresholds. In this work, Otsu’s criterion function is reduced into a suitable form for easy computation. An algorithm using Particle Swarm Optimization (PSO) is then proposed which works much faster than the original Otsu multi thresholding. This method achieves performance, at par with a similar approach using hybrid PSO, proposed recently, without going for the hybrid approach. It does so by suitable parameter selection for PSO and thereby avoiding some steps like sorting which are needed during the process of hybridization.

Keywords: Particle Swarm Optimization, Otsu’s thresholding, Multi level thresholding.

1. Introduction: Thresholding is an important technique for image segmentation. Segmentation plays an important role in many fields like Optical Character Recognition, Signature Identification, Biomedical Imaging, and Target Identification. Many methods have been proposed for thresholding of images. Threshold selection techniques can be divided into parametric and non-parametric techniques. In parametric approaches (Weszka and Rosenfeld, 1979 [15]; Synder et al., 1990 [11]), the gray-level distribution of each class is assumed to have a Gaussian probability density function. Moment preserving thresholding is a parametric method which segments the image based on the condition that the thresholded image has the same moments as the original image [13]. In nonparametric approaches, the thresholds are obtained in an optimal manner according to some criteria. For instance, Otsu’s method [7] chooses the optimal thresholds by maximizing the between-class variance with an exhaustive search. In Pun’s method [8], as modified by Kapur et al. [3], the picture threshold is found by maximizing the entropy of the histogram of gray levels of the resulting classes. Some other thresholding techniques have been extended from bi-level threshold selection to multilevel threshold selection [7, 11, 13, 14, 16]. The Sahoo et al. study on global thresholding [10] concluded that Otsu’s method is one of the better threshold selection methods for general real world images with regard to uniformity and shape measures. However, Otsu’s method uses an exhaustive search to evaluate the criterion for maximizing the between-class variance. With an increase in the number of classes of an image, there is an exponential rise in the time taken by Otsu’s method for multilevel threshold selection. An improvement over Otsu was

proposed in [5] but it is still exhaustive and computationally more expensive than the evolutionary approaches. Zahara et al [18] proposed a hybrid optimization (NMPSO) technique on within class variance for finding Otsu’s threshold by using PSO (Kennedy and Eberhart [4]) in conjunction with NM (Nelder Mead [6]) method. Such hybrid approaches work well and give better convergence rate when the objective function is very non linear with multiple optima. Otsu’s objective function is relatively smooth and the number of optima is limited, as is observed for a wide range of images. For such well behaving functions it is possible to achieve fast convergence without going for a hybrid approach. In this work, a simple representation of Otsu’s between class variance is developed by defining two functions. Using this representation the objective function is calculated efficiently. Suitable parameter selection for PSO is done and it is shown that the method works at par with NMPSO. The organization of the paper is as follows. In section 2 Otsu’s thresholding is reviewed and an efficient formulation of the objective function is presented. In section 3 PSO is reviewed. Then NMPSO technique is studied. In section 5 the proposed approach is presented. In section 6 the results are depicted and a comparative analysis is provided.

2. Otsu Thresholding An image is a 2D grayscale intensity function, and contains N pixels with gray levels from 1 to L. The number of pixels with gray level i is denoted as fi, giving a probability of gray level i as:

pi =

fi N

In the case of bi-level thresholding of an image, the pixels are divided into two classes, C1 with gray levels [1, …, t] and C2 with gray levels [t+1, …, L]. The gray level probability distribution of the pixels in the two classes is: C1: p1/ω1(t), …, pt /ω1 (t) C2: pt+1/ω2(t), …, pL /ω2 (t), t


ω1 ( t ) = ∑ p i


i =1

ω2 (t) =



i = t +1


The means of the two classes are given by: t

i.p i i =1 ω1 ( t)

μ1 ( t ) = ∑


μ 2 (t) =

respectively. Mean of the entire image is given by:


i.p i 2 ( t)


i = t +1


μ T = ∑ i.p i

μk =


i =1

The following two equations can be easily derived:

[CW(t k ) - CW(t k -1 )] [CF(t k ) - CF(t k -1 )]

The objective function can be formulated as:

ω1 . μ1 + ω 2 . μ2 = μ T ω1 + ω 2 = 1


∑ω .μ

(2) (3)


k =1



M CW(tk ) - CW(tk-1 ) 2 = ∑[CF(tk ) - CF(tk-1 )].{ } CF(tk ) - CF(tk-1 ) k =1

The between class variance for a particular threshold is defined as:

σ B2 (t ) = ω1 ( μ1 − μ T ) 2 + ω 2 ( μ2 − μT ) 2




The objective is to find a threshold (t*) that maximizes σ B . 2

k =1

Expanding the right hand side of (4) and using (2, 3) we get:

σ (t ) = ω1 .μ1 + ω2 .μ2 − 2(ω1 .μ1 + ω 2 .μ2 )μ T + (ω2 + ω1 )μT 2

2 B


⇒ σ B2 (t ) = ω1 .μ1 + ω2 .μ2 − μT 2


μT is a constant for the whole image, hence 2 maximizing σ B is equivalent to maximizing: 2 2 ω1 . μ1 + ω 2 . μ2 (6)

The last term

Arg [ Max {ω1 . μ1 + ω 2 . μ2 }] 2


1≤ t ≤ L This is now extended to multiple levels. Assume that there are M-1 thresholds {t1, t2… tM-1}, which divide the original image into M classes: C1 for [1… t1], C2 for [t1+1… t2]…, Ci for [ti-1+1… ti] …, and CM for [tM-1+1, …, L]. The between class variance can be defined here as: M

σ B2 (t ) = ∑ ω k (μk − μ T ) 2 k =1

As earlier, this equation can be reduced to: M

σ B2 (t ) = ∑ ω k . μk 2 − μ T 2 k =1

Thus the optimal thresholds (t1*,t2*, …, tM-1*) are given by: M

(t1*,t 2 *,…, t M-1*) = Arg [Max {∑ωk .μk }] 2


1 ≤ t1*, t 2 *,…, t M -1* ≤ L Define two functions (histograms): i

CF(i) = ∑ p j

, the cumulative probability distribution


function and i

CW(i) = ∑ j.p j , the weighted cumulative distribution j=1

function for i=1, 2, … L.

Clearly, ω k = CF(t k ) - CF(t k -1 ) where t0=0 and tM=L can be defined for consistency. It can be seen that

. μk

[CW(t k ) - CW(t k -1 )]2 =∑ CF(t k ) - CF(t k -1 ) k =1 M


Thus, from the image, the two histograms CF and CW are found out and the objective function is efficiently evaluated using the equation (7).



t* =




3. Particle Swarm Optimization Particle swarm optimization (PSO) is one of the latest evolutionary optimization techniques developed by Kennedy and Eberhart [4]. The PSO concept is based on a metaphor of social interaction such as bird flocking and fish schooling. Similar to genetic algorithms, PSO is also populations based and evolutionary in nature, with one major difference from genetic algorithms that it does not implement filtering, i.e., all members in the population survive through the entire search process. PSO simulates a commonly observed social behavior, where members of a group tend to follow the lead of the best of the group. The procedure of PSO is illustrated as follows. 1. Initialization: Randomly generate a population of the potential solutions, called ‘‘particles’’, and each particle is assigned a randomized velocity. 2. Velocity update: The particles then ‘‘fly’’ through hyperspace while updating their own velocity, which is accomplished by considering their own past flights and those of their companions. The particles’ velocity and position are dynamically updated by the following equations:

ViNew = w.ViOld + c1.rand(). (pi − xiOld) + c2.rand(). (pg − xiOld) (8)

x iNew = x iOld + ViNew


Here, pi is the personal best position achieved by a point in the search space, pg denotes the global best yet and xi is the position of the particle at the current instant. The values c1 and c2 are two user defined constants which represent the weights given to the personal and global best positions. Eberhart and Shi [1] and Hu and Eberhart [2] suggested c1 = c2 = 2 and w = [0.5 + rand/2.0)]. The new velocity of a particle depends on its old velocity, the personal best position reached by the particle till that time instant and also on the global best discovered yet. The particles approach the global best as well as their own personal bests, and doing so eventually the global best is emerged.

4. NMPSO Approach: NMPSO [18] is a hybrid technique where PSO is used in conjunction with a local optimization technique (Nelder Mead Simplex Algorithm). Similar ideas have been discussed in hybrid methods using GA and direct search techniques, and they emphasize the trade-off between solution quality, reliability and computation time in global optimization (Renders and Flasse [9]; Yen et al., [17]). The population size in NM–PSO approach is set at 3N+1 when solving an N-dimensional problem. In Otsu’s method we need to estimate d-1 parameters, for division into d classes, so N is d-1. The initial population is created in two steps: using a predetermined starting point, N+1 particles are spawned with a positive step size of 1.0 in each coordinate direction, and the other 2N particles are randomly generated. These 3N+1 particles are then sorted by their fitness values, and the top N+1 are fed into the simplex search method to improve the (N+1) Th particle. This sorting can be done at best in O((3N+1).log(3N+1)) time. The NM method [6] is a derivative free technique where reflection, shrinking and elongation of a point through the centroid of two other points is done to get the newer point. The other 2N particles are adjusted by the PSO method by taking into account the positions of the N+1 best particles. This procedure for adjusting the 2N particles involves selection of the global best particle, selection of the neighborhood best particles, and finally velocity updates by equations (8, 9). The parameter values taken here are those suggested by [1, 2]. The global best particle of the population is determined according to the sorted fitness values.

5. Proposed approach: In the proposed approach the population size is a bit higher than NMPSO. It is taken 4d, for solving a d-class classification problem. The initial population is chosen, scattered randomly about the points that divide the frequency histogram into 1/d equal parts (the 100/(d-1)th percentiles). The user defined parameters c1, c2 and w are problem specific and for a particular problem a particular set


Lena Lena Square2 Square2

No of Classes

2 3 2 3

Optimal Threshold

117 92, 151 140 59, 150

of parameters helps in speedy execution. Thus, it can be fruitful to first adjust these parameters to their optimum values for the problem at hand. Also, once tuned, these parameters are found to be pretty robust for that application. It can be noticed that the search space is not very large (0255) in each dimension. In the proposed approach the value assigned to c1 is 0.5 and c2 is 2 thus giving more weightage to the global weights than the personal weights. The choice of weights is supported by the facts that the search space is small and the function is smooth and has limited number of optima. The larger initial population assures that one of the initial population lies near the global optima and ultimately pulls the best value there. The value of w is taken as 0.5 as the velocity constant. The point to mention here is that though hybrid approaches are quite useful for irregular functions, they might not be very advantageous over the general method, if the function to be optimized is not very erratic.

6. Results and Discussion: The three approaches are evaluated in this section: Otsu’s exhaustive search method, NMPSO, and the proposed method (General PSO). The programs were run on MATLAB 7. The processor was P4 and 512 MB RAM. All methods were simulated under identical conditions and their results are compared. The methods are tried on a wide range of images. The CPU time given below is the average time taken for over 200 runs. It is to be pointed out that of the 200 times the programs were run, in about 5 percent of the runs the converged value for one of the thresholds deviated by a maximum of 1 from its expected exact value for the proposed method. This can be ignored, considering the fact that the human eye is not able to perceive the difference of 1 in the intensity value; hence this misclassification does not make a difference. The stopping criterion is the number of iterations. The proposed algorithm converges in lesser number of iterations than NM-PSO as the number of thresholds increases.

CPU Times Taken (in seconds)

No of Iterations





Proposed Algorithm

0.0010 0.1816 .0009 0.1723

0.0011 .0102 .001 0.0096

0.0011 0.0045 .001 .0044

10 20 10 20

10 15 10 15





Figure 1. (a) Gray Level Lena Image (b) Histogram with the thresholds (Black - bi level, Red – Tri Level) (c) Bi Level Thresholding (d) Tri level thresholding





Figure 2. (a) Square2 (b) Histogram and thresholds of square2 (Black - bi level, Red – Tri Level) (c) Two level thresholding (d) Three level thresholding

7. Conclusions: In this work it is shown that particle swarm optimization in itself can work at par with its hybrid if the function space is not very irregular. Parameter tuning is essential in expediting the convergence and for well behaving functions it can outperform the hybrid optimization techniques. This is shown in the case of Otsu’s thresholding.


Hu, X., Eberhart, R.C., Tracking dynamic systems with PSO: Where_s the cheese? In: Proc. Workshop on Particle Swarm Optimization, Indianapolis, IN, USA, 2001.


Kapur, J.N., Sahoo, P.K., Wong, A.K., A new Method for Gray-Level Picture Thresholding Using the Entropy of the Histogram, Computer Vision, Graphics, and Image Processing, 29, 273-285, 1985


Kennedy J., Eberhart R.C., Particle Swarm Optimization, In: Proc. IEEE International Conference on Neural Networks, Piscataway, NJ, USA, 1942–1948, 1995.


Liao P. S., Chen T. S., Chung P. C., A Fast Algorithm for Multilevel Thresholding, Journal of Information Science and Engineering, 17, 713-727 (2001)

References: 1.

Eberhart, R.C., Shi, Y., Tracking and optimizing dynamic systems with particle swarms. In: Proc. Congress on Evolutionary Computation. Seoul, Korea, pp. 94–97, 2001.


Nelder, J.A., Mead, R., A simplex method for function minimization, Comput. J. 7, 308–313, 1965.


Otsu N., A threshold selection using gray level histograms, IEEE Trans. Systems Man Cybernet, 9,6269, 1979.


Pun T., A new method gray-level picture thresholding using the entropy of the histogram, Signal Processing. 2, 223-237, 1980.


Renders J.M., Flasse S.P., Hybrid methods using genetic algorithms for global optimization. IEEE Trans. Systems Man Cybernet, Part B: Cybernet, 26, 243–258, 1996.

10. Sahoo, P.K., Soltani, S., Wong, A.K.C., SURVEY: A survey of thresholding techniques, Comput. Vision Graphics Image Process, 41, 233-260, 1988. 11. Synder W., Bilbro G., Logenthiran A., Rajala S., Optimal thresholding A new approach, Pattern Recognition Letters, 11, 803–810, 1990. 12. Tsai D. M., and Chen Y. H., A fast histogramclustering approach for multilevel thresholding, Pattern Recognition Letters, Vol. 13, No. 4, 1992, pp. 245-252. 13. Tsai W. H., Moment-preserving thresholding: a new approach, Computer Vision,Graphics and Image Processing, Vol-29, pp 377-393, 1985. 14. Wang S., Haralick R., Automatic multithreshold selection, Computer Vision, Graphics, and Image Processing, Vol. 25, 1984, pp. 46-67. 15. Weszka J., Rosenfeld A., Histogram modifications for threshold selection, IEEE Transaction on Systems Man Cybernet, 9, 38–52, 197 16. Yen J. C., Chang F. J., and Chang S., A new criterion for automatic multilevel thresholding, IEEE Transactions on Image Processing, Vol-4, No. 3, 1995, pp. 370-378. 17. Yen J., Liao J.C., Lee B., Randolph D., A hybrid approach to modeling metabolic systems using a genetic algorithm and simplex method, IEEE Trans. Systems Man Cybernet.—Part B: Cybernet. 28, 173– 191, 1998. 18. Zahara E., Fan S. K. S., Tsai D. M., Optimal multithresholding using a hybrid optimization approach, Pattern Recognition Letters - 26, 1082–1095, 2005.

Jayadev Acharya is a senior undergraduate pursuing his Bachelor of Technology in Electronics & Electrical Communication Engg (E&ECE) at IIT Kharagpur. His interests are Data Analysis, Statistics, Wavelets and Image Processing.

G. Sreechakra is a pre final year student, pursuing his Dual degree (B.Tech in E&ECE and M.Tech in Visual Information Processing and Embedded Systems) at IIT Kharagpur, in the same department. His research interests are Signal Processing and Applied Mathematics.

Dr. Ajoy K. Ray is a Professor in Electronics & Elec. Communication Engg at IIT Kharagpur. He is also the Head of the School for Medical Science and Technology at IIT Kharagpur. His research interests are Pattern Recognition, Machine Intelligence, Image Analysis and Computer Architecture. Dr. Jaideva Goswami is currently a Principal Engineer at Schlumberger. He was a Professor in the Electronics & Electrical Communication Engg Department at IIT Kharagpur. His interests are broadly in Sensor Design and Data Analysis.

Supposed advantages of the proposed algorithm ... - Semantic Scholar

1Indian Institute Of Technology Kharagpur. 2Schlumberger Technology Corporation. Abstract: ... the number of classes of an image, there is an exponential.

239KB Sizes 1 Downloads 106 Views

Recommend Documents

Modified Aho Corasick Algorithm - Semantic Scholar
apply the text string as input to the pattern matching machine. ... Replacing this algorithm with the finite state approach resulted in a program whose running.

Fixed-Point DSP Algorithm Implementation, SF 2002 - Semantic Scholar
Developing an understanding of which applications are appropriate for floating point ... The code development process is also less architecture aware. Thus,.

Fixed-Point DSP Algorithm Implementation, SF 2002 - Semantic Scholar
Embedded Systems Conference ... The source of these signals can be audio, image-based or ... elements. Figure 1 shows a typical DSP system implementation.

Fixed-Point DSP Algorithm Implementation, SF 2002 - Semantic Scholar
Digital Signal Processors are a natural choice for cost-sensitive, computationally intensive .... analog domain and digital domain in a fixed length binary word.

A Fast Greedy Algorithm for Outlier Mining - Semantic Scholar
Thus, mining for outliers is an important data mining research with numerous applications, including credit card fraud detection, discovery of criminal activities in.

An Entropy-based Weighted Clustering Algorithm ... - Semantic Scholar
Email: forrest.bao @ ... network, a good dominant set that each clusterhead handles .... an award to good candidates, preventing loss of promising.