1 Introduction

Contrast enhancement is an important process in applications where the quality of the image considered is important for further analysis. The core objective of contrast enhancement is to improve the perception of objects in an image which is highly desired in many application areas such as medical image processing, image/video processing [18]. Recently, it has become even more significant, as the utilization of digital images over the internet has expanded. Gamma correction approach is broadly used as contrast enhancement in the literature in spite of many other existing algorithms due to its brightness preservation. Though, several other contrast enhancement algorithm has also been reported to enhance the specific details of the image such as histogram equalization, global and local histogram equalization [8, 36] adaptive histogram equalization (AHE) and Contrast Limited Adaptive histogram equalization (CLAHE) [29, 38] and other histogram equalization based algorithms [2, 5, 9, 11, 14, 16].

The classical contrast enhancement techniques do not serve the purpose of providing high-quality images for applications such as night vision and satellite imagery. In order to obtain the desired quality in the enhanced images, swarm intelligent technique is combined with classical contrast enhancement techniques. Many researchers used particle swarm optimization to enhance the quality of the image due to its effectiveness and implemented through programming languages [7]. Finding a generic optimal contrast enhancement algorithm, applicable to all types of images is still an open challenge for the researchers.

In Section 2, we survey the past work in contrast enhancement of gray scale images. Section 3 addresses the optimal contrast enhancement algorithm using PSO. Section 4 presents an experimental evaluation of proposed method with state-of-art contrast enhancement algorithms. Finally, conclusions are given in section 5.

2 Related work

Contrast enhancement improves the quality of the image in terms of clarity, information content, brightness, edge enhancement and noise removal. Due to technical limitations, many image capturing devices may not display the actual appearance of objects. This is known as gamma distortion which often disturbs the quality of the image. The classical contrast techniques such as histogram equalization, modified histogram equalization techniques [10, 12, 17, 22, 25, 27, 28, 34, 37] are not providing satisfying results for images that suffer from gamma distortion [4].

Gamma correction is a suitable technique to solve gamma distortion problem by image capturing devices. Gamma correction is a type of Histogram modification technique in which image enhancement is achieved using an adaptive parameter called gamma (γ) [22]. It is a non-linear operation that adjusts lightness or darkness of an image. The basic form of the transformed gamma correction (TGC) of an image is given by

$$ \mathrm{TGC}={I}_{\mathrm{max}}{\left(\raisebox{1ex}{${I}_{in}$}\!\left/ \!\raisebox{-1ex}{${I}_{\mathrm{max}}$}\right.\right)}^{\gamma } $$
(1)

TGC follows a simple power law, characteristics based on the value of γ. In Eq. (1), Iin is an actual intensity value of the input image and Imax is the maximum intensity value of the input image. The intensity value of each pixel is transformed using Eq. (1) by substituting the gamma value. Hence gamma value ranges from 0.0 to infinity. Gamma value equal to 1 implies the faithful reproduction of input image. If gamma value is less than 1.0 it lightens an image and gamma value greater than 1.0 darkens an image [18]. Therefore the precise value of gamma is image dependent based on its intensity profile. The use of fixed gamma value for the different type of images will exhibit the same changes in intensity [3]. Hence it is necessary to choose an optimal gamma value that is image dependent in order to produces better quality image.

Seema et al. [31] proposed a contrast enhancement technique based on gamma correction approach. The authors segment the histogram of the image recursively and applied the adaptive gamma correction approach. The gamma value is chosen based on the cumulative distribution function (CDF) but unfortunately, the CDF curve of the image encounters fluctuations due to environmental factors such as noise [25, 35, 37]. As a consequence, unwanted artifacts may be produced while finding the gamma value based on CDF and probability distribution function (PDF) resulting in over-enhancement and under enhancement. Thus the image brightness gets distorted and dynamic range gets expanded [25]. In paper [20] the authors proposed a method that locally estimates the gamma value in an image using support vector machine [SVM]. However, this approach, it is necessary to use database of training images but it fails when the given input image does not belong to the training database. In order to obtain the optimal gamma value without prior knowledge about the image, some optimization techniques can be used. Therefore, contrast enhancement technique has been formulated as an optimization problem and swarm intelligence based optimization techniques is integrated with gamma correction approach.

Particle swarm optimization has gained more popularity in the area of contrast enhancement due to its effectiveness and convergence speed. Gorai and Ghosh [19] considered the contrast enhancement as an optimization problem and used PSO to solve it. The authors used parameterized transformation function for contrast enhancement by considering the local and global information present in the image. The authors tried to achieve the best result according to the objective function by optimizing only the parameters of transformation function with the help of PSO.

