# Fast COVID-19 Detection from Chest X-Ray Images Using DCT Compression

Authors: Fatma Taher; Reem T. Haweel; Usama M. H. Al Bastaki; Eman Abdelwahed; Tariq Rehman; Tarek I. Haweel
Journal: Applied Computational Intelligence and Soft Computing
 (2022)

---

## Abstract

Novel coronavirus (COVID-19) is a new strain of coronavirus, first identified in a cluster with pneumonia symptoms caused by SARS-CoV-2 virus. It is fast spreading all over the world. Most infected people will develop mild to moderate illness and recover without hospitalization. Currently, real-time quantitative reverse transcription-PCR (rqRT-PCR) is popular for coronavirus detection due to its high specificity, simple quantitative analysis, and higher sensitivity than conventional RT-PCR. Antigen tests are also commonly used. It is very essential for the automatic detection of COVID-19 from publicly available resources. Chest X-ray (CXR) images are used for the classification of COVID-19, normal, and viral pneumonia cases. The CXR images are divided into sub-blocks for finding out the discrete cosine transform (DCT) for every sub-block in this proposed method. In order to produce a compressed version for each CXR image, the DCT energy compaction capability is used. For each image, hardly few spectral DCT components are included as features. The dimension of the final feature vectors is reduced by scanning the compressed images using average pooling windows. In the 3-set classification, a multilayer artificial neural network is used. It is essential to triage non-COVID-19 patients with pneumonia to give out hospital resources efficiently. Higher size feature vectors are used for designing binary classification for COVID-19 and pneumonia. The proposed method achieved an average accuracy of 95% and 94% for the 3-set classification and binary classification, respectively. The proposed method achieves better accuracy than that of the recent state-of-the-art techniques. Also, the time required for the implementation is less.


---

## Body

## 1. Introduction

COVID-19 or coronavirus-infected patients will experience mild to moderate respiratory illness, which may sometimes lead to pneumonia. In order to limit the widespread of the coronavirus, early detection of COVID-19 is important. For detecting COVID-19, polymerase chain reaction (PCR) is the most widely used technique. PCR sensitivity is found to be low [1]. Moreover, PCR is time-consuming and not very accurate [2]. For tracking the pathological signature of COVID-19 on the CXR of suspected patients [3, 4], chest radiography is performed worldwide in diagnosis. Unfortunately, the CXR abnormalities caused by COVID-19 are similar to those of viral pneumonia [5, 6]. In order to detect and differentiate COVID-19 and pneumonia, automation is required.Artificial intelligence, such as machine and deep learning, has been employed to achieve such automation based on CXR [7]. A deep learning approach to detect COVID-19 and viral pneumonia was achieved in Reference [8] implementing ResNet-101 with high accuracy. ResNet-50 architecture along with the SVM classifier also produced good accuracy [9]. Makris et al. [10] employed several convolutional neural network (CNN) models and compared their performances in classifying COVID-19, pneumonia, and normal images [10]. Asif et al. [11] trained InceptionV3 using transfer learning techniques to distinguish COVID-19 from viral pneumonia and normal CXR and obtained a high accuracy. Das et al. [12] have developed an interesting model using ensemble average learning employing three pretrained CNN networks; DenseNet201, Resnet50V2, and InceptionV3 achieved high accuracy and sensitivity. Ridhi et al. [13] classified COVID-19, pneumonia, and normal CXR employing stacked of DenseNet and GoogleNet. Gupta et al. [14] implemented a CNN network termed InstaCovNet-19 integrating several deep networks and achieved high accuracy both in binary (COVID-19 vs. non-COVID-19) and in 3-class (COVID-19, pneumonia, and normal) classifications. Another CNN network was proposed in Reference [15] which achieved high accuracy for binary, 3-class, and 4-class classifications. Canayaz et al. [16] proposed a diagnosis of COVID-19 using deep neural networks and metaheuristic-based feature selection and achieved very high accuracy. Khuzani et al. [17] employed features extracted using the spatial domain (GLCM, GLDM, and texture), spectral-domain (FFT), and spaciospectral-domain (wavelet) transforms fed to a feedforward neural network for a 3-class classification, COVID-19, pneumonia, and normal [17]. It is shown in Reference [17] that features associated with the spectral domain have better prediction power than the other groups (spatial and spaciospectral) regarding COVID-19 prediction from CXR images. It is worth mentioning here that vagueness may be introduced in the CXR images during the sampling techniques and due to transformation from three-dimensional to bi-dimensional images which may require the implementation of fuzzy techniques to enhance both the contrast and edges of the CXR images before classification [18, 19].This work presents a novel efficient method for 3-class classification, COVID-19, normal, and pneumonia. The proposed method employs the energy compaction property of the DCT for a compressed spectral-domain feature extraction. The rest of the paper is organized as follows: Section2 summarizes the essential properties of the DCT. The proposed technique is illustrated in Section 3. A discussion is given in Section 4 to elaborate on the main advantages of the proposed technique over the present state-of-the-art methods. Finally, Section 5 concludes the work.


