## 4 Conclusions  
In this paper, an image segmentation algorithm based on adaptive bilateral filtering for SSR image enhancement and a region-growing algorithm were proposed for filtering out the interference of uneven light reflectivity and segmenting the defects. A limitation of this method was that it could not differentiate between stems/calyxes and scars. To solve this problem, an algorithm for stem/calyx recognition based on texture features was also introduced. Finally, a defect detection algorithm was developed from the two methods. The algorithm could take only the segmentation results of real scars as the final results. Deploying the proposed defect detection algorithm into the embedded image processing module OpenMV4H7 Plus, the accuracy of stem/calyx recognition was 93.7%, and the accuracy of scar detection was 94.2%. The results show that the proposed defect detection algorithm can complete the extraction of apple surface defects and exclude the interference of stems/calyxes in the case of uneven light reflectivity. The proposed defect detection algorithm can be applied to the detection problem.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Defect Type** & **Sample Size** &
\begin{tabular}{c} **Number of Correct Disease** \\ **Condition Judgments** \\ \end{tabular} & **Accuracy (\%)** \\ \hline Normal-stem & 70 & 67 & 95.7 \\ Normal-calyx & 70 & 65 & 92.8 \\ Scar-light browning & 70 & 64 & 91.4 \\ Scar-heavy browning & 70 & 68 & 97.1 \\ Total & 280 & 264 & 94.2 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Detection accuracy of two types of defects under the proposed algorithm.  
Figure 17: Detection effect of the proposed defect detection method. (**a**) Apple samples; (**b**) detection results of the proposed defect detection method.  
detection algorithm could be used in automated apple defect detection systems to increase productivity and reduce labor costs. This may have wide applications in orchards and food processing plants.  
In addition, an issue that was not addressed in this study is whether the segmentation method suffers from over-segmentation for scars with large areas of obvious decay grading. Although it does not affect the overall segmentation and extraction of scars and the judgment of the health of the apple, it causes an additional increase in the number of scars counted. Further research is needed to follow up on this issue.  
All authors conceived and designed the study. Validation, writing--review and editing, and supervision, L.Y.; conceptualization, methodology, software, validation, and writing--original draft preparation, D.M.; validation and visualization, Z.X.; validation and investigation, K.H. All authors have read and agreed to the published version of the manuscript.  
This research was funded by the National Natural Science Foundation of China Original Exploration Program under Grant 42050103, the University-Industry Collaborative Education Program of Ministry of Education of China under Grant 220604307204001 and the Science and Technology Plan Project of Hubei Provincial Department of Transportation under Grant 201472111.  
Not applicable.  
The data presented in this study are available on request from the first author. The data are not publicly available due to intellectual property considerations.  
The authors declare no conflict of interest.