# Morphological Foot Model for Temperature Pattern Analysis Proposed for Diabetic Foot Disorders
## 2 Materials and Methods
### Foot Model Extraction  
A foot model was extracted for each gender and foot separately, employing all the images previously acquired. For simplicity, the procedure to extract the right foot model is described but an analogous procedure was employed for the left foot. The method consisted in selecting one of the images as a reference or fixed image, and subsequently registering, by an affine transformation, the remaining ones to that reference. A simplified scheme describing the workflow employed is presented in Figure 1.  
As mentioned in the previous section, the RGB images for each volunteer were segmented by three independent researchers. Then, the ground truth segmentation for each subject was obtained by applying the STAPLE algorithm (STAPLE #1), which will be employed as reference for a specific subject. For instance, as shown in Figure 1, the subject on the left was considered the reference to extract the final model. The other ground truth segmentations, corresponding to the remaining subjects, were spatially registered to the reference using the affine transformation from the SimpleElastic module (ELASTIX) [34] in Python 3 [35].  
A registration procedure based on IR images is complicated since these images lack the spatial information required to apply the usual feature-based and intensity-based registration techniques. However, by employing a third modality, in this case the binary image corresponding to each mask (ground truth segmentation), registration can be successfully achieved, as previously reported [26; 36]. This approach requires an image registration between modalities (RGB-D-IR) that is as precise as possible. Therefore, prior to the procedure  
Figure 1: Workflow employed to extract the right foot model. This process is repeated using all subjects as reference to extract the final model. A similar workflow is employed for the left foot.  
to extract the foot model, any possible misalignment between the RGB-D images, or the associated ground truth segmentations, and the IR images were corrected by performing a 2D affine transformation. The registrations between masks were also based on an affine transformation [26]. When all the masks were in the same coordinate system, the STAPLE algorithm (STAPLE #2) was applied again in order to extract the right feet model associated with the subject used as reference. Since this approach may be dependant on the image selected as reference, the process was repeated as many times as there were available images. In this manner, all subjects were used as reference, and the one providing the highest overlap measures was selected as the final foot model.  
Once the final right foot model was established as global reference, based on the overlap measures, the ground truth segmentations associated with each subject were subsequently registered to this model by another affine transformation. All these spatial transformations were also carried out using the SimpleElastix module [34] in Python 3 [35]. Since, as previously ensured, RGB-D-IR images were in the same coordinate system, the same affine transformation used for each segmentation mask was applied to the corresponding RGB-D and IR images using the Transformic module [34,37] in Python 3 [35]. That is, the file of parameters corresponding to each registration was employed in the Transformic module to bring the IR image to the reference model. Finally, the foot model was applied to the transformed IR image. A simplified scheme of the workflow is presented in Figure 2.  
Figure 2: Workflow employed to apply the right foot model to the acquired IR image. An analogous workflow is employed for the left foot.