## 3 Materials and Methods
### 3D Thermal Model of the Envelope  
Thermal cameras have a low resolution, meaning that at a certain distance from the object, the size of the pixel projected on it will be enlarged. The first consequence for a radiometric survey is that the measured temperature will be the average of the surface temperatures projected on each pixel. On the other hand, this same problem appears in photogrammetric processing as the alignment of the images (extraction tie points) is much more complex. By approaching the recording of images from a UAS, a certain level of improvement could only be obtained with a minimum flight height and an increase in the overlapping of the photos. Reducing the height causes the footprint of the photo to be much smaller, increasing the number of photos noticeably, as does flying with greater overlap. The number of images that this solution would generate, apart from the inherent difficulty of the flight and its planning, means that the processing time would be extended to unacceptable limits or even require special hardware if it were to be processed in high or ultra-high quality. The location of the building and its construction characteristics make it very difficult to take photographs from the UAS; not only is it impossible to photograph at close range, but there are also multiple obstacles that prevent the alignment of some of the photographs. With all the limitations described so far, it was decided to carry out pre-processing of the images which, although simple, has not been applied to date, to the best of the authors' knowledge. For this purpose, the MATLAB Toolbox was used, which offers all kinds of functions for the processing of RGB, thermal and multispectral images. Although 3D models were constructed by applying different focusing techniques, white balance and histogram redistribution, as well as conversion of thermal images with colour palettes to greyscale, it is important to note that whatever method is used, the temperature, expressed in shades of grey and white, contained in the photograph must not be altered. That is, any noise reduction procedure, correction of the non-linearity of the camera's thermal sensors or focusing cannot result in a model where thermal anomalies are diluted or delocalised. In order to present the study as clearly as possible, several examples of photographs before and after processing are shown below, followed by details of the mathematical basis of the method used. Figure 12 presents the conversion of a radiometric thermal image recorded with a colour palette to a greyscale image while retaining the thermal information. This transformation was performed to add to the set of photographs from which the model was generated, some taken by hand, thus making it possible to increase the size of the chunk loaded in Metashape. As can be seen from Figure 13, some thermal images have a very uneven histogram that prevents the detection of tie points during photogrammetric processing. This figure shows the original photo on the left and on the right the same image after redistributing the histogram. Although the improvement in the result is clear and the resulting 3D model is valid and shows the sharpest geometric details, it was not used, because the redistribution of the histogram showed some thermal anomalies more intensely, but diluted the edges of the affected regions on the roof of the building. Figures 14 and 15 are of the greatest interest. They depict the application of two Gaussian filters with different depths. The first one, used in Figure 14, is of lower intensity than the one in Figure 15. In both cases, the better focus of the original image after applying the filter is evident. Since the final model was constructed after focusing the images and this type of filter is particularly suited to the characteristics of a thermal image, its mathematical foundations and properties are presented below. Its advantages for global and direct  
diagnosis, accuracy, processing complexity and computational time are also presented in later sections.