1 Introduction

Image enhancement is one of the most common operations in the domain of digital image processing. De-noising [9, 41], brightness enhancement [2], contrast enhancement [51], sharpness enhancement [55], tonal adjustment ([28]), resolution enhancement [1, 8, 18], all come under the umbrella of image enhancement. Enhancement algorithms vary according to the type of enhancement required. For example, noise removal algorithms only remove noise and do not improve brightness or contrast, whereas contrast enhancement algorithms improve overall contrast of the image, without removing noise or enhancing sharpness. Image enhancement plays crucial role in medical imaging, satellite imaging, remote sensing, surveillance imaging, video processing etc. There exist many well-known image enhancement algorithms. Some algorithms cater to specific problems in specific type of images, while others are general purpose algorithms, suitable for a wide variety of images. For example, [33] proposed a wavelet based algorithm for de-spiking motion artifacts, especially due to head movement, in resting state fMRI signal. This is a noise removal algorithm, designed specifically for this purpose. It is not very likely that this algorithm will give equally good results in removing noise of other images. On the other hand, [11] proposed a histogram specification algorithm which is expected to enhance a wide variety of images. In the present article, we propose a general purpose algorithm which aims at enhancing the contrast and adjusting the brightness of an image.

Contrast enhancement algorithms can be broadly divided into two categories - local enhancement and global enhancement [10]. Local algorithms employ feature based approaches. These features are obtained either by local statistics, like local mean or standard deviation, or by edge operators. The main idea of local enhancement algorithms is to define a local function for any pixel, taking into consideration only the neighbors of that pixel. Several enhancement algorithms have been developed based on this concept. Here we discuss only a few. In [7], a local contrast transform algorithm was proposed to enhance local structures in X-ray images. Local contrast is defined as a ratio of local intensity variation to local mean. Wavelet multi-resolution decomposition was used for enhancement. The detail coefficient and average coefficient were interpreted, modified and wavelet synthesis was done with the modified coefficients. In [43], a new probabilistic approach was presented to enhance images. Four algorithms were proposed. They were based on the virtual particle model performing random walk on the image lattice. The probability of transition of the walking particle from one lattice point to its neighborhood was assumed to be determined by Gibbs distribution. In [4], a sigmoidal gamut mapping of images was described. The remapping functions were selected based on an empirical contrast enhancement model developed from the results of a psychophysical adjustment experiment. The experiment showed that a sigmoidal contrast enhancement function was efficient to maintain the perceived lightness contrast of the images by selectively rescaling images from source device with full dynamic range into destination device with limited dynamic range. In [36] a translation invariant and isotropic image contrast enhancement algorithm which is based on product of linear filters was proposed. In [39], the idea of gray level partitioning, tunable cubic polynomial and a few other important concepts related to contrast enhancement were discussed. The idea of gray level partitioning is based on human perception of a set of gray chips. Contrast enhancement using a class of morphological non-increasing filters was investigated in [49]. In [27], a logarithmic mapping function was used which was adapted to the luminance characteristics of the neighborhood of each pixel. This method allowed for simultaneous decrease in luminance in bright regions and increase in luminance in dark regions of the image. Since image quality varies from region to region within the image, [30] proposed an adaptive un-sharp masking method to locally enhance images. Input image was divided into overlapping blocks and gain factor for each block was estimated based on gradient information of that block. Several other local image features for contrast enhancement were used in [35, 37, 40]. Local enhancement algorithms are suitable for local texture enhancement, but they can distort the original image and can introduce artifacts.

Global image enhancement algorithms use a single transformation function for the whole image. These are mainly histogram modification algorithms like histogram equalization where the intensities of pixels are re-assigned in such a way that the resultant intensity distribution is uniform. An improvement over conventional histogram equalization, known as the brightness preserving bi-histogram equalization (BBHE) was presented in [21]. This algorithm broke the histogram into two sub-histograms and equalized each sub-histogram separately. The constraint was that breaking of histogram occured at the mean intensity. This preserved the brightness of the original image, unlike conventional histogram equalization which tended to change the brightness. In [6], an improvement over BBHE was proposed by using minimum difference input-output brightness and scalable brightness preservation. Recursively separated and weighted histogram equalization (RSWHE) algorithm was proposed in [22], for brightness preservation and contrast enhancement. This algorithm recursively segmented a histogram into two parts, modified the sub-histograms using a normalized power law function, and performed histogram equalization on the weighted sub-histograms. In [17], a histogram modification algorithm which used probability distribution of luminance pixels in order to enhance contrast of images, was proposed. In [19], color and depth image histograms were used to globally enhance contrast of images while contrast of images were enhanced using interpixel contextual information in [5]. Several other such algorithms were discussed in [16, 31, 53]. Since global image enhancement algorithms use a single transformation function for the entire image, they suffer from over enhancement or under enhancement in certain parts.

