International Conference on Information and Communication Technology and Its Applications (ICTA 2016) Federal University of Technology, Minna, Nigeria November 28 – 30, 2016 Automatic Gray Image Contrast Enhancement using Particle Swarm and Cuckoo Search Optimization Algorithms 1A. J. Onumanyi, 2F. Idris, 2M. B. Abdullahi, 1H. Bello-Salau, 1S. O. Aliyu, & 1M. Okwori 1Dept. of Telecommunication Engineering, Federal University of Technology, Minna 2Dept. of Computer Science, Federal University of Technology, Minna adeiza1@futminna.edu.ng, fatiidris2012@gmail.com, el.bashir02@futminna.edu.ng, bellosalau@gmail.com, salihu.aliyu@futminna.edu.ng, michael_okwori@yahoo.com Abstract—In this paper, we report on the investigation of two image being processed, most automated techniques lack the different metaheuristic based algorithms for Gray Image (GI) capacity for generalization. Despite these limitations, full enhancement. First, we investigated the Particle Swarm Opti- automation is evidently required for most new applications mization (PSO) algorithm under certain parameter settings for the GI enhancement task, and followed with the Cuckoo Search in areas such as pattern recognition, forensics and robotics, (CS) algorithm for the same task. Then, we proposed an algo- and thus the need for better techniques. rithmic procedure for computing a new set of objective measures In this paper, we report on the investigation of two for quantifying the performance of any image enhancement metaheuristic algorithms for autonomous GI enhancement. algorithm. Comparative analyses were conducted alongside To achieve this, we adopted the transformation and evaluation classical approaches such as the Linear Contrast Stretching (LCS) and the Histogram Equalization (HS) techniques. Our functions in [3] and applied them for GI enhancement. findings revealed that the CS and the PSO algorithms provide First, we investigated the Particle Swarm Optimization (PSO) better performance than the popularly used LCS and HE technique based on certain parameter settings. Secondly, we techniques. However, between the PSO and the CS algorithm, explored the Cuckoo Search (CS) algorithm for the same the CS performed better on more images than the PSO. These task. These algorithms were chosen owing to their respective results obtained using the proposed metrics were seen to be clearly consistent with the enhanced images and thus, we high performance output, as noted in the literature [4]. Each concluded that autonomous GI enhancement methods based on algorithm was modified and details of the modifications are metaheuristic optimization algorithms produce efficient results, presented in appropriate sections. The results of the different and can effectively replace our dependence on subjective human algorithms were analyzed using a set of newly proposed judgment. metrics and findings are presented herein to justify the effectiveness of the metaheuristic algorithms. An algorithm Keywords — Cuckoo Search, Contrast Enhancement, Gray for computing these metrics is also presented and readers are Image, Metaheuristic, Particle Swarm Optimization, provided with output images to enable them cross evaluate between the proposed metrics and the reader’s perception of I. I NTRODUCTION the enhanced images. Nowadays, digital images have become a typical way of The rest of the paper is organized as follows: Section II acquiring, storing and communicating information among provides a brief review of the relevant literature. In Section people, corporations, businesses and security outfits [1]. III, we present details of the methodology used, while results Thus, it has become pertinent to ensure the integrity of digital and analysis are provided in Section IV. Conclusion is drawn images, particularly those used for sensitive purposes in pat- in Section V. tern recognition, forensics, and a host of other applications. In this regard, an important area of focus is gray image II. R EVIEW OF R ELEVANT L ITERATURE enhancement [2]. Several works have tried to improve the There are several reported works on Gray Image (GI) contrast of Gray Images (GI), however, these techniques enhancement. These methods can be broadly divided into have been either fully manual, that is, humans are required point operations, spatial operations, transform operations, and to identify areas for improvement, or partially automated, pseudocolouring methods [3]. Techniques under point opera- where humans need to assess the enhancement performance tion (also termed indirect method) include contrast stretching, to make conclusions. For most automated techniques, it has window slicing and histogram modeling [3]. These are the been observed that they often depend only on the global infor- simplest and most popular methods for GI enhancement, mation of the image, without consideration for local details thus, they are widely deployed in the literature. However, [3]. Furthermore, because of their dependence on the specific they have more global effect than local effect; thus, they 46 International Conference on Information and Communication Technology and Its Applications (ICTA 2016) suffer from over stretching of the image contrast. Indirect the image, I, can be resized to a smaller dimension to methods typically adjust the image histogram to improve improve processing speed, however, in this work, we used the entropy. On the other hand, spatial operations (or di- the original dimension given as (R × C). The image, I, is rect methods) establish criterions of contrast measurement converted to gray scale, G, with same dimension, (R × C). and enhance the image by improving the measure [5]. In By using a local window size, LW = 3, we computed the [5], Fuzzy logic was used as an adaptive direct enhance- local mean, using the LW × LW window size, the global ment method based on fuzzy entropy principle and fuzzy mean of the entire image, G, and the local standard deviation, set theory. Authors claimed that the proposed technique σ. These parameters served as the basic requirements for performed better than the Adaptive Contrast Enhancement running the GI process. technique; however, evaluation was done subjectively. In 2004, Munteanu and Rosa [3] proposed a transformation B. The Image Transformation and Evaluation Process function for contrast enhancement and used Evolutionary To begin, it is worth noting that an image transformation Algorithm (EA) as a global search strategy for the best function typically changes the intensity value of a gray image enhancement. Authors became one of the first to use heuristic pixel, Gi,j for i = 1, 2, ..., R and j = 1, 2, ..., C, to a different algorithm for GI enhancement, and they used both subjec- value, Fi,j for i = 1, 2, ..., R and j = 1, 2, ..., C. Thus, the tive and objective methods for evaluation, and showed the transformation function we used in this work is given as [3] superiority of their method over Linear Stretching (LS) and Histogram Equalization (HE). In 2005, Russo [6] proposed Fi,j = T (Gi,j ) ∀i ∈ R; j ∈ C (1)   an objective evaluation technique based on the histograms of µG  a = κ × Gi,j − c × µi,j + µi,j the edge gradients. Though shown to outperform both linear σ i,j+b and nonlinear unsharp masking technique, Rosso’s technique where a, b, c, and κ are the parameters of the enhancement produces overshoots along the object contours. Kwok et kernel to be optimized, having the following typical values: al., [7] in 2006 proposed an intensity-preserving technique 0.5 < κ < 1.5; 0 ≤ a ≤ 2; µG < b < 0.5, and for contrast enhancement using Particle Swarm Optimization 0 ≤ c ≤ 1 [3].The transformed or enhanced image is obtained (PSO). The PSO technique was used to obtain proper gamma- by computing Fi,j for all i, j using (1). Subsequently, the factor values for the enhancement process. The use of mean- number of edges, Ne in Fi,j is computed using a Sobel intensity as the objective measure of evaluation is insufficient detector. The Sobel detector produces an edge image, Ei,j to make conclusions, as such, broad measures are required. In containing ones at pixels describing the image’s edge pixels [8], authors used PSO to maximize the information content of in Fi,j , and zeroes at other non-edge pixels. Because Ei,j an enhanced image using Munteanu’s functions in [3]. Gorai contains only binary representation of pixels corresponding et al., [8] showed that PSO performed better than GA, LS to edges in Fi,j , the total number of edges in Ei,j can be and HE. Particularly, Ghosh et al., in [4] explored the use computed as: of Cuckoo Search (CS) algorithm for image enhancement. It R X X C was concluded that CS provides better performance compared Ne = Ei,j (2) to PSO, Genetic Algorithm (GA), Linear Contrast Stretching i=1 j=1 (LCS) and Histogram Equalization. Similarly, other works in The intensity, ξ i,j of each pixel is obtained as [9][10][11][12][13] have made efforts to enhance GIs, and the trending conclusion is that metaheuristic algorithms tend to provide better image enhancement based on the use of ξ i,j = Ei,j • Fi,j ; ∀i ∈ R; j ∈ C (3) transformation functions. However, these methods often lack where (•) denotes element wise multiplication. Thus, the standard objective measures for measuring their effectiveness. total intensity of Fi,j is given as Thus, in addition to investigating both PSO and CS in our work, we proposed new objective measures for quantifying R X X C an algorithm’s performance. Φ= ξ i,j (4) i=1 j=1 III. M ETHODOLOGY To evaluate the goodness of the enhanced image, we used In this section, we provide details on the two metaheuristic the fitness function given in [3] as follows based algorithms used here for GI enhancement, namely Particle Swarm Optimization (PSO) and Cuckoo Search (CS)   Ne algorithms. In addition, we provide an algorithm for comput- Z = log(log(Φ)) × × exp(H(Fi,j )) (5) ing a new set of metrics for evaluating any GI enhancement R×C algorithm. Details of these algorithms are provided in their where H(Fi,j ) is the entropy of the enhanced image, respective subsections. Fi,j . Thus, having established the requisite functions for transformation in (1) and for the evaluation in (5), the two A. Input Parameters metaheuristic algorithms, PSO and CS were then used to Let the image to be enhanced be denoted as I, with obtain the optimum values of a, b, c and κ, in accordance dimensions (R × C). Now, based on the user’s requirement, with their constraints, using (5) as the fitness function. 47 International Conference on Information and Communication Technology and Its Applications (ICTA 2016) C. Use of Particle Swarm Optimization (PSO) Algorithm Thus, for a number of iteration, Niter , the rest of the We present here the use of Particle Swarm Optimization process ensues as follows: (PSO) algorithm [14] as modified for the enhancement pro- 2) Set the lower and upper bounds for the parameter cess. First, we state the necessary functions used in PSO as constraints based on dimension, d, 3) Obtain the random initial solutions (or nests), 4) For each iteration, until Niter, do n vt+1 = wn vtn + cn1 r1 (gbest − xnt ) + cn2 r2 (pbest(n) − xnt ) 5) Get a cuckoo randomly by Levy Flights xnt+1 = xnt + vt+1 n (6) 6) Evaluate each solution (or nest) using (5), after trans- formation using (1), where xnt is the position of the nth particle, vt+1n denotes 7) Obtain the global best value among all nest as Maxfit th n the next velocity of an n particle, w is the inertial 8) If Maxfit(t+1) > Maxfit(t) weighting, r1 and r2 are randomly generated numbers within 9) Update the new global best the range 0 and 1, and cn1 and cn2 are the social and cognitive 10) End if components of the kernel, while gbest and pbest are the 11) Empty a fraction, pa, of the worst nests, global and personal best values of the entire particle popula- 12) Update the new nests using (7) tion, and individual particle, respectively. Next, a population 13) Keep the best solutions size, P , is set for the possible number of solutions (or 14) Return to 1, until Niter is completed. particles) to be used by the algorithm. The dimensions of each particle d, is given as the number of parameters to be Summarily, the optimum values of a, b, c, and κ, computed optimized (d = 4, in this case). Next, the initial random values by the CS algorithm will typically produce the best enhanced were generated for a, b, c, and κ, and these values were used image at the end of the iteration. in (1) to transform the image Gi,j into Fi,j , while evaluating the fitness of Fi,j using (5) based on the values of a, b, c, E. Proposed Objective Evaluation Measures and κ. At an initial time t, the fitness of each particle, n is We propose here an algorithmic procedure for measur- stored as pbest (for n = 1, 2, . . . , P ), while the global best ing the performance of a GI enhancement algorithm. The value in the population of all particles is stored as gbest. The procedure is as follows: Let the original and enhanced subsequent steps taken by the algorithm are as follows: gray image be Gi,j and Fi,j , respectively, for i ∈ R and 1) For each particle, n = 1 to P, do j ∈ C. Then, the algorithm uses a (3 × 3) window size 2) Compute the fitness value of each particle, n using (5), to compute the local variance, σ G and σ F , of both Gi,j after transformation using (1) and Fi,j , respectively. Next, it uses Otsu’s algorithm to 3) Compare the pbest(t) and pbest(t+1), and do compute an optimum threshold value, TG from σ G . Finally, a. If pbest(t+1) > pbest(t) to compute the measurement metrics, let the count of the b. Then, pbest(t+1) is made the current best value Detailed and Background Variance of both the original and of the particle. enhanced image be denoted as DO and BO , and DE and 4) Return to 1, and do for all P BE , respectively. The algorithm computes these metrics as 5) Obtain the gbest at t+1 follows: 6) If gbest(t+1) > gbest(t) 1) For i = 1 to R, do 7) Then, gbest(t+1) is made the current global at t+1. 2) For j = 1 to C, do 8) Thus, compute the next value of the velocity and the 3) If σ G (i, j) ≥ TG particles using (6) 4) Increment DO set by 1 9) Return to 1, until P. 5) Else D. The use of Cuckoo Search (CS) Algorithm 6) Increment BO set by 1 7) End The Cuckoo Search (CS) Algorithm using Levy flight 8) If σ F (i, j) ≥ TG [15] is applied here for image enhancement and the kernel 9) Increment DE set by 1 function used for finding new solutions is given as: 10) Else 11) Increment BE set by 1 xnt=1 = xnt + α ⊕ Levy(λ) (7) 12) End where α > 0 is the step size related to the scale of the 13) End problem of interest, in most cases, α = 1 is normally used, 14) End and 1 < λ < 3 is the Levy distribution parameter, while xnt At the end of Line 14, the algorithm computes the overall and xnt=1 are the current and next solutions with dimension, Detailed and Background Variance of both the original and d. In our work, the CS algorithm was used as follows: enhanced image by adding all the counts in DO and BO , 1) Let the number of nests (or different solutions, similar and DE and BE , respectively. In addition, by using a Sobel to particles in PSO) be n, and the dimension of each detector, the number of edges denoted as NO and NE particle be d (where d = 4). Let the probability of respectively for the original and enhanced image are also discovering an alien egg (or solution) in a nest be pa. considered for evaluating the algorithm’s performance. 48 International Conference on Information and Communication Technology and Its Applications (ICTA 2016) Table4:PerformanceEvaluationfor”Pout”Image IV. R ESULTS AND D ISCUSSION PSO CS LCS HE For evaluation purpose, four different images (see Figs. 1 – BO 68852 68852 68852 68852 4) were used for running the PSO and CS algorithm alongside BE 63628 50514 66696 66461 classical techniques such as the Linear Contrast Stretching DO 988 988 988 988 (LCS) and Histogram Equalization (HE) techniques. The DE 6212 19326 3144 3379 images used for evaluation have various properties relevant NO 1519 1519 1519 1519 for evaluating these algorithms, such as a variety of both NE 7437 15879 4271 5585 small and large number of pixels (see Table 1a), different Table5:PerformanceEvaluationfor”Fingerprint”Image shades, darkness, and representing different applications, e.g PSO CS LCS HE Fingerprint image for finger print analysis. The parameters BO 291820 291820 291820 291820 used for the metaheuristic algorithms are provided in Table BE 278541 279972 283368 284964 1b. Before proceeding, it should be noted that the term DO 15380 15380 15380 15380 Background (BV) and Detailed Variance (DV) are only DE 28659 27228 23832 22236 similar terminology-wise to the metrics used in [3], but NO 8775 8775 8775 8775 different in their technical interpretation. Here, BV describes NE 12409 12369 942 8923 the number of pixels that belong to the background image (or noisy component) of the image, while DV describes Furthermore, it should be noted that the PSO and CS the number of pixels that belong to the foreground image algorithms are statistical in nature, thus, they often provide (or true signal component). Both metrics form an effective different results on different runs. Consequently, the values measure for evaluating any GI enhancement algorithm. We provided here for their evaluations were averaged over 5 provide the enhanced images (see Figs. 1 – 4) outputted different runs. Over the different images used in this work, by each algorithm so that readers can make their subjective it can be seen that the two metaheuristic algorithms clearly evaluation and then proceed to corroborate their judgment outperform the classical LCS and HE techniques (see Tables using the corresponding output metrics in Tables 2 – 5. Thus, 2 – 5). However, between the PSO and CS algorithm, the by visually analyzing each algorithm’s output (see Figs. 1 – CS technique provided 12.78% performance gain over the 4) and comparing them with their corresponding objective PSO in the DV for “Coins” image, 16.14% gain over the measures (see Tables 2 – 5), it can be clearly seen that the PSO in the DV for “Cameraman” image, while the PSO objective measures closely reflect the true outcome of the provided a 4.99% gain over the CS in the “fingerprint” image. enhancement process. Consequently, it can be seen that a Interestingly, the CS achieved 67.86% gain over the PSO in well enhanced image should have lower BV and higher DV the “Pout” image. Upon closer examination of the “Pout” along with more number of edges than its original version. image, it can be seen that it has the smallest Signal to Noise Table 1a: Images used and their respective dimensions Ratio (SNR) based on the DV and BV of the original image, Figure Image Name Size (Pixels) thus, it contains more noise. Consequently, the CS algorithm Fig.1 Coins 246 × 300 performed better on the image with high noisy content than Fig.2 Cameraman 256 × 256 other techniques. Though the CS provides better performance Fig.3 Pout 291 × 240 than the PSO, it should be noted that this performance was averaged over several runs. Thus, users could obtain varia- Fig.4 Fingerprint 480 × 640 Table 1b: Parameter Settings for the Metaheuristic Algorithms tions for a single run wherein the PSO algorithm provides Method Generations Pop. Size Parameters a better result than the CS (hence, justifying the need for PSO 50 25 C1 , C2 = 0.6; w = 1 averaging). However, against the classical methods (that is, CS 50 25 Pa = 0.25 LCS and HE), both metaheuristic algorithms consistently Table2:PerformanceEvaluationfor”Coins”Image provide better performance whether on single or over several PSO CS LCS HE runs. BO 70453 70453 70453 70453 V. C ONCLUSION BE 52610 49506 69548 69671 DO 3347 3347 3347 3347 This paper has presented an investigation of two meta- DE 21190 24294 4252 4129 heuristic algorithms, namely Particle Swarm Optimization NO 2103 2103 2103 2103 (PSO) and Cuckoo Search (CS) algorithm for the Gray Image NE 9808 10529 2309 2095 (GI) enhancement task. As a contribution, the paper has Table3:PerformanceEvaluationfor”Cameraman”Image provided consistent and objective measures that can be used PSO CS LCS HE to evaluate any GI enhancement algorithm. These measures BO 61198 61198 61198 61198 are clearly consistent over the evaluation of four different BE 52713 50246 60174 60548 images. It has been shown that the metaheuristic algorithms DO 4338 4338 4338 4338 outperform two popular classical methods namely Linear DE 12823 15290 5362 4988 Contrast Stretching (LCS) and Histogram Equalization (HE). NO 2503 2503 2503 2503 However, between the CS and PSO algorithms, the CS NE 6281 7005 2808 2749 algorithm performed better on more images than the PSO. 49 International Conference on Information and Communication Technology and Its Applications (ICTA 2016) Fig. 1a: Original Fig. 1b: PSO Fig. 1c: CS Fig. 1d: LCS Fig. 1e: HE Fig. 2a: Original Fig. 2b: PSO Fig. 2c: CS Fig. 2d: LCS Fig. 2e: HE Fig. 3a: Original Fig. 3b: PSO Fig. 3c: CS Fig. 3d: LCS Fig. 3e: HE Fig. 4a: Original Fig. 4b: PSO Fig. 4c: CS Fig. 4d: LCS Fig. 4e: HE While noting that these metaheuristic algorithms are highly [2] R. Maini and H. Aggarwal, “A comprehensive review of image statistical in nature, and often converge to solutions close enhancement techniques,” arXiv preprint arXiv:1003.4053, 2010. [3] C. Munteanu and A. Rosa, “Gray-scale image enhancement as an to the optimal, it might be difficult to conclude which is automatic process driven by evolution,” IEEE Transactions on Systems, better on single runs of the algorithm. However, on the Man, and Cybernetics, Part B (Cybernetics), vol. 34, no. 2, pp. 1292– average, the CS provides better performance. Summarily, this 1298, 2004. [4] S. Ghosh, S. Roy, U. Kumar, and A. Mallick, Gray Level Image work adds to the body of evidence supporting the claim Enhancement Using Cuckoo Search Algorithm. Springer, 2014, pp. that metaheuristic algorithms possess the potential to replace 275–286. subjective and manual methods based on human judgement [5] H. Cheng, R. Min, and M. Zhang, “Automatic wavelet base selec- tion and its application to contrast enhancement,” Signal Processing, in GI enhancement. Future works will provide a thorough, vol. 90, no. 4, pp. 1279–1289, 2010. indepth and objective evaluation of different metatheuristic [6] F. Russo, “Automatic enhancement of noisy images using objective algorithms for the GI enhancement problem. evaluation of image quality,” IEEE transactions on instrumentation and measurement, vol. 54, no. 4, pp. 1600–1606, 2005. [7] N. M. Kwok, Q. P. Ha, D. Liu, and G. Fang, “Intensity-preserving R EFERENCES contrast enhancement for gray-level images using multi-objective par- ticle swarm optimization,” in 2006 IEEE International Conference on [1] C. A. Schneider, W. S. Rasband, and K. W. Eliceiri, “Nih image to Automation Science and Engineering. IEEE, 2006, pp. 21–26. imagej: 25 years of image analysis,” Nat methods, vol. 9, no. 7, pp. [8] A. Gorai and A. Ghosh, “Gray-level image enhancement by particle 671–675, 2012. swarm optimization,” in Nature & Biologically Inspired Computing, 50 International Conference on Information and Communication Technology and Its Applications (ICTA 2016) 2009. NaBIC 2009. World Congress on. IEEE, 2009, pp. 72–77. [9] N. M. Kwok, Q. P. Ha, D. Liu, and G. Fang, “Contrast enhancement and intensity preservation for gray-level images using multiobjective particle swarm optimization,” IEEE Transactions on Automation Sci- ence and Engineering, vol. 6, no. 1, pp. 145–155, 2009. [10] H.-D. Cheng and H. Xu, “A novel fuzzy logic approach to contrast enhancement,” Pattern Recognition, vol. 33, no. 5, pp. 809–819, 2000. [11] S. Hashemi, S. Kiani, N. Noroozi, and M. E. Moghaddam, “An image contrast enhancement method based on genetic algorithm,” Pattern Recognition Letters, vol. 31, no. 13, pp. 1816–1824, 2010. [12] T. Celik and T. Tjahjadi, “Automatic image equalization and contrast enhancement using gaussian mixture modeling,” IEEE Transactions on Image Processing, vol. 21, no. 1, pp. 145–156, 2012. [13] G. Maragatham and S. M. M. Roomi, “A review of image contrast enhancement methods and techniques,” Research Journal of Applied Sciences, Engineering and Technology, vol. 9, no. 5, pp. 309–326, 2015. [14] J. Kennedy, Particle swarm optimization. Springer, 2011, pp. 760– 766. [15] X.-S. Yang and S. Deb, “Cuckoo search via lvy flights,” in Nature & Biologically Inspired Computing, 2009. NaBIC 2009. World Congress on. IEEE, 2009, pp. 210–214. 51