## 2. Discrete Cosine Transform

The DCT incorporates real sinusoids and has many interesting features. In addition to its orthogonal structure, the DCT has excellent energy concentration properties. Only 10% of the DCT spectral components contain about 90% of the total signal power [20]. Consequently, the DCT is the core of multimedia image and video compression techniques such as Joint Photographic Experts Group (JPEG) and Moving Picture Experts Group (MPEG) compression standards [21]. Moreover, the DCT has good decorrelating properties and may be employed to reduce the inherent high correlation that exists between the rows and columns of images [22]. The elements of matrix T of one-dimensional DCT in the case of N-element input vectors can be defined as follows [21]:(1)Tkn=αkcosπNkn+12.Fork,n=0,1,…,N−1, with αk=1/N for k=0 and αk=2/N otherwise.Another advantage of DCT is its two-dimensional separability. IfX is an input image, then its representation Y in the transform domain of two-dimensional DCT can be calculated as follows [20]:(2)Y=TXTt.Modern image applications partition input images into 8 × 8-pixel blocks. Consequently, 8 × 8 DCT has been given special consideration to provide for approximations that are computationally simple. Since the pioneering work by Haweel [20] that explored a DCT approximation requiring only 24 additions, many other approximations have been introduced in the literature. A comparative study for all effective approximations has been analysed in Reference [22].


## 3. Proposed Technique

### 3.1. Dataset

The employed data set contained the CXR images of COVID-19-positive cases, normal, and viral pneumonia cases. These CXR images were produced at the Rashid Hospital Radiology Department in Dubai in the United Arab Emirates. Balanced sets were selected where each of the three sets contains 600 CXR images. Images are in JPEG format having a dimension of 1024 × 1024 pixels.


### 3.2. Feature Extraction

All images are resized to 256 × 256 grayscale, and every image is scanned by an 8 × 8 mask. The two-dimensional DCT is computed for each masked block using Equation (2). Out of the 64 spectral components, only the highest 8 transform pixels (top left) are retained while all other transformed pixels are discarded. That is, all images have been compressed by a factor of 8. To illustrate the quality of the compressed CXR images, the discarded pixels are zeroed and the masked blocks are transformed back to the spatial domain [20].(3)X^=TtYT.Figure1 shows the original and the compressed reconstructed images for the three cases. The subjective good quality of the compressed images is clear. The percentage error energy norm (PEEN) has been computed as an objective measure for the degradation caused by compression. The PEEN is defined as follows [20]:(4)PEEN=∑m=0M−1∑n=0M−1Im,n−IRm,n2∑m=0M−1∑n=0M−1I2m,n×100,where I (m, n) is the original CXR image and IR (m, n) is the reconstructed (compressed) image.Figure 1
Original and compressed CXR images.Table1 illustrates the PEEN for the three cases which indicates that they are all low and almost equal. Since this slight degradation due to compression is almost the same for the three sets, the effect of compression on the classification stage is negligible.Table 1
PEEN for compressed CXR images.
NormalCOVID-19PneumoniaPEEN3.58453.50333.5066As further evidence for the low impact of the DCT compression on the CHX images, the peak signal-to-noise ratio (PSNR) has been estimated for the three cases. The PSNR is defined as follows [22]:(5)PSNR=10∗∑m=0M−1∑n=0M−1Imax2m,n∑m=0M−1∑n=0M−1Im,n−IRm,n2.Table2 shows the PSNR for the three cases. The retained highest 8 transformed pixels for each 8 × 8 block are concatenated to form one 8-pixel raw, so that the compressed image size is now 32 × 256. A pooling averaging window mask of 4 × 4 is performed for every compressed image twice. At the first run, the average resulting image size is 8 × 64, and after the second run, the size is 2 × 16. The final averaged image is flattened to produce a 32-feature vector for each CXR image in each class. Figure 2 illustrates the feature extraction methodology.Table 2
PSNR for compressed CXR images.
NormalCOVID-19PneumoniaPSNR33.852833.513733.1771Figure 2
Feature extraction steps for the 3-set classification.