Few works have combined local and global enhancement methods to get the best of both worlds. The work in [42] proposed a combination algorithm where local enhancement was followed by global enhancement. Similarly, [52] also proposed a thermal image enhancement algorithm based on combined local and global image processing in the frequency domain. In [20], an enhancement algorithm for remote sensing images was proposed, which used an adaptive gamma correction to enhance the image globally, and then DCT was used to alter the high frequency components and intensify minute details.

Over the past few years, deep neural network (DNN) has become popular and many works have used DNN for image enhancement purpose. In [29], deconvolutional DNN was used to establish an end to end mapping between low-resolution and high-resolution images, thereby enabling recovery of high-resolution images from low-resolution ones. In [56], a novel deep convolutional neural network was used to progressively reconstruct high-resolution depth map images from low-resolution images which were captured by sensors. Photo-realistic high bit depth (HBD) images were recovered using deep convolutional neural network in [44]. In [23], a specifically designed convolutional neural network architecture was developed for the enhancement of single infrared images. In [45], a convolutional neural network (CNN) was used to detect contrast enhancement for forensic purpose.

Some enhancement algorithms require a pre-categorization of images prior to enhancement. In [50], statistical parameters were obtained from luminance information of images. These parameters were used to categorize images into six classes viz. Dark, Low-Contrast, Bright, Mostly-Dark, High-Contrast and Mostly-Bright. Finally, enhancement was achieved by applying piecewise linear transformation function to the images based on their class. Similarly, in [34], the popular adaptive gamma correction (AGC) algorithm was proposed where images were divided into four classes - High/moderate Contrast High/moderate Brightness (HCHB), High/moderate Contrast Low Brightness (HCLB), Low Contrast High/moderate Brightness (LCHB), and Low Contrast Low Brightness (LCLB), based on their statistical parameters (mean and standard deviation). Different gamma correction and brightness adjustment functions were applied to the images based on their class. AGC performs better than state-of-the-art image enhancement algorithms, like recursively separated and weighted histogram equalization (RSWHE) [22], adaptive gamma correction with weighting distribution (AGCWD) [17], contextual and variational contrast enhancement (CVC) [5], and layered difference representation (LDR) [25], in terms of contrast enhancement. AGC has certain advantages over DNN-based algorithms as well. It is simpler and faster. AGC can be computed on a CPU, as opposed to expensive computing devices, e.g. GPU, required by DNN. Unlike DNN, which is a data-driven approach, AGC is based on single image statistics, which makes it computationally efficient.

In spite of being efficient, AGC does not work well on images whose mean or standard deviation values are close to the boundary of separation of each class (HCHB,HCLB,LCHB,LCLB). This is because there is an abrupt change in the enhancement functions from low to high/moderate contrast or low to high/moderate brightness. To overcome this problem, we propose modified contrast enhancement and brightness adjustment functions, which make use of the functions of [34], but get rid of their discontinuities. They do so by combining the contrast enhancement functions using a non-linear weight function and combining the brightness adjustment functions using another non-linear weight function. The modified functions can thus take care of the images which lie on the boundary of separation of two classes. Results reveal that the modified continuous functions work better than the discontinuous functions.

The major contributions of this work are as follows

  1. 1.

    Development of an image enhancement algorithm which can be applied to any image irrespective of image statistics. This is achieved by combining enhancement functions for high/moderate and low contrast images, using a non-linear weight adjustment function, and by combining enhancement functions for high/moderate and low brightness images by another non-linear weight adjustment function.

  2. 2.

    Experimental determination of the steepness parameters for the non-linear weight adjustment functions. The parameters are determined such that the entropy and root mean square (rms) of the enhanced images are at highest saturation values. Any further change in parameter values do not result in any considerable increase in entropy or rms of enhanced images. Since these parameter values have been determined using a large number of images from a variety of sources (9979 images collected from six public image databases), these are expected to work for any image.

  3. 3.

    Achievement of better qualitative and quantitative image enhancement by the proposed algorithm. Experiments have shown that the proposed algorithm achieves better contrast enhancement than existing state-of-the-art image enhancement algorithms.

The rest of this paper is divided into six sections. Section 2 gives a brief description of the adaptive gamma correction algorithm and the problem that arises due to pre-categorization of images. Section 3 discusses about the proposed continuous functions in details. Section 4 gives a step-by-step description of the modified enhancement algorithm. Section 5 describes the experimental setup and discusses results of image enhancement using the proposed algorithm. Section 6 concludes the paper.

2 Pre-categorization problem in adaptive gamma correction

To the best of the authors’ knowledge, there does not exist any single image enhancement algorithm, which can enhance all kinds of images satisfactorily. As a result, there exist a number of enhancement algorithms, which pre-categorize images based on their statistical parameters and enhance each category by separate enhancement functions. This section discusses the pre-categorization strategy employed in AGC and the problem which arises due to it.

