## 5 Results  
### Grape Cluster Size Segmentation Results  
This subsection presents the pixel-based segmentation results obtained. Table 1 enumerates the segmentation method, the color space analyzed, the values of the tunable parameters of each method, the clusters detected, the cluster size estimate error after segmentation (Segm. in Table 1), and the improvement obtained when applying a morphological filtering (Seg. + Morph. Filter in Table 1) for noise removal and the optimal (or minimum) morphological filtering sequence applied, obtained by a trial and error procedure in one sample image. The results of Table 1 have been obtained by analyzing 97 clusters of grapes obtained from 40 vineyard images (see Figure 1). This proposal agrees with [28], where a small amount of labeled images was used to identify the most optimal grape descriptor. In this paper, all of the methods assessed are color dependent, so the optimal results are tuned for the mature reddish grape variety analyzed in this paper; it is expected that the segmentation of damaged grapes, grape varieties with other characteristic skin color or even the same variety, but in another maturity state, may produce different results. In general, Table 1 shows that the detection of non-occluded clusters of grapes is always successful, probably because the skin color variability of the grapes is limited by the use of controlled illumination at night. Then, the quality of the segmentation procedure can be evaluated in a fine way by computing the number of different pixels (false positives and false negatives) between the automatic segmentation provided and the manual labeling of the clusters. The first method (first bloc of rows) illustrated in Table 1 corresponds to the threshold segmentation method applied to different color spaces. In this case, the best segmentation results and the best cluster size estimate were obtained when applying a threshold (0.54902) to the H layer, obtaining an error of 13.55%, improved to 10.01% by applying a morphological filtering sequence (a hole filling (HF) combined with four erosions (4E) and four dilations (4D)). The next method shown is the Mahalanobis segmentation (Mah. Segm. in Table 1) in the RGB and HSV color spaces. The use of the Mahalanobis distance has the advantage that it does not require additional configurable or segmentation parameters, as it only requires the definition of reference templates [4], the determination of the Mahalanobis distance, and the classification of the pixels according to the class of the nearest Mahalanobis class. Table 1 shows that the average size error obtained was 17.36% in the RGB color space and 16.05% in the HSV color space, and these values were improved up to 13.29% and 10.50% by the application of an optimal sequence of morphological operators: four erosions (4E), four dilations (4D) and a hole filling (HF); and three erosions (3E), three dilations (3D) and a hole filling (HF), respectively. The cluster size estimate errors obtained with the Bayesian segmentation (Bay. Segm. in Table 1) in the RGB and HSV color spaces are similar (19.29% and 17.97%). The development of the Bayesian classifier requires the previous definition of the baseline probability for the two classes used: grapes and background. In this paper, the assumption made is that all of the pixels of the image must be members either of the grape or background class, and then, the best separation between both classes was with a pixel prior probability of 43.36% for the grape class and 56.64% for the background class, values obtained by a trial and error procedure during the tuning stage. The errors obtained with the Bayesian classifier were improved up to 13.24% and 10.29% with the application of an optimalsequence of morphological operators: five erosions (5E), five dilations (5D) and a hole filling (HF); and three erosions (3E), four dilations (4D) and a hole filling (HF), respectively.