## 3 Geometrical Calibration
Differently from [11], however, the object contour detection is only needed for the thermogram, and the quantity evaluated is not the alignment between thermal and depth edges, but rather the \"degree of filling\" of the projected 3D points inside the thermal edge, which translates to a different definition of the objective function to minimize. Another difference is that this method takes as its input the full 3D representation of the object, and not the single view representation (often referred to as 2.5D [32]). This method can deal efficaciously with initial parameter values significantly different from the ones searched for, which makes it particularly suitable for a decoupled type of integration. The extrinsic calibration method here developed can be divided into the following principal parts:  
1. extraction of the object contour from the thermogram;
2. creation of a matrix \(\overset{=}{M}_{1}\) (with dimension equal to the resolution of the thermogram) obtained in this way: starting from the contour extracted in 1), a series of internal and external subsequent layers are created, and the same numerical value is associated to each pixel of each layer, following a specific function \(f_{l}\) defined later in this section;projection of all the 3D points on the image plane with an initial set of extrinsic parameters, and the creation of a second matrix \(\overset{=}{M_{2}}\) composed of binary values, 1 if on that pixel at least one 3D point has been projected, 0 otherwise. Furthermore, in order to have a more uniform projection, the pixels sufficiently close to each pixel with values 1 are set to 1 if 0 (to avoid non uniform situations, especially for sparse point clouds);
4. minimization of the objective function of Equation (1), with a global minimization technique: \[f_{obj}=f_{obj}\left(\overset{=}{R},\tilde{t}\right)=-sum\left(\overset{=}{M_ {1}}\circ\overset{=}{M_{2}}\left(\overset{=}{R},\tilde{t}\right)\right)\] (1) where \(\circ\) is the Hadamard product, \(sum\) is the operator that sums all the elements in a matrix, \(\overset{=}{R}\) is the rotation matrix (computed as a function of the three Euler angles) and \(\tilde{t}\) is the translation vector. The Euler angles and the components of the vector \(\tilde{t}\) that make the function \(f_{obj}\) minimum are the searched values, namely the extrinsic parameters. It is to be outlined that the matrix \(\overset{=}{M_{1}}\), once computed, remains fixed in the optimization process described in Equation (1) and so only one contour extraction operation is required. The point (1) can be done either in an automatic way (exploiting some well-known edge detection or background extraction algorithm) or manually. The background extraction also permits us to avoid the possible gross error of assigning to the 3D points, if the corresponding pixels are very near to the edges, the background temperature. For the point (2), the function \(f_{l}\) has to be properly chosen, so to assure that the objective function minimum corresponds to the desired situation, namely that the 3D projected points completely fill up the zone inside the contour without overflowing outside the contour. The function \(f_{l}\) utilized is of Gaussian type:  
\(f_{l}(x)=c_{1}e^{-c_{2}x^{2}}\) if \(x\geq 0\) (layer \(x\) inside the contour or the contour itself if \(x=0\))  
\(f_{l}(x)=c_{1}e^{-c_{2}x^{2}}-c_{3}\) if \(x<0\) (layer \(x\) outside the contour)  
(\(x\in Z\), \(c_{1}\), \(c_{2}\), \(c_{3}\) positive constants). An example of the application of the function \(f_{l}\) is shown in Figure 3.  
The \(c_{3}\) constant is important, because it permits us to shift the curve of the external layers so that the function \(f_{l}\) has negative values there. This is necessary to avoid situations in which the minimum of the \(f_{obj}\) corresponds to the filling of zones incorporating the contour, but it is larger than the contour itself (in other words, to avoid that the projected points \"overflow\" the contour).