Chebyshev’s inequality states that at least 75% values of any distribution are located within 2σ distance around the mean on both sides [38], where σ indicates standard deviation. An image is considered to be of low contrast, when most of the pixel intensities are concentrated within a small range. Based on these, AGC considers an input image with mean (μ) and standard deviation (σ) as low contrast if

$$ DD \leq \frac{1}{\tau} $$
(1)

where DD is the algebraic difference between μ + 2σ and μ − 2σ and τ is a parameter used to define the contrast of the image. Equation (1) can be simplified as

$$ 4\sigma \leq \frac{1}{\tau} $$
(2)

Value of τ is fixed at 3, through experiment, which leads to the condition σ ≤ 0.083 for low contrast images and σ > 0.083 for high/moderate contrast images.

Since mean (μ) varies from 0 to 1, threshold is set at mid value 0.5. Images with μ ≤ 0.5 are considered low brightness images while those with μ > 0.5 are considered high/moderate brightness images. Using these thresholds, AGC categorizes images into four classes [High/moderate Contrast High/moderate Brightness (HCHB), High/moderate Contrast Low Brightness (HCLB), Low Contrast High/moderate Brightness (LCHB) and Low Contrast Low Brightness (LCLB)]. Different enhancement functions are used for high/moderate contrast and low contrast images. Similarly, different functions are used for high/moderate brightness and low brightness images. (Henceforth, high/moderate contrast is mentioned as high contrast and high/moderate brightness is mentioned as high brightness, only for convenience in writing).

The AGC enhancement algorithm states,

$$ I_{\text{out}}=c{I^{\gamma}_{\text{in}}} $$
(3)

where Iin and Iout are input and output image intensities respectively, c and γ are enhancement parameters. AGC states, for low contrast images, a good choice for γ is

$$ \gamma=-\log_{2}\sigma $$
(4)

whereas for high contrast images,

$$ \gamma=e^{\frac{1-(\mu+\sigma)}{2}} $$
(5)

is a good choice. This choice of γ gives rise to a discontinuous function with abrupt change at σ = 0.083. A plot of γ as σ changes from 0 to 0.5 is shown in Fig. 1. The abrupt change of γ at σ = 0.083 can be seen in the plot. It is observed that μ has very little effect on the value of γ, that too only when σ > 0.083. Value of γ lies between 0.779 (for σ = 0.5 and μ = 1) and \(\infty \) (for σ = 0 and μ = any value from 0 to 1).

Fig. 1
figure 1

Plot showing variation of γ with σ for various values of μ

Similarly,

$$ c=\frac{1}{1+\text{Heaviside}(0.5-\mu)\times(k-1)} $$
(6)

where

$$ k=I^{\gamma}_{\text{in}}+(1-I^{\gamma}_{\text{in}})\mu^{\gamma} $$
(7)

and

$$ \text{Heaviside}(x)= \begin{cases} 0,&x\leq0\\ 1,&x>0\\ \end{cases} $$
(8)

Heaviside(x) is also a discontinuous function with abrupt change of c at μ = 0.5.

Figure 2 shows the variation of c with μ for different values of γ. The abrupt change of c at μ = 0.5 becomes more prominent with increasing Iin. Beyond μ = 0.5, c is constant and equal to 1, irrespective of the value of μ or γ.

Fig. 2
figure 2

Plot showing variation of c with μ for various values of γ

The discontinuities in values of γ and c, and the fact that there is little or no change in their values beyond the threshold, are reasons that AGC does not work well for all images. To illustrate this, Fig. 3a shows a sample image (collected from the internet), whose μ is 0.619 and σ is 0.039, while Fig. 3b depicts the same image after enhancement by AGC. Clearly, AGC has failed to enhance contrast and adjust brightness, and the result is a dark image.

Fig. 3
figure 3

A sample image and the corresponding AGC enhanced image

3 Proposed non-linear weight adjusted adaptive gamma correction

We propose non-linear weight adjustment in γ and c computation to get rid of the problem of discontinuities mentioned in Section 2. The weight adjusted functions converge to the discontinuous functions at extrema. It is observed that the weight adjusted functions perform better in most cases, particularly at the vicinity of discontinuity.

3.1 Non-linear weight adjustment

A discontinuous function f(x) having value f1(x) for xx0 and f2(x) for x > x0 can be considered to be two functions weighted by a step function S(x) such that,

$$ S(x)= \begin{cases} 0,&x\leq x_{0}\\ 1,&x>x_{0}\\ \end{cases} $$
(9)

In this form, f(x) can be written as,

$$ f(x)=(1-S(x))f_{1}(x)+S(x)f_{2}(x) $$
(10)

