## 3 Materials and Methods
### Software and Fundamentals of SfM-MVS Photogrammetry  
Structure from Motion Multiview Stereo (SfM-MVS) Photogrammetry is a cost-effective and versatile technique used, among other applications, for the three-dimensional (3D) modelling of terrain and the three-dimensional reconstruction of archaeological heritage sites and artistic objects [47; 48; 49]. The recording of overlapping images allows the use of SfM-MVS techniques. These procedures are considered to be automated photogrammetric methods characterised by high resolution and low cost [50], which are also flexible and easy to apply with a very fast learning curve [51]. The SfM-MVS is, in essence, based on the overlapping of the recorded images to find common points and thus generate a sparse three-dimensional point cloud, without the need for prior calibration [52]. To achieve this, it is necessary that the images present an adequate level of overlapping so that the processing software can identify homologous points between them [53]. Subsequently, MVS algorithms are applied to density the sparse cloud from the already oriented images [54]. In addition, during image analysis, the software automatically determines the internal and external parameters of the camera [55]. It is important to note that one of the main advantages of photogrammetry techniques is the absence of invasiveness; only through image processing is it possible to detect damage and/or defects in the reconstructed structure or object, and to maintain a continuous monitoring of the evolution of the entire affected area [56]. SfM-MVS techniques allow the use of conventional (RGB), multispectral or thermal imagery. The first two are the most commonly used, although there are some studies in which terrain models have been constructed using thermal images [57]. In this study, SfM-MVS will not be applied to the terrain, but to the wine cellar. Although various commercial products exist, one of the most widely used software packages in SfM-MVS is Agisoft Metashapet(tm), largely due to its intuitive, user-friendly interface, and automated workflow, which allows for easy generation of dense point clouds, 3D models, digital elevation models, and orthomosaics. The resolution of thermal cameras is significantly lower than that of RGB cameras, and since the three-dimensional reconstruction process is based on finding points belonging to two overlapping images, the modelling is much less detailed and more complex to perform. In addition, thermal imagery is affected by factors such as the emissivity of the materials, which makes it even more difficult to obtain a clear and detailed model. For this reason, the thermal images recorded by the cameras presented in the previous section were pre-processed using the Image Processing Toolbox belonging to MATLAB(tm). Figure 6 shows a diagram of the workflow and then details the focusing and contrast balancing techniques applied. Figure 6: Workflow for obtaining the three-dimensional model from thermal images. As discussed above, one of the major difficulties in 3D building construction using thermal imaging is the low resolution of cameras designed to be used on board a UAS; 640 \(\times\) 521 px compared to values as high as 6000 \(\times\) 4000 px, and even higher on RGB high-resolution cameras. SfM-MVS techniques are based on the capture of photos with a good percentage of overlap that, as a whole, cover the entire region to be modelled. The reconstruction algorithms search for common points between the images, from which depth is introduced. A triangular mesh is then created, and finally a texture is added. In the flowchart presented in Figure 6, the parts of the process that are carried out outside the photogrammetry software are coloured in blue and those that are carried out inside Metashape in green. It can be observed that after capturing the images, processing is required that does not apply to the RGB images.