## 5 Conclusions  
With the widespread application of network technology for uploading images, the demand for image segmentation is growing. This paper addresses the limitations of the Magefreehome algorithm in fine segmentation under complex backgrounds and proposes a series of effective improvements based on in-depth analysis and experimental validation. These improvements include the introduction of a dynamic threshold mechanism, enabling the algorithm to automatically adjust thresholds in response to background variations under different lighting and color conditions, significantly enhancing adaptability. The implementation of a shadow detection mechanism effectively mitigates shadow interference in target detection, further improving accuracy. Additionally, the optimization of the image center point selection strategy ensures more accurate localization of the foreground region during processing, enhancing stability. To address sensitivity to noise and limited robustness, a continuity detection-based method for determining segmentation start and end points was developed, improving the algorithm's generalization ability. These strategies not only preserved the original processing speed but also significantly enhanced accuracy and recall rates, resulting in outstanding performance in segmentation tasks under complex backgrounds. In the future, integrating deep learning techniques could further optimize the adaptability of dynamic thresholds with image backgrounds, explore methods to improve precision, and refine the handling of shadows and noise, thereby bolstering the algorithm's robustness and enabling more precise and efficient image segmentation. Besides these, the OTSU algorithm can struggle with more complex grayscale images, where histograms might not have clear bimodal distributions, which is not included in the algorithm of this paper, and we will further study in the future. Methodology, J.L. ; Experiments, J.L. ; Writing--review and editing, J.L. and X.G. All authors have read and agreed to the published version of the manuscript. This research received no external funding. Not applicable. The program code and research data involved in this paper have been uploaded to the site code ocean, which links to [[https://doi.org/10.24433/CO.5820074.v1](https://doi.org/10.24433/CO.5820074.v1)]([https://doi.org/10.24433/CO.5820074.v1](https://doi.org/10.24433/CO.5820074.v1)) (accessed on 29 August 2024), and the project name is ImageJicer. Please see Appendix A for instructions and precautions. The program code is also uploaded to Github, where the link is [[https://github.com/eating-saint/Tong_img_code1](https://github.com/eating-saint/Tong_img_code1)]([https://github.com/eating-saint/Tong_img_code1](https://github.com/eating-saint/Tong_img_code1)) (accessed on 20 September 2024) or [[https://github.com/eating-saint/Tong_img_code1/blob/main/Tong_code1.py](https://github.com/eating-saint/Tong_img_code1/blob/main/Tong_code1.py)]([https://github.com/eating-saint/[PERSON]_img_code1/blob/main/Tong_code1.py](https://github.com/eating-saint/Tong_img_code1/blob/main/Tong_code1.py)) (accessed on 20 September 2024). The authors gratefully acknowledge the reviewers' professional comments and the editors' support of this work. The authors declare no conflict of interest. Appendix A Project Name: ImageSlicer How to Run the Project: Running this project on the Code Ocean platform is straightforward. Follow these steps:  
1. Start the Run: Click the \"Reproducible Run\" button, which will trigger the main script (run file) in the project. 2. Execute the Main Script: The run file will automatically call the ImageSlicer.py file located in the /code/directory. 3. After the image processing is complete, the results will be saved in the result/result data folder. **Required Data**: The necessary data files are located in the/data folder.