f(x) has a value of f1(x) when S(x) = 0, that is when xx0. f(x) = f2(x) when S(x) = 1, that is when x > x0. By changing the function S(x), the nature of f(x) can be varied. To avoid discontinuity, we need an S(x) that spans the interval [0,1], but avoids the abrupt change of value at x = x0. A simple form of S(x) that fulfills this condition is the non-linear function of (11). Figure 4 shows the two forms of S(x) functions. Figure 4a is a step function with x0 = 0.4. Figure 4b is a continuous non-linear function which converges to Fig. 4a at extrema. The steepness of Fig. 4b, and thus the value of S(x) at x0, can be varied by putting weight p on the exponent. On increasing p, Fig. 4b becomes steeper and approaches the step function. The weighted non-linear function is given in (12).

$$ S(x)=x^{-\log_{2}(x)} $$
(11)
$$ S(x)=x^{-p\log_{2}(x)} $$
(12)
Fig. 4
figure 4

A Step function and a continuous non-linear function which approaches the Step function

3.2 Computation of enhancement parameters

The idea discussed in Section 3.1 has been used to do away with the discontinuities discussed in Section 2. The two γ functions in (4) and (5) have been combined by a non-linear weight adjustment function wγ to generate the continuous γν function. This adjustment function wγ is expressed as

$$ w_{\gamma}=(2\sigma)^{-{p^{}_{\gamma}}\log_{2}(2\sigma)} $$
(13)

Clearly, wγ is analogous to S(x) in (12). Since σ varies from 0 to 0.5, 2σ varies from 0 to 1. Hence wγ spans the interval [0,1]. wγ approaches 0 as σ approaches 0 and it approaches 1 as σ approaches 0.5. The parameter pγ determines the steepness of wγ. The resultant function γν is a weighted summation of (4) and (5). It can be expressed as

$$ \gamma_{\nu}=w_{\gamma}e^{\frac{1-(\mu+\sigma)}{2}}+(1-w_{\gamma})(-\log_{2}\sigma) $$
(14)

Equation (14) is analogous to (10) in Section 3.1. Clearly, for small values of σ, wγ is small, hence (14) reduces to (4). As σ increases, wγ also increases, thereby (5) gains weight, until at σ = 0.5, wγ is 1 and (14) converges to (5). Mathematically, this can be expressed as,

$$ \begin{aligned} \lim_{\sigma\to 0} \gamma_{\nu}=-\log_{2}\sigma \\ \lim_{\sigma\to 0.5} \gamma_{\nu}=e^{\frac{1-(\mu+\sigma)}{2}} \end{aligned} $$
(15)

Similar to wγ, the discontinuous c functions have been combined by a non-linear weight adjustment function wc.

$$ w_{c}=\mu^{-{p^{}_{c}}\log_{2}\mu} $$
(16)

pc is the steepness parameter. As μ varies from 0 to 1, wc varies from 0 to 1 with varying steepness depending on pc. The weighted continuous c function, denoted by cν, is obtained from (6) and (7).

$$ c_{\nu}=\frac{1}{w_{c}+(1-w_{c})k_{\nu}} $$
(17)

where

$$ k_{\nu}=I^{\gamma_{\nu}}_{\text{in}}+(1-I^{\gamma_{\nu}}_{\text{in}})\mu^{\gamma_{\nu}} $$
(18)

When μ is small, wc is small, which implies (1 − wc)kν term predominates. With increasing μ, the wc term gains weight. At μ = 1, wc = 1, i.e. cν = 1. This is in compliance with (6). Mathematically, this can be expressed as,

$$ \begin{aligned} \lim_{\mu\to 0} c_{\nu} &= \frac{1}{k_{\nu}} = \frac{1}{I^{\gamma_{\nu}}_{\text{in}}+(1-I^{\gamma_{\nu}}_{\text{in}})\mu^{\gamma_{\nu}}}\\ \lim_{\mu\to 1} c_{\nu} &=\frac{1}{w_{c}}=1 \end{aligned} $$
(19)

3.3 Steepness parameters p γ and p c

A plot showing the variation of wγ with σ (13), for a wide range of values of pγ is shown in Fig. 5. We observe that with increasing values of pγ, the rise of wγ becomes sharper. Selection of pγ is crucial for computation of wγ, which in turn, determines the weight each γ function gets in order to compute γν.

Fig. 5
figure 5

Plot showing variation of wγ with σ for various values of pγ

Similar to pγ, pc is crucial for evaluation of wc, hence cν. A plot showing variation of wc with μ (16)for a wide range of values of pc is shown in Fig. 6. As pc increases, wc changes from a flat curve to a sharp one, similar to wγ.

Fig. 6
figure 6

Plot showing variation of wc with μ for various values of pc

