# Semantic Segmentation of Packaged and Unpackaged Fresh-Cut Apples Using Deep Learning
## 3 Results and Discussion
### Semantic Segmentation Results of the Randomly Disposed Unpackaged Fresh-Cut Apples  
To evaluate the trained network, 1008 images were processed (Table 1). The network of the randomly disposed unpackaged apples showed a very good performance of segmentation. The network achieved a mean accuracy, global accuracy, and mean IoU all greater than 99%. Moreover, the network attained a 0.99411 mean BF score.  
Figure 14: Segmentation results for randomly disposed packaged fresh-cut Granny Smith greenish apples. The red label is associated with the class glitter.  
Figure 13: Segmentation results for randomly disposed packaged fresh-cut Pink Lady reddish apples. The red label is associated with the class glitter.  
Figure 15: Segmentation results for randomly disposed packaged fresh-cut Golden yellowish apples. The red label is associated with the class glitter.  
Full information about the performance on each of the three classes in the randomly disposed unpackaged fresh-cut apples was measured by the confusion matrix (Table 2) and the class metrics (Table 3).  
The confusion matrix minima (Table 4) and confusion matrix maxima (Table 5) were evaluated over the complete test set: they provide useful hints about the performance of the method in the best (minima) and the worst (maxima) cases.  
The confusion matrix maxima (Table 5) shows that a maximum of 33,431 and 131 pulp pixels were incorrectly assigned to the classes peel and background. They will be ignored by the subsequent colour analysis of the computer vision system under development. Moreover, 3485 is the maximum number of peel pixels incorrectly assigned to the class pulp. No background pixels were incorrectly assigned to the pulp class. These two numbers are the most relevant ones; these pixels would bias the colour analysis, bringing into colour analysis contributions from parts of the images that do not exhibit relevant signs of senescence. Nonetheless, the low number of these pixels, with respect to the correctly classified ones, suggest that their statistical contribution to determining the results of classification and regression will be negligible.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Global** & **Mean Accuracy** & **Mean IoU** & **Weighted IoU** & **Mean BF Score** \\ \hline
0.99977 & 0.9966 & 0.99394 & 0.99954 & 0.99411 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Quantitative evaluation metrics of the network trained for randomly disposed unpackaged fresh-cut apples.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Accuracy** & **IoU** & **Mean BF Score** \\ \hline
**Pulp** & 0.9991 & 0.9962 & 0.9953 \\
**Peel** & 0.9908 & 0.9857 & 0.9868 \\
**Background** & 1.0000 & 1.0000 & 0.9999 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Class metrics on the randomly disposed unpackaged fresh-cut apples.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Pulp** & **Peel** & **Background** \\ \hline
**Pulp** & 62,080 & 0 & 0 \\
**Peel** & 0 & 0 & 0 \\
**Background** & 0 & 0 & 2,584,232 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Confusion matrix minima over the testing dataset.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Pulp** & **Peel** & **Background** \\ \hline
**Pulp** & 283,229 & 33,431 & 131 \\
**Peel** & 3485 & 155,323 & 1604 \\
**Background** & 0 & 184 & 2,849,891 \\ \hline \hline \end{tabular}
\end{table}
Table 5: Confusion matrix maxima over the testing dataset. The first column is especially relevant: it shows the number of pixels misclassified as pulp while belonging to peel or background.  
Moreover, Tables 4 and 5 show that most of the pixels of each image have been correctly labelled by the network: the number on the diagonal is much larger than that of off-diagonal ones, corresponding to a different type of misclassification.