## 2 Proposed Methodology
### CNN Architecture  
A convolutional neural network (CNN) is an architecture through which learning and pattern recognition are performed on an input image (Figure 4), allowing the identification of differences among various images [33]. The primary structure of a CNN comprises four main layers: the convolutional layer, the pooling layer, the fully connected layer, and the SoftMax layer [34].  
The convolutional layer receives the image as input and applies convolutional processes. Several filters, known as kernels, are applied. These filters are smaller than the original image and traverse the image through all pixels lengthwise and widthwise to create an activation map. This layer extracts features and patterns from the input images using the kernels and is responsible for capturing features such as color, gradient direction, etc. [35].  
The pooling layer plays a crucial role in reducing the dimensions of the feature map and the parameters that were extracted from the preceding layer. This reduction helps prevent overfitting in the network. There are two primary types of pooling layers: the maximum pooling layer and the average pooling layer [36]. In this paper, both types of  
Figure 4: Structure of a CNN.  
layers were implemented to obtain the optimal CNN configuration. The fully connected layer is responsible for differentiating the features represented by the activation layers and identifying the input class. Each of these layers contains perceptrons, with the number of perceptrons being dependent on the size of the input images after the convolution and pooling layers [37]. The confusion matrix is used to assess the performance of CNN. The primary objective of this technique is to evaluate the CNN model based on the metrics obtained from both correct predictions and the errors identified during the classification. It not only provides information about the errors but also categorizes the types of errors made by the classifier [34]. The indicators that are most frequently reported in studies using CNNs are calculated using the following equations:  
\[Accuracy(\%)=\frac{(TP+TN)}{(TP+TN+FN+FP)}\times 100 \tag{1}\]  
\[Precision(\%)=\frac{TP}{(TP+FP)}\times 100 \tag{2}\]  
\[Recall(\%)=\frac{TP}{(TP+FN)}\times 100 \tag{3}\]  
\[F1-Score(\%)=\left(\frac{2\times(Recall\times Precision)}{(Recall+Precision)} \right)\times 100 \tag{4}\]  
where _TP_ is the number of true positives, _FP_ is the number of false positives, _TN_ is the number of true negatives, and _FN_ is the number of false negatives.  
On the other hand, salt and pepper is a common alteration in thermal images that can occur due to a camera sensor defect, software failure, or during image acquisition or transmission [38,39]. To replicate this, 2% salt and pepper noise was added to the 4800-image database. Using the same CNN configuration, new hyperparameters were obtained considering the corrupted database. Finally, to test the robustness of the latter, tests were carried out on images with salt and pepper noise at levels of 10, 20, and 30%. For the latter, the tests were performed with 960 images for each salt and pepper noise condition (80 images for each of the twelve states that can be detected by the method). The last test was to apply a median filtering process to the images corrupted with 10%, 20%, and 30% salt and pepper noise because this is the process that should be performed to improve the quality of the image if salt and pepper noise were present in a real case.