Experiments are done by gradually changing values of pγ and pc such that the corresponding values of wγ and wc at the thresholds (σ = 0.083 and μ = 0.5) range from 10− 6 to 1. We observe that optimum results in terms of average entropy and average root mean square scores of the enhanced images are obtained at a point where values of wγ and wc are 10− 5 and 10− 3 respectively, at the thresholds. The corresponding values of pγ and pc are 2.47 and 9.96 respectively. Experimental details of determination of pγ and pc are discussed in Section 5.1.2.

Figure 7 shows the variation of γ and γν with σ at an arbitrary value of μ = 0.5. γν has been computed using pγ = 2.47. The discontinuous nature of γ as opposed to the continuous γν is clearly visible in the plot. Also, it is evident that γν converges to γ at the extrema.

Fig. 7
figure 7

Plot showing variation of γ and γν with σ at μ = 0.5

Figure 8 shows the variation of c and cν with μ, at an arbitrary γ = γν = 2.5. Value of pc is taken to be 9.96 for computation of cν. The continuous nature of cν as opposed to c is more evident with increasing intensity. Like in Fig. 7, values of c and cν also merge at extrema.

Fig. 8
figure 8

Plot showing variation of c and cν with μ at γ = γν = 2.5

A 3D view of the variation of γ and γν, as σ varies from 0 to 0.5 and μ varies from 0 to 1 is shown in Appendix. Similarly, a 3D view of variation of c and cν, as μ varies from 0 to 1 and γ or γν varies from 0.779 to 50, for intensity 0.996, is also given there.

4 The enhancement algorithm

The main step of the image enhancement algorithm consists of modifying each intensity according to the enhancement function. Here we discuss the algorithm with reference to our proposed function. A block diagram of the algorithm is given in Fig. 9.

  • Color Transformation: Most color images are available in RGB (Red (R), Green (G), Blue (B)) format. In this format, the three channels are correlated, hence intensity transformation affects color of the image. For this reason, color images are first converted to the HSV (Hue (H), Saturation (S) and Value (V)) color space. In this space, color information can be completely separated from Value information (V). So, enhancement of V enhances the image without affecting color. This transformation is not required for grayscale images.

  • Enhancement of Intensities: Enhancement consists of transforming each intensity according to (20).

    $$ I_{\text{out}}^{\prime} = c_{\nu}I_{\text{in}}^{\gamma_{\nu}} $$
    (20)

    where cν and γν are evaluated using (17) and (14) respectively. γν automatically takes care of high or low contrast images. Similarly, cν handles both bright and dark images.

  • Reverse Color Transformation: Color image is converted back to RGB from HSV color space with enhanced V. Grayscale images do not require to undergo this step.

Fig. 9
figure 9

Block diagram of proposed image enhancement algorithm

5 Experimental setup and results

The experiments can be divided into two parts. Firstly, a database has been prepared and using the database, experiments are done to compute pγ and pc. Finally, using the computed values of pγ and pc, qualitative and quantitative assessment of the proposed algorithm have been performed.

5.1 Experimental setup for image enhancement

Experiments have been performed to find the values of the two steepness parameters pγ and pc. Using these parameters, the performance of the proposed algorithm has been tested. We have prepared a database consisting of 9979 images for these experiments.

5.1.1 Database description

Images from six public image databases namely, Gonzalez et al. [14], Extended Yale Face Database B [13, 24], Caltech-UCSD birds 200 [54], Corel [3, 26, 46,47,48], Caltech 256 [15] and Outex-TC-00034 [32], have been used to analyse the performance of the proposed algorithm. There is no need to pre-categorize images in this algorithm, but since results have been compared with AGC [34], images from the six databases are divided into four classes - HCHB, HCLB, LCHB and LCLB, based on statistical parameters (as mentioned in Section 2).

The total number of images in each class, along with the number of images from each public image database within each class, are listed in Table 1. From these images, 3000 images have been randomly chosen from each class to form a new database D. For example, 3000 images have been randomly chosen from 29132 images belonging to HCHB. D has been used for the experiments done in this work. As can be seen from Table 1, LCHB has only 979 images. So the 979 images have been selected in D. Finally, D consists of 9979 images, 3000 images each, from HCHB, HCLB and LCLB, and 979 images from LCHB. D is used for all quantitative analysis described in this paper. For qualitative analysis, a few randomly selected images from the internet have also been used, besides the images from D. The randomly selected images from the internet, wherever used, have been mentioned.

Table 1 Number of images within each class

5.1.2 Determination of steepness parameters

The first part of the experiment is to determine the values of the steepness parameters pγ and pc. We perform experiments starting from pγ = 0, then gradually increasing pγ such that weight wγ at the threshold (σ = 0.083) decreases from 1 to 10− 6 (13). The various values of pγ and corresponding values of wγ are listed in Table 2. Again, for each pγ, pc is gradually increased such that weight wc at the threshold (μ = 0.5) decreases from 1 to 10− 6 (16). A list of values of pc and corresponding wc is given in Table 3.

