1 Introduction

In the last decade respiratory diseases are the leading cause of death in the world. The lung disease prevents the lungs from working properly, which causes major morbidity, mortality and due to long duration of treatment, it also causes economic burden. The most common forms of lung diseases include asthma, Chronic Obstructive Pulmonary Disease (COPD), pneumonia, tuberculosis and corona virus disease the cause of the last Pandemic. The death caused by only Corona Virus Disease (COVID-19) is around 65 million people worldwide [1]. It is observed that chances of spreading of infectious diseases like COVID-19, in the community are decreased with early detection and identification of the affected person. Also, early and accurate diagnosis of lung disease helps in better treatment with increasing mortality. Hence an affordable and approachable diagnosis system is needed for early detection. The X-ray imaging system is one such diagnostic system which is economical and ubiquitously available.

Radiography images like Chest X-Ray (CXR) or computer tomography (CT) are a routine technique for the diagnosis of lung-related diseases such as pneumonia [2], and tuberculosis [3], lung-cancer etc. CXR image were commonly used for the preliminary detection of large number of COVID-19 [4] patients. A CXR is an imaging test that uses X-rays to look at the structures and organs in the chest. The advantage of X-ray imaging system over a computer tomography (CT) is that it can be used instantly in case of emergency and it is ubiquitously available.

The CXR image does not require highly skilled qualified technician and special infrastructure. Another benefit is, CXR images are less harmful to the human body, so can also be used for pregnant women and infants [5, 6]. Hence, Chest X-ray imaging system is a potential diagnosis system used for early detection of lung diseases, with the help of clinical data [7]. But the limitation of the CXR is poor quality of images obtained due to its acquiring environment and dependency on the proficiency of the technician. Hence for accurate diagnosis preprocessing of the CXR image such as contrast enhancement is essential.

There is a large difference of the densities in the lung and other structures in the chest, so the chest x-ray image behaves as a wide-range intensity distribution, which makes it difficult to investigate the focus. Also, different lung disease causes spatial different variation in contrast and brightness of CXR image. Image enhancement for chest radiograph is performed to improve the visualization of tissues and structures by optimizing parameters, like contrast, brightness, spatial resolution, and noise level, to detect various diseases present in the chest [8].

Commonly used contrast enhancement method is Histogram Equalization (HE), but with application of HE some regions of X-Ray image become saturated [9, 10]. To avoid it, Contrast Limited Adaptive Histogram Equalization (CLAHE) [11] was developed but HE and CLAHE methods operate on source pixels with linear operations. Another image enhancement technique is Morphological Enhancement (ME) operation which improves the contrast of the x-ray images [12]. But the efficiency of morphological operators depends upon the values of infimum and supremum and the order of sequences in the chosen vector space, which varies with the type and quality of the image. Further improvement in contrast enhancement of images is achieved by using non-linear operation on pixels of source image as gamma correction [13]. This method has a limitation that the values of gamma parameter and constants are dependent on intensity of input image pixels. Thus in the present paper, an adaptive gamma correction method for contrast improvement of chest x-ray images is proposed. In this paper Chest X-Ray (CXR) images are first categorized into four classes depending upon contrast and average intensity of the image and accordingly adaptive gamma correction is applied.

The paper presents a brief review on existing CXR image enhancement methods in Section 2. The detailed proposed methodology of classification of images into four categories as low and high contrast images with bright and dark average intensity value and calculation of the adaptive value of \(\gamma\) for contrast enhancement is described in Section 3. The proposed method is tested on four datasets Chest X-Ray Images (Pneumonia) dataset [14], Tuberculosis (TB)_Chest_Radiography_Database [15], COVID-QU-Ex Dataset [16], and NIH Clinical Center chest X-ray [17]. The results of the proposed method are compared for five type of lung diseases with existing methods in Section 4, which shows significant improvement in contrast enhancement in CXR images. Section 5 presents conclusion and future scope.

2 Image enhancement techniques

