## 2 Materials and Methods
### Feature Extraction  
To obtain color features, three histograms \(\{P_{R}\), \(P_{G}\), \(P_{B}\}\) were generated. One histogram was obtained from each RGB channel. Five statistical attributes were computed for each channel: the average value \(\mu=\sum_{I=0}^{255}P(I)\), variance \(\sigma^{2}=\sum_{I=0}^{255}P(I)\) \(\left(I-\mu\right)^{2}\), skewness \(m_{3}=\sum_{I=0}^{255}P(I)\) \(\left(I-\mu\right)^{3}\), kurtosis \(m_{4}=\sum_{I=0}^{255}P(I)\) \(\left(I-\mu\right)^{4}\), and entropy \(H=-\sum_{I=0}^{255}P(I)\) \(log_{2}P(I)\). Figure 3 shows the three RGB channels of an apple slice and the corresponding histograms. For texture analysis, the color image was transformed into a grayscale image using the luminosity model, which consists of a weighted average of the RGB channels: \(\mathbf{I}=\mathbf{0.21R}+\mathbf{0.72G}+\mathbf{0.07B}\). According to the luminosity model, the green channel is the one that contributes the most, which agrees with the fact that green is the dominant color in apples. Textural features convey statistical information about the relative positions of the pixel intensity values within the region of interest. Textural features are obtained from the gray level co-occurrence matrix (GLCM), which specifies the distribution of pairs of pixel intensities according to the distance between these two pixels and the angle of the line segment that joins them. There are four possible angles: \(0^{\circ}\) (horizontal), \(45^{\circ}\) (diagonal), \(90^{\circ}\) (vertical), and \(135^{\circ}\) (anti-diagonal). The GLCM of a pair of pixel intensities \((\mathbf{I}_{m},\mathbf{I}_{n})\) at distance \(\mathbf{d}\) and angle \(\mathbf{\varphi}\) is defined as  
\[\mathbf{P}(\mathbf{I}_{m},\mathbf{I}_{n},\mathbf{d},\mathbf{\varphi})\mathbf{=}\frac{Number\ of\ pairs\ (\mathbf{I}_{m},\ \mathbf{I}_{n})\ at\ distance\ \mathbf{d}\ and\ angle\ \varphi}{Total\ number\ of\ possible\ pairs}\]  
where \(\mathbf{m},\mathbf{n}\mathbf{=}\mathbf{1},\mathbf{2},\ldots,\mathbf{N}\), and \(\mathbf{N}\) is the number of pixel intensities. Seven textural features were computed from the GLCM: (1) the angular second moment \(ASM\mathbf{=}\sum_{\mathbf{m}=1}^{N}\sum_{\mathbf{m}=1}^{N}\mathbf{P}(\mathbf{I}_{m},\ \mathbf{I}_{n},\ \mathbf{d},\ \mathbf{ \varphi})^{2}\), (2) the contrast \(\mathbf{C}\mathbf{=}\sum_{\mathbf{m}=1}^{N}\mathbf{I}^{2}\) \(\left[\sum_{\mathbf{m}=1}^{N}\sum_{\mathbf{m}=1,\ |\  
Shape length features were extracted from apple slices. First, the boundary contour of an apple slice was detected to obtain a sequence of straight-line segments. A straight-line segment joins two adjacent boundary pixels, and it is assigned a code number depending on its direction, as in Figure 4, where eight straight line segments are shown along with their code numbers {0, 1, 2, 3, 4, 5, 6, 7}. The sequence of segment codes obtained from the boundary contour is called chain code [20,21]. Next, an eight-entry histogram was generated from the chain code, where each entry is the number of times a code number occurs, within the chain code, divided by the chain length. This histogram contributes eight shape features, also known as direction length descriptors. Shape curvature is another shape descriptor [21], which is the frequency of occurrence of groups of external concave angles (smaller than 180\({}^{\circ}\)) and groups of external convex angles (larger than 180\({}^{\circ}\)). An external angle was formed between two adjacent straight-line segments, which were part of the boundary contour of an apple slice, scanned in the clockwise direction. Two groups of convex angles and two groups of concave angles are shown in Figure 5.  
Figure 3: Set of histograms for the three RGB channels of an apple slice. The first half of the upper row is a group of three concave angles where the first code is 0. The second half of the upper row is a show of three concave angles where the first code is 1.