Adaptive Logarithmic-Power Algorithm for Preserving the Brightness in Contrast Distorted Images

The digital images get distorted due to nonuniform light conditions or improper acquisition settings of the digital camera. Such factors lead to distorted contrast objects. In this work, we proposed adaptive enhancement algorithm to improve the contrast while preserving the mean brightness in the image. The method developed is a combination of discrete wavelet transform and gamma correction. Firstly, the gamma scale is computed from multi-scale decomposition using 2Ddiscrete wavelet transform. The value of scale parameter in gamma was computed from combination of logarithmic and power function. Secondly, the gamma correction is implemented to improve the contrast in the image. Lastly, bilateral filtering is utilized for smoothness of edges in the image. The approach effectively preserved the brightness and optimized the contrast in the image. The objective quality measures used as Peak SNR, AMBE, entropy, entropy based contrast measure and median absolute deviation is computed and compared with other state-ofthe-art techniques. Keywords—Non-uniform images; gamma correction; multiscale 2Ddiscrete wavelet transform; logarithmic-power; quality metrics


I. INTRODUCTION
Due to imbalance of energy in the wavelength between RGB (red, green, and blue) colours, the distortion in the contrast is produced in the images. The contrast is the variation of brightness to discriminate between the features present in the image. The Fig. 1 is the exact illustration of what had been discussed by Qing Zhang et al [1]. The figure displayed an image with the distorted contrast, where most of the pixel values lies at the left extrema of the intensity scale. If the pixel values narrows at the extreme left, right, and middle values of the intensity scale, then the image is termed to be dark, bright, and low contrast images. For high contrast, the requisite amount of pixel should be uniformly distributed over the entire intensity scale [2]. Therefore, contrast is an important parameter to indicate the structural information in the image. With contrast stretching, the spread from a low to a high contrast range can be attained. Such mapping is termed to be the adjustment of dynamic range of intensity scale. Therefore, contrast stretching is a transformation technique utilized through linear or non-linear operations. The histogram equalization (HE) is one of the popular linear transformation technique, known for its simplicity and ease of use. It is an intensity-based transformation which computes the information content based on statistical inference. Fig. 2 shows the full span of range obtained from HE technique. It generates distributed regions all over the intensity scale. But, with the stretch of contrast, contouring artifacts is occurred due to the loss of edges. Moreover, due to poor brightness preservation, the quality of the image is distorted. Hence, it is required to maintain the equilibrium between contrast and brightness in the image.

