## 3 Materials and Methods
### Development of the Scenario
#### 3.2.2 Image Processing  
At the end of the acquisition of the images, we proceeded to select the type of segmentation to be implemented, according to the characteristics of the AR-Sandbox, in which multi-pigmentation was counted according to the height of the sand. This meant that there were several colors in the sand, and it was necessary to use a method that could have a focus and objective where a specific color was selected with a color model; for this reason, segmentation by color-space was selected.  
According to Reference [24], there are six options for creating image segmentation by using color-space, these are: grayscale, RGB (red, blue, green), HSV (hue, saturation, value), Opp. (opponent color), and LUV and LAB. After the results analysis, the differences between the models were small; among those differences was a high TPR (true positive rate) in the BGR model, which was better than in the others. This rate was the basis for the confusion matrix and the ROC (receiver operating characteristic) curves; for this reason, the BGR model was selected in order to obtain better performance in the prediction results.  
Once the acquisition of images was completed, the image processing stage was commenced; for this purpose, the Python library OpenCV was used, which provides tools to perform segmentation by color-space. The color type and chosen space was the color model BGR (blue, green, red), since the colors of the projections were known in the mentioned scale, which is a requirement for processing. In this case, the reference color was the green equivalent in BGR to (47, 122, 16).  
As a first instance, an image resizing was done, obtaining as a result a dimension of 128 \(\times\) 128 pixels. From the target color and a range of close colors, segmentation by color-space was carried out in order to separate the colors in the image; therefore, the values within these parameters were painted white and the rest of them were black. This is called a mask, which provides a contrast in the image. Making use of the mask, the white part took the green color, while the rest of the image remained black. In order to return to the reference color range to demarcate the contour of the figure, facilitating the identification of shapes in the model of prediction that will be further explained, in Figure 3, the process that was carried out with the circle, square, and triangle is presented, where the captured image, the obtained mask, and the resulting image after having applied the filter are seen.  
From the above, two sets of tests were formed. The first was dataSetOriginal, composed of 90 images in their original state, without applying any type of image processing algorithm. The second was dataSetFilter, composed of 90 images, to which the segmentation method by color-space was applied, in order to be used in the execution of the models generated by the Random Search optimization algorithm. Figure 4 presents the two test sets.  
Figure 3: Segmentation process by color–space.  
Subsequently, two coefficients, Jaccard and Sorensen-Dice were used, which in different ways, provide a probability of similarity between the original image and the image after performing the process of segmentation by color-space. This task was carried out in Matlab, where the Jaccard coefficient and the Sorensen-Dice coefficient were extracted individually for each of the images. All of the results of each coefficient were then grouped, and an average probability of the set of images was given.  
To carry out this process, the original image that was in grayscale was imported to perform the contour analysis with the help of the activeContour function, and then the mask obtained in the segmentation process by color-space was imported to make use of the functions Jaccard and Sorensen-Dice; therefore, for the Jaccard coefficient, a = 0.8221 was obtained, and for the Sorensen-Dice coefficient, a = 0.8767.