### 3.3. Normal, COVID-19, and Pneumonia Classification

A feedforward neural network is employed to classify the three sets as shown in Figure3. The input layer is 32 neurons corresponding to the 32-feature vectors. Two hidden layers with 50 and 20 neurons, respectively, are used. The number of neurons in the hidden layers was optimized for best performance. The output layer has 3 neurons corresponding to the three classified sets. The upper output neuron is on (has a value of 1) if the 32-feature vector corresponds to the normal set, the middle neuron is on for COVID-19 feature vector, and finally, the last output neuron is on for pneumonia feature vector as shown in (6), where O is the output (target) matrix.(6)O=NCP=100010001.Figure 3
Employed multilayer neural network for the 3-set classification.The transfer functions for the neurons connecting the second hidden layer to the output neurons are the log-sigmoid since the swing of the outputs is between zero and one.The Levenberg–Marquardt algorithm has been employed for updating the suggested neural network. Like the quasi-Newton methods, the Levenberg–Marquardt algorithm is designed to approach second-order training speed without having to compute the Hessian matrix [23]. The Hessian matrix, H, can be approximated as follows [23]:(7)H=JtJ,and the gradient can be estimated as follows [23]:(8)g=Jte,where J is the Jacobian matrix that contains the first derivatives of the network errors with respect to the weights and biases and e is a vector of network errors. The Levenberg–Marquardt algorithm uses this approximation to the Hessian matrix in the following Newton-like update to minimize the mean-squared error (MSE) [23]:(9)Xk+1=Xk−JtJ+μI−1Jte,where µ is an adaptation variable. The Levenberg–Marquardt is fast and more accurate near an error minimum where µ is highly reduced near the minimum [24]. The number of input CXR images employed in the training session is 500 images from each class (a total of 15000 images). The MSE learning curve is shown in Figure 4 where the very fast convergence near the minimum MSE is clear. The training algorithm reached an MSE of about −90 dB in 88 epochs only. This target MSE was set a priory to stop the training program as an indication for convergence. Figure 5 shows the variation of µ during the training phase. The start value of µ is 1e − 3 and the final value is 1e − 15. It is also noted that µ has been dramatically reduced near the targeted minimum MSE as expected. Validation tests have been performed to ensure that the employed neural network did not overfit or underfit the input data (features derived from the 3-set CXR images).Figure 4
Learning curve for the 3-set classification neural network.Figure 5
Variation ofµ during the 3-set neural network training phase.The convergent neural network has been tested using 100 images from each class (a total of 300 images). As an indication of the test phase of the proposed technique, five test output vectors corresponding to true positive COVID-19 CXR cases are listed in Table3, which shows almost ones and zeros at the expected positions.Table 3
Outputs for tested true positive COVID-19 CXR cases.
4.9923e − 088.2066e − 112.7338e − 081.0418e − 128.5371e − 111.0000e + 001.0000e + 001.0000e + 001.0000e + 001.0000e + 001.0093e − 073.8957e − 087.3039e − 075.1293e − 101.9430e − 11


### 3.4. COVID-19 and Pneumonia Classification