II. RELATED WORK
To overcome the limitation of HE, different techniques were proposed as mentioned in [3][4] [5] to improve the quality of the image. The main idea in most of the techniques was to spread the dynamic range of the images. However, the HE does not provide sufficient information on the composition of fine details and edges. Most of the results obtained from the modified approach to HE, produced over enhancement for the darker scale and under enhancement for the lighter scale of the intensity values. The illustration in Fig. 3 was the enhanced image form the algorithm proposed by Kuldeep Singh and R. Kapoor as "MMSIC" [6]. The modified HE was computed from mean-median based clipped histogram to improve picture quality. With this technique, the large number of pixel values were more towards the left extrema. This effect leads to *Corresponding Author www.ijacsa.thesai.org the low quality of contrast. Also, M.M. and M. Abdullah-Al-Wadud [7] had proposed the boosting algorithm for correction in over enhancement. The minor regions were boosted to suppress quantum jumps. Another approach is the global and local HE methods. In the global HE, the overall picture is enhanced. Whereas in local HE, with the utilization of small windows, the quality of the picture is improved. Qi-Chong Tian and Laurent D. Cohen [8] proposed the combination of global and local HE to preserve the naturalness of the image. Further, fast quadratic HE was proposed by Surabhi Patel [9]. The author claimed the method was computationally faster as compared to global HE and local HE. Lastly, compared to the various modified methods of HE, BPDHE [3] produced effective results in preserving the mean brightness.
Other than HE, discrete wavelet transform is also a useful tool to improve the overall quality of the image. Hafiz Syed Muhammad Muslim et al. [10] had proposed noise reduction using 2-dimensional-discrete wavelet transform (2D-DWT) and a Gaussian low-pass filter. The DWT was used to filter the high frequency content and, for the other part, a Gaussian low pass filter was used. The algorithm was designed for improvement in the visual quality of medical images.
In recent times, the implementation of gamma is used for contrast improvement. Like sigmoid, it is also a non-linear approach to improve the contrast. In this techniques, gamma parameter is a constant value. Due to non-uniform contrast in images, the scale parameter in cannot be held constant. To meet the challenge, Huan S et al [11] developed AGCWD as adaptive gamma correction with weighted distribution mapping of the histogram to improve the contrast. The algorithm designed is limited in approach and mostly overenhanced the low-contrast images. Gang Cao et al [12] have proposed an effective way to handle the exaggerated enhancement with gamma correction. Rather than correlating with the cumulative density function, gamma scale was used for the negative portion of the images. The modulated value of gamma alleviates the contrast of the image. For the effectiveness of gamma correction, a scale parameter is required to be computed such that, along with the contrast improvement, brightness is preserved in the image. The method of mean-variance computation of scale parameter was proposed by Meriama Mahamdioua and Mohamed Benmohammed was proposed to deal with the non-linear nature of gamma correction. But most of the experimental results were focused on facial recognition in the image. In such condition, the other details of the image could be avoided for overall enhancement. Further G. Jiang et al [13] developed the golden search algorithm to optimize the scalability of gamma. Through the weighted sum, mean brightness was preserved. Liyun Zhuang and Yepeng Guan [14] proposed the log-exponential method to compute the scale of gamma. The HE was modified through the gamma scale to show the richness in the information details. The objective measures indicated the improvement but the subjective quality of the image was effected due to saturation effects. The hybrid combination of discrete wavelet transform and singular value decomposition was utilized by Sahnoun M. et al [15]. The experiments were restricted to MRI images for utilization of the proposed method and was dealt with grayscale content. Linwei Fan et al [16] explored the pros and cons of denoising techniques for the better visibility of the images. After formulation of denoising problem, various methods and their consequences were explored to conclude the findings of denoising techniques.
Although, HE is the simplest technique to enhance the contrast in the image. Due to serious limitation of over/underenhancement (as clearly observed in Fig. 2 and 3), alternate approach of gamma is presented in our proposed algorithm.
The key point is to preserve the mean brightness while improving the contrast. So, the estimation of brightness is computed through multiscale resolution analysis. And lastly, the scalability of contrast is increased by automated gamma scale calculated from logarithmic-power function.
The organization of the paper will be as followed. In section III, the proposed algorithm is discussed. In section IV, experimental results is demonstrated. Lastly, the conclusion of the proposed algorithm is interpreted.

III. PROPOSED ALGORITHM
The Fig. 4 demonstrates the flow diagram of the proposed algorithm with gamma correction in contrast distorted images. The course of the work progressively followed with the conversion of raw RGB image to hue (H), saturation (S) and intensity value (I). The luminance value (I) is used for further processing stages. The computation of gamma scale function was obtained from logarithmic-power function. For the optimal value of scale parameter, multiscale resolution is implemented using 2D-discrete wavelet transform. This approach is necessary to extract the maximal luminance information in the intensity component. Lastly, the enhanced image is obtained from bilinear filtering to smooth out the edges.

A. Image Transformation
It is difficult to process the information for individual colors. Hence, for the given raw image, given as F(x,y), is converted to "I" [17] such that:  (1) "T denotes the transformation of RGB to HSI.
As shown in fig. 5, in comparison to grayscale, the intensity component has the maximal content of brightness in the image.