Table 2 pγ and corresponding wγ at σ = 0.083
Table 3 pc and corresponding wc at μ = 0.5

For each pγ, pc pair, the 9979 images of D are enhanced using the proposed algorithm. Entropy and root mean square (rms) scores of the enhanced images are computed. These scores are averaged over the 9979 images. So, at the end, we have a set of 225 averaged entropy values and 225 averaged rms values (since there are fifteen pγ values and fifteen pc values in Tables 2 and 3 respectively). We work with these averaged entropy and averaged rms values to determine the optimum pγ and pc. For convenience in writing, in this subsection (5.1.2), we refer to the averaged entropy and averaged rms simply as entropy and rms respectively.

Figure 10 shows plots of pc vs entropy and pc vs rms respectively for increasing values of pγ. Only six among the fifteen pγ values of Table 2 are plotted to maintain clarity in the plots. The two plots show that for a particular value of pγ, entropy and rms initially increase with increasing pc, but start to saturate at a region around pc = 8. By the time pc reaches 9.6, entropy and rms have attained their maximum possible values. They show very little change beyond pc = 9.6. Figure 10 also shows that as pγ is increased, the graphs of pc vs entropy and pc vs rms become sharper. For example, for pγ = 0.14 (the light green curve), entropy at pc = 0.32 is 5.041, and for pγ = 0.25 (the red curve), entropy at the same pc is 4.881 which is less than 5.041. However, for pγ = 0.14, entropy at a higher pc, e.g. pc = 6.64 is 6.074, whereas entropy of pγ = 0.25 at pc = 6.64 is 6.110 which is greater than 6.074. As pγ is gradually increased beyond 1.48, the graphs start overlapping on each other, indicating a saturation point. Beyond pγ = 2, the graphs completely overlap. Increasing pγ further shows negligible change in entropy or rms. If we look at the graphs closely, we can observe that the overlap occurs earlier for entropy. Therefore, only four colors are separately visible in Fig. 10a, indicating curves for pγ = 1.48, pγ = 2.47 and pγ = 2.96 overlap. However, rms values continue to change with increasing pγ, so five distinct colors are visible in Fig. 10b. rms values saturate around pγ = 2. rms curves for pγ = 2.47 and pγ = 2.96 completely overlap indicating saturation.

Fig. 10
figure 10

pc vs entropy and pc vs rms for increasing values of pγ

Figure 11 does not give any new information. It just shows the variations of Fig. 10 from a different dimension. It shows variations of entropy and rms respectively with pγ for increasing values of pc. Figure 11 has been included to add clarity to the information provided by Fig. 10. Out of the fifteen pc values of Table 3, only six have been plotted to avoid cluttering of the plots. The curves of pc = 9.96 and pc = 16.60 in Fig. 11 are not visible at all, indicating complete overlap of curves of pc = 9.96, pc = 16.60 and pc = 19.93.

Fig. 11
figure 11

pγ vs entropy and pγ vs rms for increasing values of pc

Following the nature of the graphs in Figs. 10 and 11, it is very clear that entropy and rms values saturate around pγ = 2 and pc = 9.6. We choose slightly higher values of pγ and pc to ensure complete saturation. The chosen values are pγ = 2.47 and pc = 9.96.

5.2 Performance evaluation

Superiority of the proposed non-linear weight adjusted adaptive gamma correction algorithm over AGC has been established qualitatively as well as quantitatively.

5.2.1 Qualitative assessment

For qualitative assessment, twelve images have been selected, three from each class. The images are either chosen from D or collected from the internet.

I1, I2 and I3 belong to HCHB. μ and σ values of these images are given in Table 4. Image I1 has been collected from the internet. I2 and I3 belong to D. Figure 12 shows the original images, the AGC enhanced images and the images enhanced by proposed non-linear weight adjusted adaptive gamma correction algorithm respectively. From Fig. 12a, b and c, it is clear that AGC does not make much change to I1 and it visually looks similar to the original, whereas the proposed algorithm enhances its contrast. The whitewashed effect in I1(a) and I1(b) is much reduced in I1(c).

Table 4 Mean (μ) and standard deviation (σ) of HCHB images
Fig. 12
figure 12

Comparison of enhancement algorithms on HCHB images. Image names: top → bottom: I1,I2,I3

Mean (μ) of I2 lies close to the threshold value, but σ is high. No noticeable enhancement is done to the image by AGC. Enhancement by the proposed algorithm is visibly brighter which is clear from Fig. 12d, e and f.

Similar to I2, μ of I3 also lies close to the threshold. There is no significant difference between original image and image enhanced by AGC whereas output of proposed algorithm is of higher contrast. Figure 12g, h and i show the original image, AGC enhanced image and image enhanced by proposed algorithm respectively.

Images I4, I5 and I6 belong to HCLB. μ and σ values of these images are given in Table 5 and the images and their enhanced forms are shown in Fig. 13. All three images are taken from D.

