# COVID-19 CXR Classification: Applying Domain Extension Transfer Learning and Deep Learning
## 3 Materials and Methods
### Preprocessing  
The COVID-19 CXR image data were resized to the input size of the CNN model. Rotation and horizontal flip were suitable for data augmentation during classification of the COVID-19 CXR images. This approach was effective in improving model generalization performance when applied to the classification of COVID-19 CXR images. According to research conducted by [PERSON] et al. (2019), the main idea of CLAHE involves mapping each pixel (Equations (1) and (2)), and it is based on the image distribution of grayscale. Research has demonstrated that a medical image is produced in a decent state by balancing the pixels of the image through image conversion. The study by [PERSON] involved two equations on CLAHE. Equation (1) represents histogram equalization, and Equation (2) represents reducing bias by using contrast limit. Explanations of these equations are as follows. M and N are the number of pixels and grayscale in each region, respectively, and \(f_{i,j}(n)\) is the histogram of the \((i,j)\) region for \(n=0\), 1, 2..., N \(-\) 1. An estimate of the \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multicolumn{2}{c}{**Mendeley Dataset**} & \multirow{2}{*}{**Training**} & \multirow{2}{*}{**Validation**} & \multirow{2}{*}{**Testing**} \\ \hline
**Class** & & & & \\ \hline COVID-19 & 4044 & 2426 & 809 & 809 \\ Non-COVID-19 & 5500 & 3300 & 1100 & 1100 \\ Total & 9544 & 5726 & 1909 & 1909 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Summary of the Mendeley dataset. \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multicolumn{4}{c}{**MIMIC CXR(PA) Dataset**} & \multirow{2}{*}{**Training**} & \multirow{2}{*}{**Validation**} & \multirow{2}{*}{**Testing**} \\ \hline
**Class** & & & & \\ \hline Atelectasis & 2105 & 1684 & 211 & 211 \\ \hline Cardiomegaly & 3106 & 2484 & 312 & 312 \\ \hline Consolidation & 285 & 228 & 28 & 28 \\ \hline Edema & 587 & 469 & 58 & 58 \\ \hline Fracture & 643 & 514 & 64 & 64 \\ \hline Lung Lesion & 810 & 648 & 81 & 81 \\ \hline Lung Opacity & 4113 & 3290 & 416 & 416 \\ \hline No Finding & 48,577 & 38,861 & 4857 & 4857 \\ \hline Pleural Effusion & 2177 & 1741 & 217 & 217 \\ \hline Pneumonia & 1676 & 1340 & 167 & 167 \\ \hline Pneumothorax & 478 & 382 & 47 & 47 \\ \hline Total & 64,557 & 51,641 & 6458 & 6458 \\ \hline \hline \end{tabular} \({}^{\dagger}\) MIMIC-IV: Medical Information Mart for Intensive Care-IV; PA: posteonterior.  
\end{table} 
Table 2: Summary of the MIMIC CXR(PA) \({}^{1}\) dataset. corresponding CDF, appropriately scaled by (N \(-\) 1) for the grayscale mapping [34], is as follows:  
\[f_{ij}(n)=\frac{(N-1)}{M}\times\sum_{k=0}^{n}h_{ij}(k)\ \ \,\ \ n=1,\ 2,\ 3 \ldots,\ N-1 \tag{1}\]  
To restrict the contrast to a specific level, clip limit \(\beta\) is used to cut the histogram to limit the slope of Equation (1). Clip limit is related to clip factor \(\alpha\)[34] as follows:  
\[\beta=\frac{M}{N}\Big{(}1+\frac{\alpha}{100}(s_{max}-1)\Big{)} \tag{2}\]  
The collected X-ray images became cloudy over time, thereby making them unsuitable for lesion detection [35]. Therefore, CLAHE was applied in the pretreatment process. The improved quality of X-ray images enhanced the classification accuracy of COVID-19 CXR images by approximately 3.9%. Figure 2 shows the results of applying CLAHE to the Mendeley dataset. Unlike hazy X-rays, X-rays with CLAHE applied to the images show a ground-glass opacity called COVID-19 lesions. In both lungs, these lesions can be identified well with the naked eye. Table 3 shows the results obtained through signal-to-noise ratio (SNR) indicators to indicate whether image quality improves after CLAHE in this study. Comparing the existing image and the image after CLAHE revealed that the SNR value increased in both the original and resized images. Higher SNR value means that the image quality was relatively superior. Hence, CLAHE applied in this study affected model performance improvement.