Qinqing et al. [30] also took contrast enhancement as an optimization problem and simulated annealing PSO algorithm is used to solve it. The authors also applied the parameterized transformation function for contrast enhancement based on local and global information of an image. The authors selected the parameters for transformation function using the entropy and edge-based objective function. In their paper, the initial parameters are selected randomly. The velocity and position of each particle are updated using PSO, and then simulated annealing is applied to each individual particle in order to select the individuals for next generation. This hybrid procedure preserves the edge content while increasing the computational complexity.

P. Shanmugavadivu and Balasubramaniyan [33] outlined in their work, that the multi-objective Histogram equalization model is used to enhance the image contrast as well as preserving the brightness. The main idea of this model is to first segment the input image into two parts using Ostu threshold method. The two sub-images are equalized independently using PSO by applying the brightness and contrast based objective function. This technique provides better results compared with other histogram based techniques but failed to preserve the edges. Moreover, histogram equalization based methods are suitable for images with poor intensity distribution and not suitable for images with uniform intensity distribution. The authors in [19, 30, 33] combined the PSO with traditional contrast enhancement techniques, however these methods are not succeed with gamma distortion problem.

In this paper, the gamma distortion problem is addressed using gamma correction approach and the optimal gamma value is chosen using particle swarm optimization based on the following objectives: 1) Information loss should not occur (maximization of entropy). 2) while enhancing the image, the edges should be preserved (in grayscale image edges has importance for image understanding and segmentation).

3 Particle swarm optimization

PSO is a population-based optimization technique with the aim of exploring the population of possible solutions to probe the search space simultaneously. The PSO algorithm is outlined in [24] is followed in this work. In a mathematical context, PSO can be stated as follows. Let

$$ A\subset {R}^n\;\mathrm{And}\;f:A\to Y\subseteq R $$

Where A is the search space and f be the objective function. The whole population is called as a swarm and its individuals are called particles. The swarm is defined as a set S, where

$$ S=\left\{{x}_1,{x}_2,\dots, {x}_N\right\}, $$

of N particles (possible solutions), defined as:

$$ {x}_i={\left({x}_{i1},{x}_{i2},\dots, {x}_{id}\right)}^T\in A\kern0.5em i=1,2,\dots, N $$

Where N stands for the number of particles and f(x) is the objective function, and is available for each and every particle in the search space. Each particle has a distinctive function value:

$$ {f}_i=f\left({x}_i\right)\in Y $$

The particles are assumed to move inside the search space iteratively by adjusting their position using a proper location shift called velocity, as indicated:

$$ {v}_i={\left({v}_{i1},{v}_{i2},\dots, {v}_{id}\right)}^T,\kern0.5em i=1,2,\dots, N $$

Velocity is updated iteratively to make the particles efficiently move in any region of the search space. Let ‘t’ represents the iteration count, and then the current position of the ith particle and its velocity is indicated as xi (t) and vi (t) respectively. The velocity of the particle is updated based on the information gained from previous steps of the algorithm. PSO also has a memory set:

$$ P=\left\{{P}_1,{P}_2,\dots, {P}_N\right\} $$

This contains the best positions:

$$ {P}_i={\left({P}_{i1},{P}_{i2},\dots, {P}_{id}\right)}^T\in A,\kern0.5em i=1,2,\dots, N $$

ever visited by each particle. These positions are defined as

$$ {P}_i(t)={\arg}_t\max {f}_i(t), $$

PSO is modelled based on the social behavior of the birds that allows particles to mutually communicate their experience [24]. Thus the algorithm computes the global maximizer with the best position ever visited by all the particles. Here g denotes the global best position with highest fitness value in P at a given iteration t, i.e..,

$$ {P}_g(t)={\arg}_t\max f\left({P}_i(t)\right) $$

The velocity and positions of each particle is updated during each iteration by applying the following equation

$$ {v}_i\left(t+1\right)=\omega {v}_i(t)+{c}_1{r}_1\left({P}_i(t)-{x}_i(t)\right)+{c}_2{r}_2\left({P}_g(t)-{x}_i(t)\right) $$
(2)
$$ {x}_i\left(t+1\right)={x}_i(t)+{V}_i\left(t+1\right) $$
(3)

Where ω is called as the inertia weight that controls the convergence behavior of PSO. The large inertia weight aids global search (searching new areas), while small inertia weight tends to aid local search. The variables c1 and c2 are positive constants that control the impact of the individual best and global best position. The parameters r1 and r2 are applied to control the diversity of the population, and they are consistently distributed in the range [0, 1].

4 Proposed contrast enhancement algorithm