In many situations, the CXR indicates a suspect subject and the target is to classify the subject either to be a COVID-19 case, needing special care, or just a pneumonia Case [25, 26]. For this reason, a binary classification session has been carried out on the data set of COVID-19 and pneumonia. The second 4 × 4 average pooling block in the 3-set scheme in Figure 2 has been reduced to be 2 × 2 so that the feature vector has 128 samples. This increase in the feature vector is necessary to track the little differences between the CXR images of COVID-19 [27, 28] and pneumonia and to increase the accuracy of the binary classification. To further track and learn the binary fluctuations, the hidden layers have been increased to be 70 and 30 for the first and second hidden layers, respectively, as shown in Figures 6 and 7.Figure 6
Feature extraction for binary classification.Figure 7
Employed multilayer neural network for binary classification.Again, the number of hidden layer neurons has been optimized for better performance, and validation checks have been performed to avoid underfitting or overfitting. The learning curve for a convergence target of −70 dB using the Levenberg–Marquardt algorithm is shown in Figure8.Figure 8
Learning curve for the binary classification neural network.


### 3.5. Performance

The confusion matrix is commonly used to evaluate the classification performance of a network. Table4 illustrates the elements of the confusion matrix. The following metrics are commonly employed; accuracy, precision, recall (sensitivity), and F1-score [7, 29]. In the case of balanced data set multiclass classification, as the case in hand, these metrics are, commonly, defined as follows [30]:(10)Accuracy=∑i=1MTPi+TNi/TPi+FNi+FPi+TNiM,Precision=∑i=1MTPi/TPi+FPiM,Recall=∑i=1MTPi/TPi+FNiM,F1−score=2Recall×PrecisionRecall+Prevission,where M is the total number of classes (M = 3 in this study) and i = 1, 2, 3, corresponding to normal, COVID-19, and pneumonia, respectively. To find the metrics for each class separately, the expressions in the numerators are used without dividing by M. The estimated metrics for the proposed method are illustrated in Table 5.Table 4
Confusion matrix.
Predicted positivePredicated negativeActual positiveTrue positive (TP)False negative (FN)Actual negativeFalse positive (FP)True negative (TN)Table 5
Estimated performance metrics for the 3-set classification.
NormalCOVID-19PneumoniaAverageAccuracy (%)95969495Precision (%)94979294Recall (%)93979695F1-score (%)96929393For the binary classification of COVID-19 and pneumonia (M = 2 and i = 1, 2), the estimated metrics are tabulated in Table 6.


## 3.1. Dataset

The employed data set contained the CXR images of COVID-19-positive cases, normal, and viral pneumonia cases. These CXR images were produced at the Rashid Hospital Radiology Department in Dubai in the United Arab Emirates. Balanced sets were selected where each of the three sets contains 600 CXR images. Images are in JPEG format having a dimension of 1024 × 1024 pixels.


## 3.2. Feature Extraction

All images are resized to 256 × 256 grayscale, and every image is scanned by an 8 × 8 mask. The two-dimensional DCT is computed for each masked block using Equation (2). Out of the 64 spectral components, only the highest 8 transform pixels (top left) are retained while all other transformed pixels are discarded. That is, all images have been compressed by a factor of 8. To illustrate the quality of the compressed CXR images, the discarded pixels are zeroed and the masked blocks are transformed back to the spatial domain [20].(3)X^=TtYT.Figure1 shows the original and the compressed reconstructed images for the three cases. The subjective good quality of the compressed images is clear. The percentage error energy norm (PEEN) has been computed as an objective measure for the degradation caused by compression. The PEEN is defined as follows [20]:(4)PEEN=∑m=0M−1∑n=0M−1Im,n−IRm,n2∑m=0M−1∑n=0M−1I2m,n×100,where I (m, n) is the original CXR image and IR (m, n) is the reconstructed (compressed) image.Figure 1
Original and compressed CXR images.Table1 illustrates the PEEN for the three cases which indicates that they are all low and almost equal. Since this slight degradation due to compression is almost the same for the three sets, the effect of compression on the classification stage is negligible.Table 1
PEEN for compressed CXR images.
NormalCOVID-19PneumoniaPEEN3.58453.50333.5066As further evidence for the low impact of the DCT compression on the CHX images, the peak signal-to-noise ratio (PSNR) has been estimated for the three cases. The PSNR is defined as follows [22]:(5)PSNR=10∗∑m=0M−1∑n=0M−1Imax2m,n∑m=0M−1∑n=0M−1Im,n−IRm,n2.Table2 shows the PSNR for the three cases. The retained highest 8 transformed pixels for each 8 × 8 block are concatenated to form one 8-pixel raw, so that the compressed image size is now 32 × 256. A pooling averaging window mask of 4 × 4 is performed for every compressed image twice. At the first run, the average resulting image size is 8 × 64, and after the second run, the size is 2 × 16. The final averaged image is flattened to produce a 32-feature vector for each CXR image in each class. Figure 2 illustrates the feature extraction methodology.Table 2
PSNR for compressed CXR images.
NormalCOVID-19PneumoniaPSNR33.852833.513733.1771Figure 2
Feature extraction steps for the 3-set classification.


