## 3 Materials and Methods
### System Pipeline
#### 3.2.2 Segmentation Model  
A DL approach is proposed to perform wound segmentation due to the nature of the problem. Traditional methods tend to fail for irregular boundaries where DL approaches achieve a better performance when employed with a dataset of considerable size. The dataset for image segmentation is divided into input RGB images and the corresponding segmentation masks, previously annotated.  
A segmentation toolkit from Keras, called _keras-segmentation_[25], was used to define the segmentation model. This toolkit uses Keras API, built-in TensorFlow, and contains several well-known pre-trained models for application that can be combined with different decoders. The proposed semantic segmentation algorithm was built by combining typical segmentation networks and backbones, namely, MobileNet [26] and ResNet50 [27]. The Unet [28] and Segnet [29] image segmentation architectures were evaluated for semantic segmentation. These architectures consist of two paths: encoder and decoder. For the encoder part of the network, the transfer learning technique was used to take common neural networks that perform well on image classification tasks and retrain only the top layers. Therefore, four models, MobileNet-Unet, MobileNet-SegNet, ResNet50-SegNet, and ResNet50-Unet, were trained and evaluated for the corresponding problem. Transfer learning was used in the DL base models to make the training process more effective. Both  
Figure 4: Example of image result from the pre-processing step: (**a**) original image before pre-processing; (**b**) image after pre-processing.  
base models, ResNet50 and MobileNet, pre-trained on the ImageNet dataset, were loaded before training.  
The dataset was split into three sets with a nested cross-validation technique: 60% for training, 20% for validation, and 20% for evaluation. For model selection, the training set was split randomly with four-fold cross-validation into a training set and validation set, creating the inner loop. The final evaluation was performed on the outer loop with the best model from the validation set, with the five never-seen test sets. The four-fold cross-validation procedure for model selection was nested inside the five-fold cross-validation for model evaluation. This process is shown in Figure 5.  
During training and validation, all the models were trained with the same hyperparameters: 50 epochs, 2 batch-size, and Adam optimizer. After validation, the model with the best mean IOU, MobileNet-Unet, was selected and evaluated with five-test folds to tune several hyperparameters and optimize the network's performance. The hyperparameters optimized during this stage were the following: number of epochs, batch size, and optimizer.  
A different experiment besides the hyperparameter search was made to investigate the changes in the model's performance with data augmentation. After finding the best hyperparameters for the MobileNet-Unet architecture, a different experiment was conducted to investigate the changes in the model's performance with data augmentation. Three experiments with different combinations of transformations were applied in the training dataset to investigate if augmentation could optimize the model's performance. The image augmentation tool, _Imgaug_[30], was used to create geometric transformations, color modifications, and a hybrid technique with both transformations.  
Figure 5: Representation of the nested cross-validation procedure.