# Automatic System for the Detection of Defects on Olive Fruits in an Oil Mill
## 3 Results and Discussion
### Evaluation Procedure for the Image Processing Algorithm  
The image processing goal is to detect the percentage of defective olives from the images acquired using the infrared camera (Nano M2590-NIR) placed over the conveyor belt after the washing stage. For this, olives are segmented and then every segmented region is independently processed in order to extract defects. Figures 7 and 8 show the results of the olive segmentation step for two different types of images. As can be seen, the quantity of olives on the conveyor belt has an influence in the segmentation results. When the conveyor is not completely full (Figure 7a) olives are successfully extracted even though they touch each other. The application of the two segmentations steps presented in the previous Section manages to extract all the fruits, along with part of the conveyor belt (Figure 7b,c). The regions that belong to the conveyor belt have a significantly different shape than those from the fruits. These regions can be removed from the final result using the region elongation as decision feature, (Figure 7d).  
When the conveyor belt is completely full, some fruits are included in the same region (Figure 8d). This issue mainly occurs when the image is not properly lighted (left  
Figure 6: Classification algorithm based on a decision tree that evaluates descriptors of the region such as area, circularity and elongation.  
side of the conveyor belt) or when there is too much overlap among fruits. Despite this drawback, most of the fruits can be analysed, as they are extracted from the background. Figure 8b shows the preprocessing stage, while Figure 8c depicts the result of the two level segmentation process.  
The results of the olive inspection procedure for the former examples are shown in Figure 9. The regions extracted from the segmented oliv  
Figure 8: Example of olive segmentation (conveyor belt completely full). (**a**) Image acquisition. (**b**) Result of the preprocessing step: global thresholding mask in magenta and adaptative thresholding mask in green. (**c**) Level one (magenta) and level two (green) segmentation. (**d**) Final segmentation result.  
Figure 7: Example of olive segmentation (conveyor belt not completely full). (**a**) Image acquisition. (**b**) Result of the preprocessing step: global thresholding mask in magenta and adaptative thresholding mask in green. (**c**) Level one (magenta) and level two (green) segmentation. (**d**) Final segmentation result.  
non-defective by the classification algorithm detailed in Figure 6. A segmented olive is labelled as defective when at least one region inside it is detected as defective.  
In order to assess the algorithm performance, a set of five images per day were manually labelled, using a graphic editor, with the oil mill expert assistance. Figure 10 shows an example of these images that were utilized as ground-truth. Then, the same set of images were analysed by the image processing algorithm, and the results of region comparisons were categorized and annotated according to the following definitions:  
* TP (true positive): olives or set of olives labelled and detected as defective.
* FN (false negative): olives or set of olives labelled as defective but classified as non-defective.
* FP (false positive): olives or set of olives labelled as non-defective but classified as defective.
* TN (true negative): olives or set of olives labelled and detected as non-defective.  
This way, true positive and false positive rates (TPR, FPR) were computed as:  
\[TPR=\frac{TP}{TP+FN}\cdot 100\ ;\ \ \ FPR=\frac{FP}{FP+TN}\cdot 100. \tag{16}\]  
Figure 10: Example of ground-truth (including a zoom view) for the evaluation of the Image Processing Algorithm.  
Figure 9: Defect detection. **(a)** Figure 7 defective olives detection. **(b)** Figure 8 defective olives detection.  
Thus, the detection rate is given by \(TPR\), while \(FPR\) provides the rate of non-defective olives wrongly categorized as defective.