A quick and efficient method for image enhancement is improving its contrast. Histogram Equalization (HE) is simplest and fastest contrast enhancement method [10]. HE evenly disperses the input histogram intensity levels across the whole range. However, HE has adverse side effects such as over enhancement, intensity saturation effect etc. Regardless of the pixel variation of the original image, HE changes the mean brightness of the image. To limit the problems of over-enhancement, Brightness Preserving Bi-Histogram Equalization (BBHE) [18] and Dualistic Sub-Image Histogram Equalization (DSIHE) [19] have been proposed, which splits the histogram before performing the HE. BBHE decomposes the histogram based on the mean intensity while DSIHE uses equal area based on probability density function (PDF) approach to decompose the intensities of the image. A more advanced HE variation is known as Adaptive Histogram Equalization (AHE). AHE applies histogram equalization to a small region of the image, and thus, enhancing the contrast of each region individually. Therefore, it increases local contrast and edges adaptively in each region of the image based on the local distribution of pixel intensities rather than the global information of the image. However, AHE also over amplifies, noise component in the image [20]. The images enhanced with Contrast Limited Adaptive Histogram Equalization (CLAHE) appear more realistic than images enhanced with HE, CLAHE uses the same approach as AHE but the amount of contrast enhancement that can be produced within the chosen region is limited by a threshold value [11].

Other method used to enhance the contrast of the x-ray images is Morphological Enhancement (ME). It is based on the set theory. Sets in mathematical morphology represent objects in an image [21]. The contrast enhancement of morphological features in medical images are achieved by extracting the target feature with morphological operations, by adjusting the size and shape of structuring elements (SE) and enhance the contrast of extracted features by histogram equalization followed by linear contrast stretching technique [22]. Morphological transform top-hat and bottom hat are used to enhance the contrast of medical images. A disk shaped structuring element mask, which is unaffected by rotation effect, is applied for image enhancement by using an iterative exfoliation process based on contrast improvement ratio [11]. But this method is unsuitable for poor quality medical images or images with large contrast variation. A morphological top-hat, bottom-hat based method which selects the size of SE automatically has been proposed in [23]. The morphological erosion and dilation operation are better for the region where there is large intensity variation i.e. edges in medical images but they are unable to filter noise. While the opening and closing operations are better for noise filtering but as they utilize the complementarily of erosion and dilation, the result of processed image is only correlative of image.

Gamma correction technique enhances image quality through contrast adjustment while maintaining mean brightness. However, the performance of image enhancement is affected by the selection of gamma parameter which is time-consuming and dependent upon technical skill of the operator. An Adaptive Gamma Correction with Weighting Distribution (AGCWD) for image enhancement by varying the gamma value in relation to the cumulative density function (CDF) generated from the input image [24]. However, such AGC methods are generally unsuitable for improvement of the contrast of low light images, because its brightness is over-enhanced, causing the loss of certain significant aspects and leaving the produced images unsatisfactory. An Adaptive Gamma Correction (AGC) approach is proposed [25], in which the suitable gamma value is determined automatically based on the statistics retrieved from images. In this paper the contrast of the CXR images is enhanced by the Adaptive Gamma Correction [26], where the value of gamma is selected automatically by changing it with the help of image average intensity and its intensity variation across the mean of image.

3 Proposed methodology

The CXR images are generally used for preliminary investigation as it is approachable and affordable. But it has wide variation in contrast ratio and diverse intensity distribution, due to variation in acquisition environment and skill of the technician. It is therefore essential to enhance CXR images for accurate diagnosis of lung disease at its early stage. The aim of the proposed technique is to efficiently produce a contrast enhanced CXR image using adaptive gamma correction. The value of gamma is automatically calculated depending upon statistical parameters of acquired CXR image. In the proposed method, images are first classified into four classes, depending upon its characteristics and then accordingly, different intensity transformation functions are used for different class of image. The detail of proposed method is explained with the help of flowchart shown in Fig. 1 and the details of each steps of the method are discussed in the following subsection:

Fig. 1
figure 1

Flowchart of proposed Adaptive Image Enhancement method

3.1 Image classification

The CXR images have large variations in intensity distribution and contrast ratio thus requiring the classification of images into different classes before applying enhancement techniques. In the proposed method images are classified into four different classes depending upon their contrast and brightness. A CXR image first classifies into Low-Contrast (LC) or High-Contrast (HC) depending on the contrast of the CXR.

As per the Chebyshev’s inequality, the probability that a scalar random variable \(X\) with distribution \(P\) differs from its mean \((\mu \in R)\) by more than \(\lambda \in {R}_{>0}\) and standard deviation \((\sigma \in {R}_{>0})\) fulfill the relation [27]