Table 5 Mean (μ) and standard deviation (σ) of HCLB images
Fig. 13
figure 13

Comparison of enhancement algorithms on HCLB images. Image names: top → bottom: I4,I5,I6

Both μ and σ of I4 lie close to threshold. Result of enhancement shows that AGC gives a whitewashed effect whereas the output of proposed algorithm looks brighter with better contrast. Figure 13a, b and c show the original image, image enhanced by AGC and image enhanced by proposed algorithm respectively.

Mean μ of I5 is close to threshold, but σ is high. Original image, image enhanced by AGC and image enhanced by the proposed algorithm are shown in Fig. 13d, e and f respectively. Though the two enhanced images look similar, there is a little whitewashed effect in the AGC enhanced image which is noticed in the face of the man.

Image I6 has low μ but σ lies close to threshold. Enhancement results clearly show superiority of proposed algorithm over AGC which produces a faded output. Figure 13g, h and i show the original image, AGC enhanced image and image enhanced by proposed non-linear weight adjusted adaptive gamma correction algorithm respectively.

Images I7, I8 and I9 are LCHB images. The μ and σ values are given in Table 6. Figure 14 shows the original and enhanced images. I7 has been collected from the internet, while I8 and I9 are taken from D.

Table 6 Mean (μ) and standard deviation (σ) of LCHB images
Fig. 14
figure 14

Comparison of enhancement algorithms on LCHB images. Image names: top → bottom: I7,I8,I9

Mean (μ) of I7 and I8 lie close to the threshold, while that of I9 is high. σ varies from very low to boundary value. AGC fails to enhance these images and results in a dark image as can be seen from Fig. 14. In comparison, the proposed algorithm gives much better enhancement.

Enhancement of LCLB images by AGC and the proposed algorithm are shown in Fig. 15. The μ and σ values are given in Table 7. These images are taken from D.

Fig. 15
figure 15

Comparison of enhancement algorithms on LCLB images. Image names: top → bottom: I10,I11,I12

Table 7 Mean (μ) and standard deviation (σ) of LCLB images

Unlike the other three classes, LCLB does not show much noticeable difference between the image produced by AGC and the image produced by the proposed algorithm. The reason behind this has been analyzed in Section 5.2.3

The images in Fig. 12 visibly prove that the proposed non-linear weight adjusted adaptive gamma correction algorithm is better than AGC, because AGC hardly has any effect on HCHB images. Figures 1213 and 14 show that the proposed algorithm is better for images where μ or σ or both are close to thresholds. Figure 15 shows that there is no noticeable difference in enhancement for LCLB images. Entropy and root mean square (rms) values of these twelve images and their enhanced versions are given in Tables 8 and 9 respectively.

Table 8 Entropy of images I1 - I12, original and enhanced versions
Table 9 Root Mean Square (rms) of images I1 - I12, original and enhanced versions

In Fig. 16, histogram plots of some images (original image, image enhanced by AGC and image enhanced by the proposed algorithm) are shown. Among these images, I19 has been collected from the internet. Rest are from database D. μ and σ of these images vary randomly. μ and σ values are given in Table 10. Figure 16 shows that the proposed algorithm successfully generates a flatter histogram. The only exceptions are images I15 and I17 where AGC and the proposed algorithm produce similar histograms. μ and σ values of these two images show that these are LCLB images. The reason behind similar outputs by both AGC and the proposed algorithm, on LCLB images, is explained in Section 5.2.3.

Fig. 16
figure 16

Comparison of enhancement algorithms using histogram. Image names: top → bottom: I13,I14,I15,I16,I17,I18,I19,I20,I21

Table 10 Mean (μ) and Standard Deviation (σ) values of images I13 - I21

5.2.2 Quantitative assessment

Images in database D are used for quantitative assessment of the proposed algorithm. Entropy (E) and root mean square (rms) scores of the images are computed using (21) and (22) respectively. These are then averaged over each class (HCHB, HCLB, LCHB and LCLB). Higher values of entropy or rms imply better image in terms of contrast. The values of average entropy and average rms score of original image, image enhanced by AGC and image enhanced by the proposed algorithm are given in Tables 11 and 12 respectively. The bulk average scores computed over the entire database are given in Table 13.

$$ E=-\sum\limits_{i}p_{i}\log_{2}p_{i} $$
(21)

pi is the probability of occurrence of ith intensity in the image.

$$ rms=\sqrt{\frac{1}{MN}\sum\limits_{i=1}^{M}\sum\limits_{j=1}^{N}{(\mu-\text{H}_{ij})}^{2}} $$
(22)

where M and N are the number of rows and columns respectively in the image, Hij is the intensity of the pixel of ith row and jth column.

Table 11 Average entropy of the images in D
Table 12 Average rms of the images in D
Table 13 Bulk average entropy and average rms

