## 2 Case Presentation
### Procedure in MATLAB  
The procedure for the automated analysis of thermographic images recorded during the SP test consists of three steps: (i) the generation of the regions of interest (ROIs) based on manually created masks for the thigh, calf, and foot; (ii) the removal of the outliers and wrong measurement data; and (iii) the calculation of the SP test measures. Before the automated data analysis was performed in the MATLAB environment, images with the marked ROIs, i.e., the so-called masks, had been prepared manually. The masks were defined anatomically, i.e., for the thigh, calf, and foot. This procedure was performed in the _Paint_ editing software. At this time, no procedure has been developed to automatically detect the thigh, calf, and foot in a thermographic image. As a result of the manual procedure, the so-called thigh, calf, and foot masks were developed. A visualization of the masks is shown in Figure 2.  
Thermograms with masks in the form of a BMP file were loaded into the MATLAB environment to convert them into matrices, which was necessary for further analysis. The procedure of thermogram processing was as follows:  
1. Conversion from a true RGB color image to grayscale using the rgb2 gray function. This task was performed by eliminating the hue and saturation information while retaining the luminance. The grayscale values were calculated according to the following formula: 0.299 \(\times\) R + 0.587 \(\times\) G + 0.114 \(\times\) B, where R is the red component, G is the green component, and B is the blue component. As a result, a 320 \(\times\) 240 matrix of values in the range from 0 to 255 uint8 was created;
2. Conversion of the uint8 values to the float format using the double function;
3. Reduction of the shadows by eliminating all values but the 255 value, which corresponds to the ROI;
4. Division of the matrix by 255, which creates a '0'/'1' matrix, where '1' corresponds to the number of pixels within the ROI. The SP test thermographic images were exported as text files. They were then loaded into the MATLAB environment and stored as a matrix sized 320 \(\times\) 240. Each element of the matrix corresponds to a temperature value rounded to one decimal place. The matrices were then multiplied by mask matrices for the three areas: thigh, calf, foot. The mask matrices were calculated according to the procedure described above (points 1-4). The obtained matrices were saved for further calculations. The SP test evaluates two diagnostic parameters, namely, (i) the autonomic referred pain (AURP), i.e., the percentage area with a temperature response (calculated separately for vasodilation and vasoconstriction as the size of the region that developed below or  
Figure 2: The result of the manual procedure (**upper line**) and the visualization of the matrices for the three ROIs (**lower line**). above the baseline maximum and minimum temperature, respectively) and (ii) the level of change in the mean temperature of the area (\(\Delta\mathbb{T}^{\circ}\)). The procedure for the calculation of features and measures:  
1. Calculation of the area with the AURP temperature response in the ROI: 1. Calculate the values of the minimum \(T_{min}\) and maximum \(T_{max}\) temperature in the first thermogram at the moment \(T_{0}\) = 0 s: \[\bigvee T_{px}\in\{1,\,2,\,\ldots,n\}\wedge\ t=t_{0},\quad T_{max}=\max\big{(}T _{px1},T_{px2},\,\ldots,\,T_{pxn}\big{)}\] \[\bigvee T_{px}\in\{1,\,2,\,\ldots,n\}\ \wedge\ t=t_{0},\quad T_{min}=\min\big{(}T _{px1},T_{px2},\,\ldots,\,T_{pxn}\big{)}\] 2. Calculate the area of the ROI surface \(A_{ROI}\) for the patient as the sum of non-zero pixels in the thermogram according to the following equation: \[\bigvee T_{px}>0\,\ \ A_{ROI}=\sum T_{px}\] where \(T_{px}\) is the temperature value at the pixel \(px\) within the ROI; 3.