$$P\left(\left|X-\mu \right|\ge \lambda \sigma \right)\le min\left\{1,\frac{1}{{\lambda }^{2}}\right\}$$
(1)

Where, \(\lambda\) is any positive real value.

Thus using Chebyshev’s inequality Eq. (1), in the proposed method, when the \(75\%\) of intensity distribution (T) of input CXR image h(I) is more than the threshold \(\left(1/\tau \right)\) about the mean than input CXR image is classified as High Contrast otherwise it is Low Contrast image. T is defined as \((T=diff\left(\left(\mu +2\sigma \right),\left(\mu -2\sigma \right)=4\sigma \right)\),

Hence,

$$h\left(I\right)=\left\{\begin{array}{c}HC,\\ LC,\end{array}\right.\begin{array}{c}T>1/\tau \\ {\mathrm{o}}{\mathrm{t}}{\mathrm{h}}{\mathrm{e}}{\mathrm{r}}{\mathrm{w}}{\mathrm{i}}{\mathrm{s}}{\mathrm{e}}\end{array}$$
(2)

Thus if the value of four times of standard deviation (\(\sigma\)) is less than the value of \(1/\tau\), \(\left(4\sigma >1/\tau \right)\), then CXR image be classified as high-contrast image, otherwise it will be a low-contrast image.

After analyzing CXR images for different lung diseases, with different intensity distribution pattern, it is determined that \(\tau =1.125\) is a good approximation for CXR images according to their contrast into HC and LC.

Further, the CXR images are classified accordingly to its average brightness i.e. mean intensity (\(\mu\)) value. If the value of \(\mu\) is less than \(0.5\), the image will be a Dark Image (DI) otherwise it will be a Bright Image (BI).

Hence in the proposed method the four classes of images are Low Contrast-Dark Image (LC-DI), Low Contrast-Bright Image (LC-BI), High Contrast-Dark Image (HC-DI) and High Contrast-Bright Image (HC-BI). Details for determining Adaptive Gamma Correction for LC image is explained in Section 3.2 and Adaptive Gamma Correction for HC image is explained in Section 3.3.

3.2 Contrast enhancement using adaptive gamma correction for LC image

The Power-Law gamma correction improves contrast of the image by mapping narrow range of intensity values into wider range. The basic equation for gamma correction is given as [21]

$${I}_{\mathrm{out}}={{cI}_{\mathrm{in}}}^{\gamma }$$
(3)

Where Iin is the intensity value of pixel of input image h(I) and Iout is output pixel value obtained after applying transformation. In Eq. (3), \(c\) is a parameter, which gives the brightness variation of output images, and value of \(\gamma\) is used for contrast manipulation.

In the proposed method, for making the contrast enhancement adaptive the valve of \(c\) and \(\gamma\) vary according to the statistical parameter of the input CXR image. In the LC image the value of \(\sigma\) is small and the image intensity values are very close to each other. For enhancement of the contrast of this class of CXR image, the input pixel values are modified from narrow range of intensities to wider range of intensity distribution. In gamma correction, \(\gamma\) is the parameter which is responsible for the slope of the transformation function. The transformation curve will be steeper for high \(\gamma\) value. The steeper the curve is, the more evenly the respective intensities are spread, resulting in a greater increase in contrast. It can be easily achieved in the proposed AGC for LC images by selecting the value of \(\gamma\) as

$$\gamma =-{log}_{2}\left(\sigma \right)$$
(4)

In Fig. 2 variation of \(\gamma\) with respect to \(\sigma\), using the Eq. (4) and Eq. 9 is plotted. This exhibits a decreasing curve for LC. As in LC class the value of \(\sigma\) is small, it gives a large \(\gamma\), it will insure a significant increase in contrast by dispersing the compact bright intensities to a broader intensity values. This can be ensured by Lemma \(1\).

Fig. 2
figure 2

Gamma values for different standard deviation in low contrast and high contrast

Lemma 1

For Low contrast CXR images, \(\gamma\) remains greater than \(1\).

Proof

In LC CXR images, the minimum value of \(\upgamma\) in AGC will be.

$${\gamma }_{{\mathrm{min}}}=-{log}_{2}\left({\sigma }_{{\mathrm{max}}}\right)=-{log}_{2}\left(1/4\tau \right)$$

For selection of, \(\tau =1.125,{\gamma }_{{\mathrm{min}}}=-{log}_{2}\left(0.222\right)=2.17>1\).

In the proposed method besides contrast, the brightness of the image pixel is also modified by varying parameter \(c\) as required. The parameter \(c\) is defined in Eq. (5), it is made adaptive with an objective to preserve the characteristics of bright images and improve the brightness of dark images. The bright images have \(\mu >0.5\) and the dark images have \(\mu <=0.5\).

$$c=\frac{1}{1+{\mathrm{Heaviside}}\left(0.5-\mu \right)\times \left(k-1\right)}$$
(5)

Where \(k\) is defined as,

$$k={{I}_{\mathrm{in}}}^{\gamma }+\left(1-{{I}_{\mathrm{in}}}^{\gamma }\right)\times {\mu }^{\gamma }$$
(6)

The Heaviside function is given by

$$Heaviside\left(x\right)=\left\{\begin{array}{c}1, x>0\\ 0, x\le 0\end{array}\right.$$

The effectiveness of the proposed transformation function is described in the following subsections for bright and dark LC images.

3.2.1 Bright images in LC

The main objective for enhancement of LC bright images (LC-BI) \(\left(\mu >0.5\right)\) is to only increase the contrast for improved detailed information in the image. Hence, in proposed AGC, from Eq. (5), the value of Heaviside transform will become zero and thus \(c\) will be \(1\) for preserving the brightness and the resultant intensity transformation function will be

$${I}_{\mathrm{out}}={{I}_{\mathrm{in}}}^{\gamma }$$
(7)

Figure 3 shows the transformation effects for LC-BI CXR images for five different diseases. Here the slope depends on the value of \(\sigma\). The low value of \(\sigma\) results in high spreads of intensities, which is producing a sufficient increment of contrast. In support of this the histogram of the LC-BI class of image before and after the enhancement has been shown in Fig. 4(a), (b). The histogram is compact in the right side and most of image intensity are lies in between 0.6 to 0.8 Fig. 4(a), whereas after the transformation applied on the image in Fig. 4(b), the intensity spread from 0.4 to 0.8. It will result in a sufficient contrast improvement in the original image.

Fig. 3
figure 3

Image transformation curve for LC-BI for 5 types of lung diseases

Fig. 4
figure 4

Histogram of LC-BI image before and after transformation

3.2.2 Dark images in LC

In LC dark CXR image \(\left(\mu \le 0.5\right)\), intensity distribution is compact around mean at higher gray levels. To increase the contrast of such CXR images a transformation curve which can spread the dark intensity to high intensity is required. This is needed a transformation function that can spread the compact intensity more than the other intensities. To achieve this, Eqs. (3), (5) and (6) are used and the transformation function becomes

$${I}_{\mathrm{out}}={\frac{{I}_{\mathrm{in}}}{k}}^{\gamma }=\frac{{{I}_{{\mathrm{i}}{\mathrm{n}}}}^{\gamma }}{{{I}_{\mathrm{in}}}^{\gamma }+\left(1-{{I}_{\mathrm{in}}}^{\gamma }\right)\times {\mu }^{\gamma }}$$
(8)

Figure 5 shows the transformation curve for LC-DI using the proposed AGC equation. Here most of the portion of the curve lies above the line Iout = Iin. For the low contrast image the curve is steeper, it will spread the dark intensity value more efficiently, as required. In this class of image most of the intensities comes around the mean value and as the output intensity is dependent upon the \(\mu\) value. From the above equation it is ensured that output intensity varies with \(\mu\) value and thus the contrast of this class of image is enhanced evenly. The histogram variation of the LC-DI class image before and after applying the correction with the proposed method are shown in Fig. 6(a) and (b). Here in this figure variation of intensity in the original image is between 0 to 0.4 which is very limited range whereas after the proposed method applied on the image the variation of the intensities are expanded up to 0.8 and also the higher frequency intensity also shifted in the centre, so by applying the proposed model this class of image achieved a satisfactory result.

Fig. 5
figure 5

Image transformation curve for LC-DI for 5 types of lung diseases

Fig. 6
figure 6

Histogram of LC-DI image before and after transformation. a Original LC-DI. b Proposed LC-DI

3.3 Contrast enhancement using adaptive gamma correction for HC image

When the intensities in a CXR image are evenly distributed across the available dynamic range, it is classified as high contrast image. In such images, brightness improvement is generally more significant than contrast enhancement. Hence the calculation of intensity transformation and the value of \(c\) for proposed method is performed by Eqs. (3) and (5), respectively. For this class of image the value of \(\gamma\) is calculated with Eq. (9) assured that there will be little change in the contrast.

$$\gamma =exp\left[\left(1-\left(\mu +\sigma \right)\right)/2\right]$$
(9)

Lemma 2 validates that the range of \(\gamma\) is small, as desired, and ensures that there is little variation in contrast. This condition is shown as HC curve in Fig. 2.

Lemma 2

For high-contrast images, \(\gamma \in [ 0.90, 1.65].\)

Proof

For the minimum value of \(\gamma\), the value of \(\left(\mu +\sigma \right)\) should be maximum and the maximum possible value of \(\left(\mu +\sigma \right)\) is \(max\left(\mu +\sqrt{\mu -{\mu }^{2}}\right)\) since for \(x\in \left[0, 1\right]\), we have \({\sigma }^{2}\le \mu - {\mu }^{2}\). Thus, the maximum of \(\left(\mu +\sigma \right)\) is \(\frac{1}{2}+\frac{1}{\sqrt{2}}=1.2071\). This gives the minimum value of \(\gamma\) is \(\gamma ={\mathrm{exp}}\left(\frac{\left(\frac{1}{2}-\frac{1}{\sqrt{2}}\right)}{2}\right)=0.9016278\). Hence, \(0.9016278\le \gamma \le \sqrt{e} = 1.64872\).

The impact of \(\gamma\) on the dark and bright HC images is described in the following sub section.

3.3.1 Dark images in HC

The CXR images for which \(\mu \le 0.5\) and \(\left(\mu +\sigma \right)\le 1\), the values of \(\mu\) and \(\sigma\) are either 0.5 or less than 0.5, so from Eq. (9) \(\gamma \ge 1\).

Figure 7 presents the transformation curve for different lung diseases CXR HC-DI. The curves between Iin and Iout are above the linear curve \({I}_{out}={I}_{in}\). This transformation is changing the average dark pixels to bright pixels. Thus it improves the visibility of dark images. As shown the Fig. 8(a) the histogram of the original image of the HC-DI class is shifted to the right side after applying the proposed transformation Fig. 8(b), which is required.

Fig. 7
figure 7

Image transformation curve for HC-DI for 5 types of lung diseases

Fig. 8
figure 8

Histogram of HC-DI image before and after transformation. a Original HC-DI. b Proposed HC-DI

3.3.2 Bright images in HC

In this class of image the main objective is to preserve the brightness intensity of the image. Using Eqs. (3), (4), and (6), Iout, c, and γ are calculated. Figure 9 shows the transformation curves for HC-BI. As the curve is very near to the straight line Iout = Iin, so there will be very minute changes in contrast of the CXR images of this class and it ensure preserving of intensity, as required. Figure 10(a) is the histogram of the original HC-BI image and Fig. 10(b) is the histogram after applying the proposed transformation method at the image. In the original HC-BI histogram the intensity is mostly populated at the higher value of image intensity and after the proposed transformation the transformed intensity also have the higher value of intensity. Although the curve shifted with a very minute in the left whereas it is preserving the original characteristic of the image of this class.

Fig. 9
figure 9

Image transformation curve for HC-BI for 5 types of lung diseases

Fig. 10
figure 10

Histogram of HC-BI image before and after transformation. a Original HC-BI. b Proposed HC-BI

4 Experimental results

The proposed method classifies CXR images into four categories before enhancing its contrast. The performance of proposed method is evaluated on four datasets for five different types of diseases. Different diseases alter the intensities of CXR image differently; hence they need appropriate contrast enhancement techniques. The qualitative analysis and quantitative evaluation of the proposed method is done with other state-of-art methods, namely HE [10], CLAHE [11], morphological image enhancement [11] and conventional Gamma Correction [13].

4.1 Dataset description

The standard dataset for CXR images with different diseases used by researchers are Chest X-Ray Images (Pneumonia) dataset [14], Tuberculosis (TB)_Chest_Radiography_Database [15], COVID-QU-Ex Dataset [16], and NIH Clinical Center chest X-ray [17]. The same dataset is used for comparison of performance of proposed method for qualitative and quantitative evaluation. Chest X-Ray Images (Pneumonia) dataset offers 3875 images of Pneumonia as a training package, Tuberculosis (TB)_Chest_Radiography_Database offers 700 images of Tuberculosis disease and COVID-QU-Ex Dataset offers 1864 images of COVID-19 in infection segmentation data of training package. In NIH Clinical Center chest X-ray dataset there is BBox_list_2017 where they have classified many diseases. Among this list two class of diseases are chosen namely Atelectasis which has 180 images and Lung mass having 86 images for evaluation of performance of proposed method.

4.2 Qualitative assessment

The performance of proposed method is evaluated on a set of 80 representative images from each class of image (LC-DI, LC-BI, HC-DI and HC-BI) for each disease. Quality assessment of proposed method with existing methods is shown in Fig. 11. It shows comparison of contrast enhanced images obtained from proposed method and existing methods, for five different diseases in different classes of image. Figure 11(a) shows comparison for LC Dark CXR image (in scale of 255, \(D=198.98\), \(\mu =106.47\)) for Pneumonia disease. Figure 11(b) shows comparison for LC Bright CXR image (in scale of 255, \(D=150.92\), \(\mu =156.82\)) for Tuberculosis disease. Figure 11(c), shows comparison for HC Dark CXR image (in scale of 255, \(D=206.72\), \(\mu =95.62\)), for COVID-19 disease. Figure 11(d) and (e), shows HC Bright CXR images taken from NIH Clinical Center Chest X-ray dataset for diseases Atelectasis and Lung mass (in scale of 255, Atelectasis \(D=256.21\), \(\mu =132.94\), Lung Mass \(D=265.05\), \(\mu =162.32\)). In image class of LC-DI, LC-BI and HC-BI CXR images, HE method over-enhanced the images resulting in loss of information as shown the image pixels are too bright, and CLACHE method created unwanted artifacts in the image however these methods are able to satisfactorily classify the infected region only in HC Dark CXR images. The morphological enhancement increased the overall contrast of the original image and created some dark pixels making parts of the processed image opaque and difficult to determine the finer details.

Fig. 11
figure 11

Contrast Enhancement by different methods on four classes images for five lung diseases (a) Pneumonia (b) Tuberculosis (c) COVID-19 (d) Atelectasis (e) Lung Mass

Gamma correction is not showing significant improvement from the original image in class of LC-DI, LC-BI and HC-DI CXR images, with this method only improvement is observed in HC-BI. While with the proposed method, contrasts of the images of all classes are enhanced satisfactorily without creating any artifacts.

4.3 Quantitative assessment

Enhancement of an image is a subjective parameter, hence quantification of improvement achieved is essential for comparison. The evaluation parameters generally used by the researchers, to evaluate the achieved contrast enhancement are Root Mean Square (RMS) Contrast, Contrast Improvement Index (CII) and Tenengrad.

These parameters are calculated for 80 images taken from the four datasets, discussed in Section 4.1 for each type of disease, for exiting methods HE, CLAHE, Morphological enhancement, Gamma correction and proposed adaptive gamma correction methods.

4.3.1 Root mean square contrast

The contrast of an image independent of spatial variation is calculated by RMS Contrast [28]. The RMS Contrast function is defined by Eq. (10). A large value of RMS Contrast shows better image contrast.

$${\mathrm{RMSC}}=\sqrt{\frac{1}{pq}{\sum }_{i=0}^{p-1}{\sum }_{j=0}^{q-1}{\left(\mu -{I}_{ij}\right)}^{2}}$$
(10)

Table 1 shows the RMSC obtained for CXR images affected by five types of diseases for the respective class of image i.e. Low/High contrast and Dark/Bright image. In Table 1 it is observed that the proposed method gives better RMSC compared to other existing methods. The average improvement in RMSC is more for Dark Intensity images, 25.14% and 27.65% for Low Contrast (LC-DI) and High Contrast Dark Images (HC-DI) while 19.05% and 11.9% for Low Contrast (LC-BI) and High Contrast Bright Images (HC-BI). This explains that irrespective of quality of acquired image or type of spatial variation of intensity due to different diseases, the proposed algorithm successfully enhances images maintaining the correlation between original and enhanced images.

Table 1 Root Mean Square Contrast comparison of AGC with existing method

4.3.2 Contrast Improvement Index (CII)

CII is the valuable benchmark, for comparing the performance of the image enhancement technique [29]. It is used to measure enhancement in local contrast of output image with respect to input image and represented by Eq. (11).

$$CII=\frac{{C}_{\mathrm{proposed}}}{{C}_{\mathrm{actual}}}$$
(11)

Where, C is the average value of the local contrast measured with 3 × 3 window. Cproposed and Cactual are the average values of the local contrast in the output and original image, respectively. If the value of the CII increases, then it shows improvement in contrast of an image. Table 2 shows the CII value of processed images for different classes of images and five types of diseases. Although the proposed method gives larger CII values for most of the image class but it is having low value in case of COVID-19 for dark image of each class, pneumonia for bright image of both class and lung mass for high contrast image. However the overall performance of the proposed method is better compared to the other existing methods.

Table 2 CII comparison of AGC with existing method

4.3.3 Tenengrad

Tenengrad (TGD) is based on the maximization of gradient magnitude [29]. It depends on the value of intensity of images and every image has different intensity so the values of Tenengrad vary accordingly. Since, it is based on gradient magnitude maximization so it is considered to be a very precise and powerful image quality parameter. To calculate the value of Tenengrad of an image h(I) calculate the gradient Δh(x, y) first where Δh(x, y) represent the partial derivative of h(I) with respect to x and y. The partial derivatives are calculated using a sobel filter having convolution kernels hx and hy. The gradient magnitude is calculated using Eq. (12) and the Tenengrad is measured using Eq. (13). The comparison of the Tenengrad for proposed AGC with the existing methods is shown in Table 3.

Table 3 Tenengrad comparison of AGC with existing method
$$T\left(x,y\right)=\sqrt{{\left({\left({h}_{x}\times {h}_{\left(x,y\right)}\right)}^{2}+{\left({h}_{y}\times {h}_{\left(x,y\right)}\right)}^{2}\right)}^{2}}$$
(12)
$$TGD={\sum }_{x}{\sum }_{y}T{\left(x,y\right)}^{2}$$
(13)

In Table 3 HE, CLAHE and ME methods show a much higher value of Tenengrad as compared to the original image. This is because of over-enhancement due to histogram equalization and the presence of artifacts due to CLAHE and ME. The GC method has having low value of Tenengrad compared to the original image, hence it is not able to enhance the contrast of the image satisfactorily. The proposed method shows sufficient improvement in Tenengrad to the original image of each class, except for the pneumonia disease of the HC-DI class. This method confirms that the proposed method preserves the image structural information significantly and produces a good quality of contrast enhanced image.

5 Conclusion

The lung diseases introduce abrupt fine spatial variations in intensity and affects brightness of CXR image non-uniformly. Also, acquisition environment affects the quality of CXR images. Hence, a contrast enhancement method with uniform parameters for different quality of image cannot give satisfactory results for all types of images. In the proposed method, images are classified prior to applying enhancement technique and later, adaptive value of gamma correction based on statistical parameter of image such as average brightness of image and variation of intensity about its mean, is applied. The proposed method of adaptive gamma correction is evaluated on four datasets of CXR images on five types of lung diseases (Pneumonia, Tuberculosis, COVID-19, Atelectasis and Lung mass), affecting intensity variation differently.

The qualitative analysis of images obtained with the proposed method and existing methods HE, CLAHE, ME and gamma correction shows that HE and ME over enhances the image and CLAHE introduces artifacts, while gamma correction does not show any significant improvement. The quantitative performance of the proposed adaptive gamma correction method is compared with the existing methods, on the basis of RMSC, CII and Tenengrad. These contrast measuring parameters also support the qualitative assessment of resultant images obtained with different methods.

The proposed method has performed satisfactorily in most of the lung diseases, for all types of image quality. This shows its stable and satisfactory performance as compared to existing methods. The improved quality of lung images will further support in accurate segmentation of diseased lung portions and better clinical decisions.