*4.1. Ray-Casting Technique*

Since the complete point cloud of the object may be utilized, it is a common situation that only a subset of all the 3D points is seen by the thermal camera when each thermogram is acquired. The process of spotting the points seen by the thermal camera is normally fulfilled by a ray-casting technique, which allows us, among other things, to handle occlusions. When working with point clouds, one common approach is to first convert the original point cloud into a different data type, such as voxels or a mesh representation. Then, to perform the visibility check, one can start from each pixel of the thermal image and move with discrete steps on a specific line, stopping when the desired voxel (or mesh triangle) is reached ([14,33]).

The approach we propose, however, does not need this kind of type conversion and works with data in form of point cloud. Starting from all the 3D points, two types of exclusion are applied in order to obtain a subset, representing all and only the 3D points seen by the camera. In the next sections, the scheme of these two exclusions will be analyzed, but first it is to be said that there is actually another exclusion, which is trivial—that is, the exclusion of all the 3D points projected outside the image plane.

#### *4.2. First Type of Exclusion*

In the first type of exclusion, the image plane is firstly divided into a grid, whose cell dimension is defined by the parameter ξ (its measurement unit is pixel, and each cell is composed of ξ x ξ pixels).

All the 3D points are projected onto the image plane, and then clustered depending on which cell of the grid they occupy. For each cluster, the points *Pi*, such that Equation (2) holds true, are excluded:

$$d\_i \succ d\_{\min} + \chi \tag{2}$$

where *di* is the distance between the point *Pi* and the optical center *O*, *dmin* the minimum distance among the distances *di* and χ a fixed parameter (in millimeter, as for *di* and *dmin*). For higher values of ξ, higher values of χ are needed to take into account the fact that the surface region corresponding to the points not to be excluded is larger and so the di fference in distances can be higher.

Theoretically, an optimal choice of the parameters ξ and χ would involve a non-trivial geometrical analysis, considering both the density in space of the 3D points (in general variable from region to region) and the curvature of the object surface with respect to the viewing angle. In practice, they can simply be adjusted by graphically evaluating the results. In our case, in order to obtain proper experimental results, they were computed according to the experimental relations Equations (3) and (4), suggesting a possible choice of the two parameters:

$$\xi = \text{ceil}(\text{Res}/N) + \text{1}[\text{pixel}] \tag{3}$$

$$\chi = 5/(1 - \xi/20) \text{ [mm]} \tag{4}$$

where *N* is the number of points projected on the image plane and *Res* the resolution of the image. In Equation (3), "ceil" is a function that rounds a number *x* to the nearest integer ≥*x*. Since χ is positive, according to Equation (4) ξ must be less than 20, a condition always verified for common resolutions and points cloud densities. It has to be pointed out that, for the vast majority of object geometries, the results are stable with respect to a variation of ξ and χ of some units, and so in any case their resulting values are acceptable as long as they fall into a proper range.

#### *4.3. Second Type of Exclusion*

The second type of exclusion exploits the knowledge of the normal vectors *n*ˆ*i* in each 3D point *Pi* and requires that all the points for which Equation (5) holds true are excluded:

$$(O - P\_i) \cdot \hbar\_i < 0\tag{5}$$

where *O* is the optical center.

This condition derives from the fact that, if the dot product in Equation (5) is negative, the angle between the vector ( *O*−*Pi*) and the normal vector *n*ˆ*i* is greater than 90 degrees, and so the point is not seen by the camera. This condition on its own is theoretically suitable for excluding all the inappropriate points in convex surfaces, but it fails when dealing with surfaces that present concavities. Conversely, even if the first exclusion appears to be able to handle a generic shape of the point cloud, it fails in some particular scenarios in which the point cloud lacks some parts, because in these cases some temperatures might be wrongly assigned to the opposite part of the point cloud. For these reasons, the two types of exclusion were combined, in accordance with the experimental results as well. Figure 5 shows two examples of applications of the two exclusions in succession with two di fferent values of ξ, on a region of a hypothetical surface, which is represented in the points cloud by 11 points. The zones between each pair of dotted lines (converging to the optical center) represent the band corresponding to each pixel. Inside each band, the part at the right of the purple segments are excluded according to the first type of exclusion. The points in green are the points to be maintained, the points in blue are the points correctly excluded with the first type of exclusion, the points in yellow the ones correctly excluded only with the second type of exclusion and the points in red the ones not correctly excluded after applying both the exclusions, and to which consequently a wrong temperature is assigned. In Figure 5b, better results are obtained if the value of ξ is doubled, because in this way all the points belonging to a part of the object surface not seen by the camera are correctly excluded. Indeed, the

value of the parameter ξ has to be chosen so that in each cell the number of reprojected points is higher than one, so that they form an actual cluster to which we can properly apply Equation (2). Finally, it is worth noticing that the order of the two exclusions is important: in fact, by inverting the exclusions order, it is easy to see that the point *P*11 is never excluded.

**Figure 5.** Application of the exclusion methods on a part of a hypothetical surface represented by eleven points, for two values of ξ. The value of ξ in (**b**) is twice the value of ξ in (**a**). Green points: to be maintained; blue points: excluded with the first exclusion; yellow points: excluded with the second exclusion; red points: not correctly excluded with the two exclusions.