In this section, we present the proposed contrast enhancement approach based on the optimal gamma value determined by the multi-objective particle swarm optimization algorithm. Figure 1 demonstrates the block diagram of the proposed approach that is aided by a global optimization algorithm which finds an optimal gamma value for contrast enhancement.

Fig. 1
figure 1

Block diagram for PSO based contrast enhancement framework

In this paper contrast enhancement is formulated as an optimization problem as given below: The set of particle values (gamma value) is defined as a set of N particles

$$ \gamma =\left\{{\gamma}_1,{\gamma}_2,\dots, {\gamma}_N\right\} $$

Where,

$$ {\gamma}_i={\left({\gamma}_{i1},{\gamma}_{i2},\dots, {\gamma}_{id}\right)}^T\in A $$

The entropy of the image is calculated for the gamma value and maximized using

$$ {\arg}_t\max (H)=-\sum \limits_{i=0}^{255}p(i)\times {\log}_2\left(p(i)\right) $$
(4)

Where p(i) is the probability of occurrence of ith intensity of the enhanced image.

The particle set γ should also simultaneously maximize the objective function based on Edge content (EC) given by

$$ {\arg}_t\max (EC)=\frac{n\_ edges(E)}{T} $$
(5)

Where, n_edges(E) stands for number of edge pixels detected in the enhanced image which is calculated by a canny edge detector and T be the total number of pixels in the enhanced image. When more than one objective function is associated, the problem becomes multi-objective. A multi-objective optimization technique usually applies a method called Pareto dominance [15], but this may increase the computational complexity. One of the simple ways to handle the multi-objective optimization problem is to construct an overall objective function as a linear combination of the multiple objective functions [32]. The overall objective function is defined as follows:

$$ f(x)={\alpha}_1{f}_1(x)+{\alpha}_2{f}_2(x) $$
(6)

Where α1 and α2 are constants whose values indicate the relative significance of one objective function relative to other. In this paper, the objective function’s entropy and edge content are taken with equal importance, (i.e.) the value α1 = α2 = 0.5.

The proposed multi-objective function is formulated as follows:

$$ f(x)={\alpha}_1\left[-\sum \limits_{i=0}^{255}p(i)\times {\log}_2\left(p(i)\right)\right]+{\alpha}_2\left[\frac{n\_ edges(E)}{T}\right] $$
(7)

Algorithm for the proposed method is given in Fig. 2. In the proposed method initial population and velocity are randomly chosen. After constructing the initial population the value of each particle set is passed to gamma correction approach, and contrast enhancement for given image is performed. At each iteration, the entropy and edge content are calculated for each enhanced image. A comparison is made of all the particles and the best one is stored as global optimum. If the result of the objective function is greater than the previous iteration then current iteration gamma value is considered as global optimum. The same process will be continued until termination criteria, and the final gamma value is taken as optimal gamma value that produces the contrast-enhanced image.

Fig. 2
figure 2

Algorithm for PSO based contrast enhancement framework

A termination criterion is used for ending the procedure of PSO. This condition may be a specified number of iterations or timing constraints etc. In this paper, termination criterion is set as follows. If the gbest value is same for five consecutive iterations, then the algorithm is stopped from a further search of optimal weights.

5 Experimental results and discussion

The proposed algorithm was implemented using MATLAB2013 and tested on different gray level images. The proposed method is tested with other state-of-the-art techniques such as histogram equalization, adaptive histogram equalization, contrast limited adaptive histogram equalization, brightness preserving dynamic fuzzy histogram equalization, and PSO based contrast enhancement technique [30] to validate the performance. The comparison has been made in terms of entropy, contrast, edge enhancement, and other quantitative metrics.

5.1 Parameter settings

The parameters selected for PSO are listed in Table 1. We have chosen 100 particles to form a particle swarm. The reason is that higher number of particles could speed up the convergence process of PSO. In the proposed method initial population and velocity are randomly chosen. Initially, the particle values are set to the random values in the range of 0 to 2. If gamma value is less than 1.0 it lightens an image and a gamma value greater than 1.0 which darkens an image [18]. Hence, the range of gamma value between 0 to 2 can efficiently enhance the image [3, 18]. Initially, we tried the termination criteria as fixed number of iterations for all images. But, the optimal weight estimation for some images converged too earlier. For such kind of images, fixed number of iterations may increase the computational and time complexity. In order to avoid complexity, we fixed the termination criteria as stated in section 5.1 (i.e.,) If the gbest value is same for five consecutive iterations, then the algorithm is stopped from a further search of optimal weights.

Table 1 Parameters of PSO

5.2 Image quality assessment metrics

