# Semantic Segmentation of Packaged and Unpackaged Fresh-Cut Apples Using Deep Learning
## 3 Results and Discussion
### Segmentation Results of Randomly Disposed Packaged Fresh-Cut Apples  
To evaluate the trained network on packaged apples, 1036 images were processed (Table 6). Furthermore, in this case, the trained network achieved a high performance for segmentation: mean accuracy and global accuracy greater than 99% and mean IoU of more than 98%. The mean BF score of the network was 0.99237.  
The randomly disposed packaged apples have one more class to account for the presence of glitter regions due to the reflection of light on the plastic bag. The accuracy of each of the four classes was calculated using the confusion matrix (Table 7) and the class metrics (Table 8) by comparing the ground truth with the results of the network.  
The performance of the network on each class was measured also by the confusion matrix minima (Table 9) and confusion matrix maxima (Table 10).  
The confusion matrix maxima table (Table 10) displays the maximum number of correct classifications and errors made by the network. In total, 4661 peel pixels, 33 background pixels, and 1104 glitter pixels were incorrectly classified as pulp. Additionally, in this case, errors are much less than correct classifications: the misclassified pixels are expected to be statistically not relevant for determining the results of the subsequent colour analysis.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Global Accuracy** & **Mean Accuracy** & **Mean IoU** & **Weighted IoU** & **Mean BF Score** \\ \hline
0.99987 & 0.99398 & 0.98991 & 0.99974 & 0.99237 \\ \hline \hline \end{tabular}
\end{table}
Table 6: Quantitative evaluation metrics of the randomly disposed packaged fresh-cut apples.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Curvacy** & **IoU** & **Mean BF Score** \\ \hline
**Pulp** & 0.9980 & 0.9962 & 0.9945 \\
**Peel** & 0.9977 & 0.9933 & 0.9928 \\
**Background** & 1.0000 & 1.0000 & 0.9999 \\
**Glitter** & 0.9803 & 0.9702 & 0.9803 \\ \hline \hline \end{tabular}
\end{table}
Table 8: Class metrics of the randomly disposed packaged fresh-cut apples.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Accuracy** & **IoU** & **Mean BF Score** \\ \hline
**Pulp** & 0.9980 & 0.9962 & 0.9945 \\
**Peel** & 0.9977 & 0.9933 & 0.9928 \\
**Background** & 1.0000 & 1.0000 & 0.9999 \\
**Glitter** & 0.9803 & 0.9702 & 0.9803 \\ \hline \hline \end{tabular}
\end{table}
Table 9: Classification results of the proposed method.  
A correct and accurate segmentation step, able to serve as the foreground for only the pulp of apple slices where the browning occurs, allows to monitor the shelf-life loss of the fresh-cut apples along the postharvest storage and could be great help for further analysis. The subsequent steps of features' extraction performed on a well-defined region of the image will be more efficient and consistent to predict internal quality parameters strictly related to the shelf-life (or visual quality) of the product. The principal benefits of an objective, consistent and pervasive food control along the entire supply chain, from the producers to the final consumers, are the standardization of quality levels and the timely detection of senescence enabling waste reduction, sales optimization, and customer satisfaction.  
As described earlier, the misclassified pulp pixels are very low in numbers as compared with the correctly labelled pulp pixels. Therefore, the segmentation results on both unpackaged and packaged apples would be significant to assist the quality control assessment on fresh-cut apples in the whole supply chain.