Tables 11 and 12 show that average entropy of the proposed algorithm is higher for HCHB and LCHB images. It is a little less for HCLB images. For LCLB images, average entropy of AGC and proposed algorithm are the same. As far as average rms values are concerned, proposed algorithm gives much better result for HCHB, HCLB and LCHB images. For LCLB images, average rms of AGC and proposed algorithm are same. Both average entropy and average rms scores, computed over the entire database D, are higher for the proposed algorithm (Table 13).

5.2.3 Analysis on LCLB images

Both qualitative and quantitative results show that there is no significant difference in the output of AGC and the proposed algorithm as far as LCLB images are concerned.

The chosen value of pγ is such that weights wγ for values of σ ≤ 0.083 are very small. This can be computed from (13). Therefore, (14) converges to (4) for low contrast images (σ ≤ 0.083). In other words, γ and γν values are asymptotically equal for low contrast images. This is graphically depicted in Fig. 7.

Similarly, the chosen value of pc is such that weights wc for μ ≤ 0.5 are very small (16). Therefore, (17) converges to \(\frac {1}{k_{\nu }}\). As discussed above, for low contrast images, one finds γνγ. As a result, kνk ((7) and (18)). This implies cνc ((6) and (17)). This is graphically shown in Fig. 8. Since γν converges to γ and cν converges to c, (20) and (3) are equivalent in case of LCLB images. Values of pγ and pc are the cause for similarity between AGC and proposed algorithm on LCLB images.

5.2.4 Computation time

One limitation of the proposed algorithm is the fact that its computation time is slightly higher than that of AGC. Average time required for enhancement of one image by the proposed algorithm is 0.189 seconds whereas it is 0.106 seconds by AGC. This has been computed using MATLAB 2018a on a 64 bit, Windows 10 Pro computer with 4 GB RAM and Intel(R) Core(TM) i7 − 4790, 3.60 GHz processor. Higher time requirement is due to the fact that the proposed algorithm uses a non-linear weighted combination of two enhancement functions to compute the resultant enhancement unlike AGC, which categorizes the image prior to enhancement.

5.2.5 Comparison with other state-of-the-art algorithms

The proposed algorithm has been compared with and is found to be better than AGC. To establish its superiority further, we compare it with a few other state-of-the-art algorithms.

For comparison, 300 images have been randomly selected from D. These are enhanced using brightness preserving bi-histogram equalization (BBHE) [21], recursively separated and weighted histogram equalization based on mean (RSWHE-M) and median (RSWHE-D) [22], adaptive gamma correction with weighting distribution (AGCWD) [17] and the proposed algorithm. Entropy (E) and root mean square (rms) of the enhanced images are computed. Average of E and rms over 300 images, enhanced by the different algorithms, are given in Tables 14 and 15. The best scores are observed in the proposed algorithm.

Table 14 Comparison of proposed algorithm with other state-of-the-art algorithms
Table 15 Comparison of proposed algorithm with other state-of-the-art algorithms

6 Conclusions

To overcome the problem caused by pre-categorization of images, this paper has proposed a non-linear weight adjusted adaptive gamma correction algorithm for image enhancement. This algorithm can be applied to any image irrespective of the image statistics. Enhancement is achieved by combining enhancement functions for high and low contrast images using a non-linear weight adjustment function, and by combining enhancement functions for high and low brightness images by another non-linear weight adjustment function. The non-linear weight adjustments are able to get rid of the discontinuities present in AGC. Hence, they can enhance images which lie on the boundaries of discontinuity, unlike AGC. The continuous functions converge to the discontinuous ones at extrema. We have experimentally determined the steepness parameters (pγ and pc) of the non-linear weights. Extensive experiments have been performed on 9979 images from six public image databases. Images are enhanced by slowly varying pγ and pc values. Entropy and root mean square of enhanced images are computed. The set of pγ and pc values for which entropy and root mean square give optimum result are chosen. To the best of our knowledge, this kind of extensive experimentation, to determine enhancement parameters, is not present in the literature of this field of research. Further, with the chosen values of pγ and pc, the proposed algorithm has been shown to be better than AGC both qualitatively and quantitatively. Histogram plots in Fig. 16 re-establish this superiority. The proposed algorithm has been compared with other state-of-the-art image enhancement algorithms. Results prove its better performance. However it achieves better enhancement with no prior requirement for categorization of images, at the cost of a slight increase in computation time as compared to AGC.

The proposed algorithm enhances contrast of an image, taking into consideration only its intensity values. RGB images also contain color information, which has not been utilized in this algorithm. In [12], local and global pixel information are utilized in foreground map evaluation. Local and global intensity information are utilized in several other works for image contrast enhancement. Following these ideas, an interesting future direction of this work can be to incorporate local and global color information in the proposed algorithm.