Contrast enhancement is the process of improving the image quality for better vision. After contrast enhancement, quantitative evaluation of images is an important step for determining how well the images are enhanced. In this paper, we have used Weighted Peak Signal-to-Noise Ratio (WPSNR), Homogeneity, Contrast to Noise Ratio (CNR) and Measure of Enhancement (EME) to access the quality of the enhanced image. The metrics are defined as follows.

5.2.1 Weighted peak signal-to-noise ratio (WPSNR)

WPSNR is a Human Visual System (HVS) based metric that is more accurate than PSNR. WPSNR uses the principle of redundancy of the human eye toward high-frequency components in images [26]. WPSNR in dB is expressed as

$$ \mathrm{WPSNR}=10\kern0.24em {\log}_{10}\kern0.24em \left(\frac{{\left({2}^B-1\right)}^2}{NVF\times \frac{1}{MN}{\sum}_{j=1}^M{\sum}_{i=1}^N{\left[{H}_{\left(i,j\right)}-{E}_{\left(i,j\right)}\right]}^2}\right) $$
(8)

where NVF is the noise visibility function defined as

$$ NVF= NORM\left(\frac{1}{1+{\delta}_{block}^2}\right) $$
(9)

where \( {\delta}_{block}^2 \) is the standard deviation of the block of pixels(8 × 8) and NORM is normalization function used to normalize the NVF value in the range from zero to unity. The larger value of WPSNR denotes the high quality of the enhanced image.

5.2.2 Contrast

Contrast is a second order statistical feature that returns a measure of intensity difference between a pixel and its neighbor over the whole image.

$$ \mathrm{contrast}=\sum \limits_i\sum \limits_j{\left(i-j\right)}^2P\left(i,j\right) $$
(10)

Where i and j are the two different gray levels of the image, P is the number of the co-appearance of the gray levels i and j. A high value of contrast indicates high-quality image.

5.2.3 Homogeneity

Homogeneity is second order statistical measure based on Gray Level Co-occurrence Matrix (GLCM). Homogeneity measures the similarity of gray-scale levels across the image. Thus, a larger value of homogeneity indicates more homogenous region [13, 21] and thus the image quality. This metric mathematically expressed as

$$ \mathrm{Homogeneity}=\sum \limits_i\sum \limits_j\frac{P\left(i,j\right)}{1+\left|i-j\right|} $$
(11)

5.2.4 Contrast to noise ratio (CNR)

Contrast to noise ratio is similar to Signal to Noise Ratio (SNR), but subtracts off a term before taking the ratio [23]. This is important when there is a significant bias in the image, such as from Haze [6]. CNR is computed as follows

$$ \mathrm{CNR}=\frac{\mu_o-{\mu}_B}{\sigma_B} $$
(12)

Where μo is the mean attenuation coefficient of a defined object in the region of interest, μB is the mean attenuation coefficient of the image background surrounding the object and σB is the general background noise expressed as a standard deviation of pixel values outside the targeted region of interest.

5.2.5 Measure of enhancement (EME)

EME is the blind reference metric has been proposed by Agaian et al. [1] gives an absolute score to each image on the basis of image contrast processed with Fechner’s Law relating contrast to perceived brightness.

$$ \mathrm{EME}=\frac{1}{k_1,{k}_2}\sum \limits_{m=1}^{k_1}\sum \limits_{l=1}^{k_2}20\;\ln\;\left(\frac{I_{\mathrm{max}}^{l,m}}{I_{\mathrm{min}}^{l,m}}\right) $$
(13)

where the image is divided into k1, k2 blocks, \( {I}_{\mathrm{max}}^{l,m} \) and \( {I}_{\mathrm{min}}^{l,m} \) are the maximum and minimum values of the pixels in each block of the enhanced image.

5.3 Performance analysis

Entropy and Edge content are the objective function parameters used to judge the performance of enhancement in addition to subjective evaluation. The factor entropy was used to compare the information level of the resulting images. The image with highest entropy value is the one with high contrast. The entropy and edge content measure obtained for each image is presented in Table 2. Moreover, the edge content measure was used to assess the detail content level of the resulted images. The measured values indicate that the proposed contrast enhancement technique outperforms other methods in many cases.

Table 2 Quantitative analysis of entropy and edge content for various contrast enhancement techniques

The global gamma value (optimal value) for contrast enhancement of House, Wall, Street, Swan, Couple, and lady image are listed in Table 3.

Table 3 Optimal gamma value