B. Multiscale Decomposition
Most of the algorithms were designed to decompose the input image into bright and dark regions or partitioning of histogram [18] [19] [6] to obtain the luminance value in the image. Also, the 2D-DWT is utilized to compute the weighted function for selection of control parameters.
Inspired by the use of 2D-DWT in [15], multiscale resolution to the "I" component in the HSI space is implemented to compute brightness. The primary objective is to estimate "brightness" in the image. The information was down-sampled at a scale level of "two". The Fig. 6 showed the 2D-DWT decimation of information into four sub samples. The resultant image consisted of low pass filter in rows and columns direction sub-sampled at a scale level of "2". The other followed by combination of high and low pass filter coefficients. With the profound studies [20] [21], multiscale discrete wavelet transform (2D-DWT) was implemented. The 2D decomposition is obtained from one dimensional DWT decomposition. The 2D-discrete wavelet transform is implemented with mother wavelet as "symlet5".
Where √ is the specific mother wavelet, is the intensity component of the given image and is the transformed image as shown in Fig. 5.
The choice of mother wavelet and selection of scale level was based on computation of wavelet energies [22] . The energy was calculated in a two-step formation as follows: (i) compute the wavelet energy at each scale level for different mother wavelets and (ii) the mother wavelet at preferred scale level with highest energy would be the criteria for decomposition.

C. Estimation of Scale Parameter
There could be two possible ways to determine the scale parameter, either it should be chosen a constant value obtained from testing on various images with varying light conditions. Secondly, to make it adaptable for individual intensity scale of the image. Due to unpredictable variations in color distribution, assuming a constant value is difficult to obtain desired objective. Hence, the approach based on assumption of computing the average of minimum intensity of individual colors was taken to define selection criteria. This average value was computed from the original image. Secondly, the scale parameter is computed from the modified form of scale parameter in a logarithmic function. The logarithmic function is defined by the relation as s=clog(1+r). The scaling constant "c" is chosen such that input intensity is mapped to high values and is calculated as: , where J is the maximum scale value (255) and max(I) is the maximum input value. This scale constant is modified with the assumption of mean intensity of low pass coefficients and is computed from Eq. 3. From the obtained value in equation (2), the mean intensity of pixel values were calculated as = ∑ Where "" is the mean intensity of low pass coefficients "LL".