## 3.3. Normal, COVID-19, and Pneumonia Classification

A feedforward neural network is employed to classify the three sets as shown in Figure3. The input layer is 32 neurons corresponding to the 32-feature vectors. Two hidden layers with 50 and 20 neurons, respectively, are used. The number of neurons in the hidden layers was optimized for best performance. The output layer has 3 neurons corresponding to the three classified sets. The upper output neuron is on (has a value of 1) if the 32-feature vector corresponds to the normal set, the middle neuron is on for COVID-19 feature vector, and finally, the last output neuron is on for pneumonia feature vector as shown in (6), where O is the output (target) matrix.(6)O=NCP=100010001.Figure 3
Employed multilayer neural network for the 3-set classification.The transfer functions for the neurons connecting the second hidden layer to the output neurons are the log-sigmoid since the swing of the outputs is between zero and one.The Levenberg–Marquardt algorithm has been employed for updating the suggested neural network. Like the quasi-Newton methods, the Levenberg–Marquardt algorithm is designed to approach second-order training speed without having to compute the Hessian matrix [23]. The Hessian matrix, H, can be approximated as follows [23]:(7)H=JtJ,and the gradient can be estimated as follows [23]:(8)g=Jte,where J is the Jacobian matrix that contains the first derivatives of the network errors with respect to the weights and biases and e is a vector of network errors. The Levenberg–Marquardt algorithm uses this approximation to the Hessian matrix in the following Newton-like update to minimize the mean-squared error (MSE) [23]:(9)Xk+1=Xk−JtJ+μI−1Jte,where µ is an adaptation variable. The Levenberg–Marquardt is fast and more accurate near an error minimum where µ is highly reduced near the minimum [24]. The number of input CXR images employed in the training session is 500 images from each class (a total of 15000 images). The MSE learning curve is shown in Figure 4 where the very fast convergence near the minimum MSE is clear. The training algorithm reached an MSE of about −90 dB in 88 epochs only. This target MSE was set a priory to stop the training program as an indication for convergence. Figure 5 shows the variation of µ during the training phase. The start value of µ is 1e − 3 and the final value is 1e − 15. It is also noted that µ has been dramatically reduced near the targeted minimum MSE as expected. Validation tests have been performed to ensure that the employed neural network did not overfit or underfit the input data (features derived from the 3-set CXR images).Figure 4
Learning curve for the 3-set classification neural network.Figure 5
Variation ofµ during the 3-set neural network training phase.The convergent neural network has been tested using 100 images from each class (a total of 300 images). As an indication of the test phase of the proposed technique, five test output vectors corresponding to true positive COVID-19 CXR cases are listed in Table3, which shows almost ones and zeros at the expected positions.Table 3
Outputs for tested true positive COVID-19 CXR cases.
4.9923e − 088.2066e − 112.7338e − 081.0418e − 128.5371e − 111.0000e + 001.0000e + 001.0000e + 001.0000e + 001.0000e + 001.0093e − 073.8957e − 087.3039e − 075.1293e − 101.9430e − 11


## 3.4. COVID-19 and Pneumonia Classification

