## 3 Materials and Methods
### 3D Thermal Model of the Envelope
To understand how the filter works, it is necessary to define what Gaussian noise is and what causes it to appear in RGB or thermal images. Gaussian noise, named after [PERSON], is a term from signal processing theory denoting a kind of signal noise that has a probability density function (PDF) equal to that of the normal distribution (which is also known as the Gaussian distribution). In other words, the values that the noise can take are Gaussian-distributed. The probability density function \(p\) of a gaussian variable \(z\) (Equation (3)) is given by:  
\[P_{G}(Z)=\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(z-z)^{2}}{2\sigma^{2}}} \tag{3}\]  
\(z\) being the grey level, \(\mu\) the mean grey value, and \(\sigma\) the standard deviation. Figure 14: Gaussian filter with minimum depth. Left, original image; right, focused. Figure 12: Conversion to greyscale keeping thermal information. Figure 13: Histogram equalisation. Left, original image; right, equalised. The principal sources of Gaussian noise in digital images arise during acquisition, e.g., sensor noise caused by poor illumination and/or high temperature, and/or transmission of electronic circuit noise [59]. Gaussian noise can be reduced using a spatial filter, though when smoothing an image, an undesirable outcome may result in the blurring of fine-scaled image edges and details because they also correspond to blocked high frequencies. Conventional spatial filtering techniques for noise removal include mean (convolution) filtering, median filtering, and Gaussian smoothing. The three methods were tested and the Gaussian filter was selected as it improved the texture of the images, achieving the highest number of aligned thermograms. The filter applied to the images was therefore a Gaussian low-pass filter in which it was possible to control the value of the standard deviation. This variable controls the size of the region around the edge pixels of the image that is affected by the sharpening. By selecting the correct value, as in the photographs in Figure 14, there is no variation in the thermal information collected by the image and the improved focus allowed 199 images to be oriented, compared to the 153 that Metashape aligned before processing. Although the resulting model is not comparable to that extracted from the RGB images (6000 \(\times\) 4000 px vs. 640 \(\times\) 512) the areas of the walls and roof where thermal anomalies were measured are easily identifiable and the pre-processing valid for any three-dimensional reconstruction using thermal imagery. Figures 16-18 show three views of the thermal model. Figure 16 presents a zenithal view. It can be seen that in the main roof, in the central area where both sides converge, there is a central area and an outer area with different shades of grey, indicating the non-uniform distribution of temperatures. To maintain the thermal equilibrium of the envelope, the structure in these regions must be insulated. Figure 17 is a front view of the model. In this image, it is possible to inspect the front wall on the left side. As in Figure 16, the temperature is not uniform, and the anomaly is also presented as a set of grey shades with different tones. In the region shown in the model within the red rectangle, the presence of moisture was detected. The validity of the thermal model for obtaining an overall picture of the building envelope condition can be checked by simply reviewing Figures 1, 2 and 7. In the first two figures, it is clear how the wall shows stains caused by humidity. In Figure 7, one of the views of the 3D model constructed with the RGB images also shows the same pathology. Finally, Figure 18 is a side view of the model. Although it is impossible to make any kind of analysis here, it is presented to show how, even on the wall that is least likely to be photographed due to its position, which has a minimal projection towards the camera during the flight, it is almost possible to perform the reconstruction as well. Figure 15: Gaussian filter with maximum depth. Left, original image; right, focused.