Simulation results show the performance of the proposed method in producing more natural-looking images by enhancing the contrast. The results of contrast-enhanced images have been shown in Figs. 3 to 8. The result produced by HE for ‘House image ‘is not appealing due to over enhancement. The resultant image of AHE is not satisfactory because of uneven texture pattern of the wall and door. The proposed method produces better result than CLAHE as seen by the contrast between window and smooth texture pattern of the wall. The PSO based contrast enhancement technique introduces blurring effect around the window. The plant is not clearly visible in Fig. 3f. The proposed method effectively enhances the plant, window, and wall without any artifacts.

Fig. 3
figure 3

Enhanced ‘House image’ using various contrast enhancement techniques

The original wall image is shown in Fig. 4a. The art on the left side wall, as well as the art in the right side wall, is not clearly visible in Fig. 4a. After applying histogram equalization technique to the ‘wall image’, art in the left side wall is clearly visible, but right side wall art is over enhanced (Fig. 4b). Moreover, the brightness of the dog object is not preserved. The result of AHE (Fig. 4c) is better than HE. The result of BPDFHE is better than AHE and HE, but it provides a low contrasted image. The result of PSO based contrast enhancement technique is better than HE and BPDFHE. But the resultant image is low contrast (Contrast =0.94, Table 4) compared with HE, CLAHE and proposed work. In Fig. 4f, number of black pixels are created throughout the image which gives the unsatisfactory result. The proposed method enhances the art on the wall as well as preserves the brightness of the dog object in the enhanced image. The quantitative analysis of the enhanced images using various contrast enhancement techniques is listed in Table 4. The high value of WPSNR (36.35), EME (38.07) of proposed method shows the brightness of the enhanced image.

Fig. 4
figure 4

Enhanced Wall image using various contrast enhancement techniques

Table 4 Quantitative analysis of enhanced images using various contrast enhancement techniques

The result of Street image is depicted in Fig. 5. The car and the building in the street image is not visible in the original image. After image enhancement using HE, the cars are clearly visible. But the outcome of HE is very poor (Fig. 5b). The reason behind this poor quality is, the car light gets reflected and so, the image looks blurred at many pixel locations starting from (130,147) to (197,175) and from (44,99) to (111,70). The AHE and CLAHE have introduced checkerboard effects in many places of the building wherever rectangle and square shape objects are found. The result of PSO is better than BPDFHE, but low contrasted than proposed work. The proposed method produced a pleasing result for street image and brings out hidden details of an image.

Fig. 5
figure 5

Enhanced street image using various contrast enhancement techniques

The result of swan image is shown in Fig. 6. The result of histogram equalization is better than AHE and CLAHE. The shadow on the swan is over enhanced in BPDFHE, AHE and CLAHE technique. The proposed method effectively enhances the swan image compared to other methods. The high value of WPSNR (27.19) and contrast (0.98) indicates that the proposed method gives a high contrast-enhanced image.

Fig. 6
figure 6

Enhanced Swan image using various contrast enhancement techniques

The results of couple image are shown in Fig. 7. The faces of the couple and furniture behind them are not effectively synthesized in Fig. 7a. The results of AHE and CLAHE are good compared with BPDFHE. On the other hand, the floor in the image is not enhanced well. Number of black pixels are introduced in the enhanced image. The low value of contrast metric (0.92) for PSO technique indicates the low contrast-enhanced image. The homogeneity value for PSO indicates the unsatisfactory result of PSO. The result of proposed method shows that it effectively enhances the face, surface, and furniture objects in the couple image.

Fig. 7
figure 7

Enhanced Couple image using various contrast enhancement techniques

The results of ‘lady image’ are shown in Fig. 8. In Fig. 8b, the head part of the lady is over enhanced in the resultant image. The result of AHE and CLAHE is better than PSO and BPDFHE. But many black pixels are introduced in the face part of the lady image. By visually examining the images enhanced by the proposed method, it is clear that the presented PSO based contrast enhancement technique produces more natural looking images and brings out hidden details of an image. However, the proposed method is not designed for enhancing color images.

Fig. 8
figure 8

Enhanced Lady image using various contrast enhancement techniques

In overall, experimental results showed that the presented method worked well on the low illumination and dark images and bring out hidden features of an image. Since it provides better results than other state-of-art methods, this may also be extended to color images.

6 Conclusion

The proposed method is based on gamma correction approach with PSO optimization that overcomes the drawbacks of state-of-art methods. To evaluate the performance of the proposed method, it is tested on few images with low illumination and high darkness. The experiments with the proposed method show satisfactory results in enhancing the overall image contrast and enriched the information present in the image. This method is suitable for applications in satellite and night vision images. In future, we plan to extend this work for color images and structure the termination criteria for fast convergence.