In many situations, the CXR indicates a suspect subject and the target is to classify the subject either to be a COVID-19 case, needing special care, or just a pneumonia Case [25, 26]. For this reason, a binary classification session has been carried out on the data set of COVID-19 and pneumonia. The second 4 × 4 average pooling block in the 3-set scheme in Figure 2 has been reduced to be 2 × 2 so that the feature vector has 128 samples. This increase in the feature vector is necessary to track the little differences between the CXR images of COVID-19 [27, 28] and pneumonia and to increase the accuracy of the binary classification. To further track and learn the binary fluctuations, the hidden layers have been increased to be 70 and 30 for the first and second hidden layers, respectively, as shown in Figures 6 and 7.Figure 6
Feature extraction for binary classification.Figure 7
Employed multilayer neural network for binary classification.Again, the number of hidden layer neurons has been optimized for better performance, and validation checks have been performed to avoid underfitting or overfitting. The learning curve for a convergence target of −70 dB using the Levenberg–Marquardt algorithm is shown in Figure8.Figure 8
Learning curve for the binary classification neural network.


## 3.5. Performance

The confusion matrix is commonly used to evaluate the classification performance of a network. Table4 illustrates the elements of the confusion matrix. The following metrics are commonly employed; accuracy, precision, recall (sensitivity), and F1-score [7, 29]. In the case of balanced data set multiclass classification, as the case in hand, these metrics are, commonly, defined as follows [30]:(10)Accuracy=∑i=1MTPi+TNi/TPi+FNi+FPi+TNiM,Precision=∑i=1MTPi/TPi+FPiM,Recall=∑i=1MTPi/TPi+FNiM,F1−score=2Recall×PrecisionRecall+Prevission,where M is the total number of classes (M = 3 in this study) and i = 1, 2, 3, corresponding to normal, COVID-19, and pneumonia, respectively. To find the metrics for each class separately, the expressions in the numerators are used without dividing by M. The estimated metrics for the proposed method are illustrated in Table 5.Table 4
Confusion matrix.
Predicted positivePredicated negativeActual positiveTrue positive (TP)False negative (FN)Actual negativeFalse positive (FP)True negative (TN)Table 5
Estimated performance metrics for the 3-set classification.
NormalCOVID-19PneumoniaAverageAccuracy (%)95969495Precision (%)94979294Recall (%)93979695F1-score (%)96929393For the binary classification of COVID-19 and pneumonia (M = 2 and i = 1, 2), the estimated metrics are tabulated in Table 6.


## 4. Discussion

Most of the recent state-of-the-art literature reported on machine learning detection of COVID-19 adopted deep learning through CNN. However, the parameters employed in the analysis of such work are huge, actually millions [17]. For example, GoogleNet-V1 has about 5 million [31], ResNet-50 has about 25 million [32], AlexNET has about 60 million [33], and VGG-16 has about 138 million parameters [34, 35]. Consequently, the time required for training and testing is also large (in the range of thousands of seconds), even with the use of multiple graphics processing units (GPUs). On the other hand, the number of parameters employed in neural network-based machine learning techniques, such as the proposed one, is in the range of thousands, and the processing times are tens of seconds for both training and testing even without GPUs.Table 6
Estimated performance metrics for the binary classification.
COVID-19PneumoniaAverageAccuracy (%)959394Precision (%)949293Recall (%)969495F1-score (%)939292.5


## 5. Conclusion

COVID-19 is a serious pandemic threatening mankind. The rapid spread of severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) has led to the COVID-19 worldwide pandemic. Developing highly accurate methods for the identification and isolation of SARS-CoV-2 infected patients is critical. Machine learning is implemented to automatically detect COVID-19 using features extracted from chest X-ray images. This work employs features based on DCT spectral transformations of CXR image sub-blocks. No spatial features are incorporated. The DCT energy compaction property is employed to compress each spectral sub-block. The compressed spectrum is further manipulated through averaging windows to reduce the total number of feature elements representing each CXR image. Multilayer NN is implemented to classify sets containing COVID-19, normal, and pneumonia cases. The NN converged rapidly achieving a very low mean-squared error. The proposed method achieved an average accuracy of about 95% for the 3-set classification (normal, COVID-19, and pneumonia) and 94% for the binary classification (COVID-19 and pneumonia). While achieving a comparable accuracy, the computational burden and the time required for both training and testing of the proposed technique are very low compared to the state-of-the-art methods based on convolutional neural network deep learning.



---

*Source: 2656818-2022-10-20.xml*