## 3 Methods and Materials
### The ANN Classifier Based on Fusion of Features  
This section presents a novel method for diagnosing tuberculosis using X-ray images by integrating features extracted from deep learning models (ResNet-50 and GoogLeNet) with algorithms (GLCM, DWT, and LBP) and classifying them using an ANN classifier [40]. The steps to implement the proposed method are as follows: first, we feed the enhanced X-ray images into the ResNet-50 and GoogLeNet models. These models extract deep features through convolutional, pooling, and auxiliary layers. ResNet-50 and GoogLeNet produce 2048 deep features and store them in feature vectors with a size of 662 \(\times\) 2048 for the first dataset and 4200 \(\times\) 2048 for the second dataset. Second, the PCA algorithm is used to reduce the dimensions of the two datasets while retaining the most important  
Figure 4: The basic structure of the first proposed system for diagnosing tuberculosis based on the two datasets. basic features. After PCA is applied, the dataset feature size becomes 662 \(\times\) 512 for the first dataset and 4200 \(\times\) 512 for the second dataset. Third, the extraction of texture and shape features by GLCM, DWT, and LBP algorithms is performed. The GLCM algorithm represents the region of interest in a matrix of gray levels to extract texture features from the gray levels. The algorithm distinguishes the smooth from the coarse regions, because the smooth regions have almost the same pixel values, while the coarse regions have significantly different pixel values. The algorithm produces 13 statistical measures by collecting spatial information [41]. Each measure represents a feature. Thus, spatial information determines the relationship between a pixel and its neighbors according to distance d and angle \(\theta\)[42]. The DWT algorithm analyzes the input X-ray images as signals using low- and high-pass filters. In this work, a single-level discrete 2-D wavelet transform (dwt2) function was used to analyze the X-ray images of tuberculosis and classify them into approximation and detail coefficients [43]. This function was used because it produces approximation and detail coefficients from which statistical measures such as mean, standard deviation, and variance are extracted from each component. Therefore, these statistical measures are of importance in representing the important features of the images [44]. Low filters produce approximate parameters that extract three statistical features: standard deviation, variance, and mean, while high filters produce three detailed parameters (diagonal, vertical and horizontal), from each of which nine statistical features such as standard deviation, variance and mean are extracted [45]. Thus, the algorithm produces 12 features. The LBP algorithm extracts the texture characteristics of binary surfaces by analyzing the contrast between local texture pixels. The algorithm is set to 6 \(\times\) 6 pixels; each chest X-ray is represented in a matrix, and then each pixel in the X-ray is replaced by 35 adjacent pixels according to Equation (4) [46]. The process continues until each pixel in the X-ray is replaced by neighboring pixels. The algorithm compares the gray levels of each central pixel (\(g_{c}\)) and the gray levels of neighboring pixels (\(g_{p}\)) [47]. \[LBP_{R,P}=\sum_{p=0}^{p-1}s\big{(}g_{p}-g_{c}\big{)}2^{p} \tag{4}\]  
\[s\big{(}g_{p}-g_{c}\big{)}=\left\{ \begin{array}{ll}0,&g_{p}-g_{c}<0\\ 1,&g_{p}-g_{c}\geq 0\end{array} \right.\]  
where \(g_{p}\) means the grey value of neighboring pixels, \(P\) refers to the number of neighboring pixels, \(R\) is the radius for neighboring pixels, \(g_{c}\) means the grey value of the goal pixel. Thereafter, we combine the deep features extracted by ResNet-50 with features extracted by GLCM, DWT, and LBP; similarly, deep features extracted by GoogLeNet are combined with features extracted by GLCM, DWT, and LBP. Thus, after merging, the size of the feature vectors becomes 662 \(\times\) 740 for the first dataset and 4200 \(\times\) 740 for the second dataset.