## 2 Materials and Methods
### Extraction of Different Color Features from the Objects  
After the segmentation step, connected components are applied in order to find groups of pixels in the images. These connected components correspond mainly to apples, as shown in Figure 3e. Some errors may appear, such as partial occlusion of the apples, false negative pixels, and grouping together different apples due to overlapping. However, for the purpose of estimating the ripening stage, all these problems are negligible.  
Color features are used to describe each detected object. Color has proved to be a very powerful feature to characterize objects in image analysis for agricultural purposes, where the selection of the optimal color space plays an essential role [26]. In this study, two groups of color features were extracted using color models: RGB, HSV, YCrCb, CMY, HSL, and L*u*v*; the definition of these models can be found in [26].  
Let us consider a generic color space with channels (A, B, and C). The first group of extracted features is comprised of the mean of A, mean of B, mean of C, mean of A + B + C, standard deviation of A, standard deviation of B, and standard deviation of C. These values are computed for all the pixels in each object. Therefore, the total number of features extracted from each apple in this stage are 6 color spaces \(\times\) 7 features = 42.  
The second group of color features includes vegetation indices that have been commonly applied in previous studies [27; 28; 29; 30; 31; 32]. Table 2 shows the definition of 14 indices that have previously been used in agricultural application to measure different properties of the objects. In order to obtain additional features, these equations are applied to the six color spaces defined above, although the indices were originally defined for the RGB color space. Thus, total number of features in this second group is 6 color spaces \(\times\) 14 vegetation indices = 84. Summing up, the total number of color features for each apple object including both groups is 42 + 84 = 126.  
\begin{table}
\begin{tabular}{c c} \hline
**Extracted Feature Name** & **Formula Used for Computing the Feature** \\ \hline Normalized red of RGB & R\({}_{n}\) = R/(R + G + B) \\ Normalized green of RGB & G\({}_{n}\) = G/(R + G + B) \\ Normalized blue of RGB & B\({}_{n}\) = B/(R + G + B) \\ Gray channel & Gray = 0.2898 \(\times\) R + 0.5870 \(\times\) G + 0.1140 \(\times\) B \\ Excess green (EXG) [27] & EXG = 2 \(\times\) G\({}_{n}\) - R\({}_{n}\) - B\({}_{n}\) \\ Excess red (EXR) [28] & EXR = 1.4 \(\times\) R\({}_{n}\) - G\({}_{n}\) \\ Color index for extracted vegetation cover (CIVE) [29] & CIVE = 0.441 \(\times\) R\({}_{n}\) - 0.811 \(\times\) G\({}_{n}\) + 0.385 \(\times\) B\({}_{n}\) + 18.78 \\ Excess green minus excess red (EXGR) [30] & EXGR = EXG - EXR \\ Normalized difference index (NDI) [31] & NDI = (G\({}_{n}\) - B\({}_{n}\))/(G\({}_{n}\) + B\({}_{n}\)) \\ Green index minus blue (GB) [27] & GB = (G\({}_{n}\) - B\({}_{n}\)) \\ Red-blue contrast (RBI) [32] & RBI = (R\({}_{n}\) - B\({}_{n}\))/(R\({}_{n}\) + B\({}_{n}\)) \\ Green-red index (ERI) [32] & ERI = (R\({}_{n}\) - G\({}_{n}\))/(R\({}_{n}\) - B\({}_{n}\)) \\ Additional green index (EGI) [32] & EGI = (G\({}_{n}\) - R\({}_{n}\))/(R\({}_{n}\) - B\({}_{n}\)) \\ Additional blue index (EBI) [32] & EBI = (B\({}_{n}\) - G\({}_{n}\))/(B\({}_{n}\) - R\({}_{n}\)) \\ \hline \end{tabular}
\end{table}
Table 2: Color features extracted for each object as vegetation indices.