=
(3) Where "" is the scale parameter for gamma correction.
The minimum perceptible value of gamma must be 0.5 for any change in the contrast. And if the value goes greater than 1, will produce low contrast image. Since, the value obtained from Eq. 3 is too large to produce a desirable quality. Hence, the objective function was introduced to balance the scale of gamma parameter.
where  is the scale parameter and "av(min(RGB))" defined the objective function and is calculated as average of minimum intensity value in RGB colors. The value of gamma ranges from zero to infinity. However, if the scale value is 1, defines the linear mapping. And if the scale tends towards zero, the mapping is at higher or in other sense, brighter output values. Otherwise, towards darker output values. The intensity range of our referred data does-not constituted darker pixel values. From Eq. 4, it is found that the value of gamma greater than 1.25, over-enhanced the final image. Hence, the primary concern was to keep the scale level less than "1". To overcome the over or under enhancement, adaptive gamma correction is implemented. As proposed in [23] , the increment value of gamma was computed from mean and variance combination for correction in contrast. But this method is limited to facial recognition, hence the proposed approach computed the average of maximum intensity of each channel in the original image. It is clearly observed in Eq. 5, the range was selected from for no correction in the gamma scale. However, if the value of gamma ( is either decreased or increased, the correction in gamma is processed from other relation as stated in Eq. 5. With this approach, the mean brightness is well preserved. Lastly, gamma correction is implemented on "HSI" transformation. The relation is as shown below: Where is the final image (HSI) and is the image obtained from Eq. 1. The Fig. 7 illustrated the comparison of entropy, peak signal to noise ratio (PSNR) and mean brightness error (AMBE) to understand the necessity of change in gamma scale. The quality metrics was compared for the images with gamma correction (M) and without correction (U). The result of ten such images were shown, where gamma scale exceeds the threshold of 1.25. The AMBE [24] is the tool to predict the preservation of mean brightness in the image. Lower the value of AMBE, better will be the preservability. Since, AMBE is not a better metrics to measure noise content in the given information. Hence, PSNR [25] is also stated to predict the noise content in the image. Higher the value of PSNR, lower will be the noise and hence, better quality of image is obtained. The effectiveness of adaptive gamma scale produced the weighted change in AMBE and PSNR. Moreover, the richness of data (entropy) could be clearly observed in comparison to unmodified gamma correction.    Further, the Fig. 9 demonstrated the quality of the image, when the threshold value was less than 0.85. The middle (b) is low in contrast and when modified with the threshold (0.5-(av(max(RGB))), produced the contrast enhanced image (c).
With point of human perception, "I" is better for color image processing. However, conversion process of "rgb" to "hsi" and vice-versa produced the over-saturated colors. It is stated in [16], that convolutional neural network based denoising technique is well equipped to retain the naturalness in the image. Due to transformation and non-linear approach (gamma), the resultant image in our approach lead to disorientation in formation of colors. Hence, bilateral filtering is implemented to each channel for uniformity in color distribution. So, bilateral filtering was implemented to smooth out the edges for enhanced image. This type of filter is a noise suppression smoothing filter. Each color component is smoothed out while preserving the edges.
In summary, the algorithm proposed could be described as:-

Algorithm: Adaptive logarithmic-power function for contrast distorted image
Input Image: Original Image F(x,y) Step 1: Convert the original image to HIS channel to obtain "I" component (brightness) Step 2: Decompose the "I" at a scale level of "2" using multiscale 2D discrete wavelet transform Step 3: Using low-pass coefficients (shown in Fig. 6), compute the scale parameter using Eq. 3 and 4.
Step 4: Validate the scale value obtained from Eq. 4, using Eq. 5 for individual images.
Step 5: Finally, apply the automated gamma correction using Eq. 6 .
Step 6: After conversion from HIS to RGB, smooth out the edges using bilateral filtering.
Step 7: Obtain the Enhanced image.

IV. EXPERIMENTAL ANALYSIS
This section deals with the quality metrics implemented for comparison of proposed method with various state of the art techniques. The experiments were analyzed in the MATLAB 2017, platform. The machine used for evaluation was Apple MacBook, 1.8 GHz CPU and 8 GB of RAM.

A. Image Dataset
The Berkeley Image dataset BSDS500 [26] and CEED 2016 [27] is used for evaluation of the proposed work. From the referred dataset, 200 images with varying light conditions were selected.

B. Quality Metrics
The objective was to preserve the mean brightness while improving the overall contrast in the image. So, for our method, three quality metrics used as Entropy, absolute mean brightness error and Peak signal to noise ratio. The assessment of algorithm was based on full reference and no-reference measure. The full reference measure the information of the enhanced image in comparison to original image. Similarly, PSNR [25] and AMBE [28] measure the information as a full reference to predict the noise and mean brightness error in the enhanced image. Whereas, entropy, as a no-reference metrics, measures the richness in the content of the information. It is the full reference technique to assess the quality of image. Typically, high score of entropy and PSNR and low value of AMBE represents the better quality of image. In reference to the experiments conducted on 200 images of BSDS500 dataset, the 20 images with distortion in contrast is chosen for fair comparison with other relevant techniques.
Even though the AMBE is independent of the noise content, but measures the mean brightness content in reference to the original image. The Fig. 10 demonstrated the comparison of proposed technique with other algorithms published in peer reviewed journals. The brightness preserving dynamic (BPDHE) [3] and median-mean based clipped HE (MMSIC) [6]are the state-of-art techniques in modified HE. Whereas, adaptive gamma weighted distribution (AGCWD) [11] and gradient based image enhancement (IM) [29] are one of the technique referred in most of the published journals. For the proposed method, the minimum AMBE is found to be 0.099 (as shown in inset) in comparison to other methods. The average value of 20 images computed is 2.36, which was far better as compared to MMSIC (8.81), BPDHE (6.11), AGCWD (48.7), and IM (107.34).   As stated previously, AMBE is not a good measure of noise content in the information. Hence, the PSNR was computed to show, that with the low value of AMBE, the noise suppression in the enhanced image is appreciably achieved. The Fig. 11 showed the comparison of different methods with our method. From table I, the average value of AGCWD and BPDHE for PSNR computed was 12.31 and 17.03. For lower value of AMBE in BPDHE, the PSNR is found to be poor and as well in the case of AGCWD. The value of 21.97 showed a marginal improvement in PSNR with a very high value of AMBE. But, in case of MMSIC, the value of 28.04 dB was noticed for a low value of AMBE. In our proposed work, both PSNR of 28.493 and AMBE of 2.36 had effectively improved the quality of image.
The entropy is a quantitative analysis to measure the content of information in the image. With low value of entropy, lesser will be the content in the information. For the average original entropy of 7.39, the entropy (Fig. 12)  It might be concluded form Table I, even though with marginal increase in PSNR (as compared to MMSIC), considerable change in AMBE and entropy could be observed. Without the loss of information, and with preserved mean brightness, the proposed method proved to be effective in restoration of contrast distorted images. The Fig. 14 showed the enhanced images obtained from proposed method for the middle-left, narrow, spread, and middle-right of the intensity scale. Also, the median based absolute deviation had been shown in reference to the input image. It is visually evident that the enhanced image showed the wide-spread over the entire intensity scale.
The images shown in Fig. 14 is chosen to show, that even for considerable distribution of pixels (boat), the efficacy of the proposed method is proved. From the histogram, it is evident that no peaks could be noticed at the extreme right and (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 12, No. 10, 2021 202 | P a g e www.ijacsa.thesai.org left of the intensity scale. Such pattern indicated no loss of information and under -exposure is found. Moreover, colors in the images did not get overlapped and hence saturation effects is negligible.

C. Comparison with Enhancement Algorithms
In our experiments, hue and saturation is not altered and intensity is enhanced for the better quality of image. Like HE, our approach was also focused to spread the intensity values. With reference to the Fig. 13, for the narrow intensity scale (refer Fig. 1) where most of the information lies in the right half had produced widespread scale value with uniform brightness and contrast. In comparison to Fig. 2 (over enhancement) and Fig. 3 (over saturated colors), the shift of the peaks over the entire region could be observed in Fig. 13. It is attained by adjusting the gamma correction as stated in Eq. 5. The enhanced image produced improved contrast while preserving the mean brightness (in comparison to original image). From the aspect of quality metrics, table II (in reference to the Fig. 1) showed the comparison of different methods with the proposed technique. Except edge based contrast measure, the technique proved to be overall effective in better quality of the image.
The Fig. 15, showed the enhanced image for stat of the art techniques, used for comparison. For the cougar, except IM, the other methods showed the flatness (BPDHE) and over brightness (AGCWD) in the image. The median based absolute deviation is also stated at every histogram of images. It is the robust measure to estimate the distance of intensity value from the referred image. In our case, the referral image is the original and is compared with the enhanced image. With reference to parachute, narrow spread of intensity scale is noticed in comparison to the proposed technique. In case of MMSIC, color disorientation is observed. For the uniform spread of intensity scale in the boat, over brightness was the major limitation of the AGCWD. Further, visual quality of method showed the over enhancement and color disorientation in the final image. In case of deer, all the methods showed the inconsistency in the spread of intensity values. The overbrightness in AGCWD, low contrast in BPDHE, oversaturation in IM and MMSIC, had adversely affected the detail and edges of the image. With fine details and pleasing quality of the image, the proposed technique effectively enhanced the image. For all the images, the quality metrics shown in table III, proved the efficacy of the approach used in the proposed method.      Lastly, the images with back, side, and front lighting is compared with the method proposed by Liyun Zhuang and Yepeng Guan [14]. The root mean square (RMS) and the entropy of the image was calculated with the same relation prescribed in Sec. 3.3.2 and 3.3.3 of the work referred in [14]. The comparative results as shown in table IV, showed the better quantitative analysis. However, in each image the entropy was more as compared to our method. But, due to over-enhancement (in reference to Fig. 9,10, and 14 of Log-Exp [14]) presented the over saturation of colors. In our proposed method, neither the detailed information was lost (as compared to input image) and, moreover, the rms value computed is found to be better than published work.
The entropy of the input image shown in Fig. 16 is 7.28, 7.20, and 7.50. From the proposed method, the brightness is preserved for improved visual quality of the image. Also, the proposed method was compared with the method proposed by Rao B [30] using CEED 2016 [27] dataset. The comparative images based on visual quality as shown in Fig. 17. The Fig.  17 (a,d and g) is the original image, (b,e, and h) is the enhanced image obtained from proposed method and (c,f and i) is the resultant image from [30].
In comparison to original image, Fig. 17 (c) showed the clipping of histogram at the extreme right of the intensity scale. It indicated the loss of detail information in the image. Whereas in Fig. 17 (b), detail had been well preserved in the proposed method. From fig. 17 (f), the pixel distribution is moved to right of the intensity scale. But in Fig. 17 (e), uniform distribution of pixel is observed.
As compared to dynamic HE [30], the enhanced images had shown spread of intensity scale with an average mean brightness error at 1.89. Similarly, the value of average PSNR is computed to be 27.39. Moreover, the optimal obtained is found to be better as compared to the final image obtained by [30]. In that case, over brightness had decreased the contrast ratio in the enhanced image. In our proposed method, mean brightness is preserved for considerable change in the contrast. Lastly, it might be concluded that the objective of uniform distribution of pixel over the intensity scale, preserving mean brightness and improving the contrast had successfully achieved through the proposed algorithm. Form Fig. 13, 14, and 17 (b), (e), and (h), it is clear that enhanced images showed the bell shaped and widespread of pixel values along the intensity scale. The bell shaped distribution represents, that most of the pixel existed at mid-tone values and therefore, minimum pixel distribution at extreme right/left of the histogram. Such representation of graph, is termed to have a better contrast with low under/over-exposure effects of illumination. Hence, with minimum AMBE and good PSNR, the approach in our method had appreciably improved the visual quality of the image.

V. CONCLUSION AND FUTURE SCOPE
An adaptive procedure for preservation of mean brightness with improved contrast had been proposed. The alternate and improved use of gamma correction was presented for various low contrast images. The dataset of 200 images from Berkeley BSDS 500 was analyzed for qualitative results. Moreover, some random images from dataset of CEED 2016 was used for different conditions of lightning in the image. Form the conclusive results for 200 set of images shown in table V, demonstrated that with improved PSNR and minimum error in brightness, proved the effectiveness of the technique used for contrast distorted images. The measure of information as described by Shannon theory, maximum is the value higher will be the content of information. Hence, the information content is found to be maximum in comparison to other method. The edge based contrast in AGCWD was maximum at the cost of over-brightness as shown in Fig. 15. It is found in our proposed method, that overall quality of the enhanced image had preserved the mean brightness and improved the contrast in the image. The over saturation of colors was also balanced with the use of bilateral filtering.
The objective of our work was to maintain the gamma scale value less than "1". Even though the visual quality is better in Fig. 17 (b), but the considerable number of pixels could be seen in the right of the intensity scale. That causes the over-exposure of brightness. So, in the future work, thresholding based gamma correction might be implemented in such images to avoid the over exposure effect. Also, for the dark images, the value of scale parameter less than "1.5" could not produce desirable visual quality in the images. Hence, the work would be extended to deal with dark intensity scale values.

ACKNOWLEDGMENT
We acknowledge the IKG Punjab Technical University, Kapurthala, Punjab, India and DAV Institute of Engineering & Technology, Jalandhar, and Punjab, India for providing valuable resources and necessary tools for the successful implementation of the work.