Segmentation of Crop Residue Using an Open-Source Labeling Tool with U-Net and DeepLabV3
Abstract
1. Introduction
2. Materials and Methods
2.1. Data Collection
2.2. Residue Segmentation Tool
- (1)
- Otsu thresholding [30] automatically determines a binary threshold by maximizing inter-class variance in grayscale histograms. This method is a default setup in the Residue Segmentation Tool.
- (2)
- Canny edge [31] applies edge detection, followed by a 3 × 3 kernel morphological opening and cleaning to generate a binary mask.
- (3)
- Manual thresholding allows users to manually select a grayscale threshold for segmentation.
- (4)
- SAM (Segment Anything Model) implements Meta AI’s pretrained SAM [32] with a ViT-b backbone. The full image is submitted as a bounding box for SAM to automatically generate a residue mask (i.e., no interactive prompting such as point clicks is used). SAM supports more advanced prompting strategies such as point-based or grid-based prompting. However, these were not explored here as the focus of this work is not on prompt engineering but on comparative segmentation performance under standardized conditions. Also, ViT-b backbone has lower computational requirements compared to other variants such as ViT-l and ViT-h.
2.3. Data Preprocessing for ML Training
2.4. Deep Learning Models
2.5. Model Evaluation Metrics and Accuracy Criteria
2.6. Hyperparameter Selection and Statistical Analysis
- Number of epochs = 100
- Optimizer = Adam
- Loss functions = Dice Loss and BCE Loss (equal weighting),
- Learning rate = 1 × 10−4
- Activation function = Sigmoid (applied to model outputs for binary segmentation)
- Threshold for mask = 0.5 (used to binarize the predicted probability masks)
- Random seed = 42 (to ensure reproducibility between two models)
3. Results and Discussion
3.1. Assessment of Residue Segmentation Tool
3.2. Model Performance on Residue Segmentation
3.2.1. Training and Validation Loss and Accuracy
3.2.2. Testing Accuracy on Crop Residue Segmentation
3.2.3. Crop Residue Cover Estimation
4. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Forcella, F.; Buhler, D.D.; McGiffen, M.E. Pest management and crop residues. In Crops Residue Management; CRC Press: Boca Raton, FL, USA, 2018; pp. 173–190. [Google Scholar]
- Morrison, J.E.; Huang, C.-H.; Lightle, D.T.; Daughtry, C.S.T. Residue measurement techniques. J. Soil Water Conserv. 1993, 48, 478–483. [Google Scholar] [CrossRef] [Scilit]
- Cai, W.; Zhao, S.; Zhang, Z.; Peng, F.; Xu, J. Comparison of different crop residue indices for estimating crop residue cover using field observation data. In Proceedings of the 2018 7th International Conference on Agro-Geoinformatics (Agro-Geoinformatics), Hangzhou, China, 6–9 August 2018. [Google Scholar] [CrossRef] [Scilit]
- Hively, W.D.; Shermeyer, J.; Lamb, B.T.; Daughtry, C.T.; Quemada, M.; Keppler, J. Mapping crop residue by combining Landsat and WorldView-3 satellite imagery. Remote Sens. 2019, 11, 1857. [Google Scholar] [CrossRef] [Scilit]
- Laamrani, A.; Joosse, P.; Feisthauer, N. Determining the number of measurements required to estimate crop residue cover by different methods. J. Soil Water Conserv. 2017, 72, 471–479. [Google Scholar] [CrossRef] [Scilit]
- Laflen, J.M.; Mulla, D.J.; Hintz, E.A. Measuring crop residue cover. J. Soil Water Conserv. 1981, 36, 341–343. [Google Scholar] [CrossRef] [Scilit]
- Sullivan, D.G.; Lee, D.; Beasley, J.; Brown, S.; Williams, E.J. Evaluating a crop residue cover index for determining tillage regime in a cotton-corn-peanut rotation. J. Soil Water Conserv. 2008, 63, 28–36. [Google Scholar] [CrossRef]
- Yue, J.; Tian, Q.; Liu, Y.; Fu, Y.; Tian, J.; Zhou, C.; Feng, H.; Yang, G. Mapping cropland rice residue cover using a radiative transfer model and deep learning. Comput. Electron. Agric. 2023, 215, 108421. [Google Scholar] [CrossRef] [Scilit]
- Ding, Y.; Zhang, H.; Wang, Z.; Xie, Q.; Wang, Y.; Liu, L.; Hall, C.C. A comparison of estimating crop residue cover from Sentinel-2 data using empirical regressions and machine learning methods. Remote Sens. 2020, 12, 1470. [Google Scholar] [CrossRef] [Scilit]
- Gao, L.; Zhang, C.; Yun, W.; Ji, W.; Ma, J.; Wang, H.; Li, C.; Zhu, D. Mapping crop residue cover using Adjust Normalized Difference Residue Index based on Sentinel-2 MSI data. Soil Tillage Res. 2022, 220, 105374. [Google Scholar] [CrossRef] [Scilit]
- Lima, F.; Blanco-Sepúlveda, R.; Gómez-Moreno, M.L.; Dorado, J.; Peña, J.M. Mapping tillage direction and contour farming by object-based analysis of UAV images. Comput. Electron. Agric. 2021, 187, 106281. [Google Scholar] [CrossRef] [Scilit]
- Lory, J.A.; Upadhyay, P.; Lagaunne, T.A.P.; Spinka, C.; Miller, R.; Davis, G.; DeSouza, G.N. Capability of high-resolution RGB imagery to accurately document residue in row-crop fields. J. Soil Water Conserv. 2021, 76, 403–413. [Google Scholar] [CrossRef] [Scilit]
- Upadhyay, P.C.; Lory, J.A.; DeSouza, G.N.; Lagaunne, T.A.P.; Spinka, C.M. Classification of crop residue cover in high-resolution RGB images using machine learning. J. ASABE 2022, 65, 75–86. [Google Scholar] [CrossRef] [Scilit]
- Yu, L.; Li, G.; Yu, J.; Bao, L.; Li, X.; Zhang, S.; Yang, J. Effect of conservation tillage on seedling emergence and crop growth-evidences from UAV observations. Cogent Food Agric. 2023, 9, 2240164. [Google Scholar] [CrossRef] [Scilit]
- Riegler-Nurscher, P.; Prankl, J.; Bauer, T.; Strauss, P.; Prankl, H. A machine learning approach for pixel wise classification of residue and vegetation cover under field conditions. Biosyst. Eng. 2018, 169, 188–198. [Google Scholar] [CrossRef] [Scilit]
- Schindelin, J.; Arganda-Carreras, I.; Frise, E.; Kaynig, V.; Longair, M.; Pietzsch, T.; Preibisch, S.; Rueden, C.; Saalfeld, S.; Schmid, B.; et al. Fiji: An open-source platform for biological-image analysis. Nat. Methods 2012, 9, 676–682. [Google Scholar] [CrossRef] [Scilit]
- Bauer, T.; Strauss, P. A rule-based image analysis approach for calculating residues and vegetation cover under field conditions. CATENA 2014, 113, 363–369. [Google Scholar] [CrossRef] [Scilit]
- Achanta, R.; Shaji, A.; Smith, K.; Lucchi, A.; Fua, P.; Süsstrunk, S. SLIC superpixels compared to state-of-the-art superpixel methods. IEEE Trans. Pattern Anal. Mach. Intell. 2012, 34, 2274–2282. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Gao, G.; Zhang, S.; Shen, J.; Hu, K.; Tian, J.; Yao, Y.; Tian, Q.; Fu, Y.; Feng, H.; Liu, Y.; et al. Segmentation and proportion extraction of crop, crop residues, and soil using digital images and deep learning. Agriculture 2024, 14, 2240. [Google Scholar] [CrossRef] [Scilit]
- Russell, B.C.; Torralba, A.; Murphy, K.P.; Freeman, W.T. LabelMe: A database and web-based tool for image annotation. Int. J. Comput. Vis. 2008, 77, 157–173. [Google Scholar] [CrossRef] [Scilit]
- Lyu, Y.; Vosselman, G.; Xia, G.-S.; Yang, M.Y. Bidirectional multi-scale attention networks for semantic segmentation of oblique UAV imagery. ISPRS Ann. Photogramm. Remote Sens. Spat. Inf. Sci. 2021, V-2-2021, 75–82. [Google Scholar] [CrossRef] [Scilit]
- Li, L.; Li, J.; Lv, C.; Yuan, Y.; Zhao, B. Maize residue segmentation using Siamese domain transfer network. Comput. Electron. Agric. 2021, 187, 106261. [Google Scholar] [CrossRef] [Scilit]
- Ronneberger, O.; Fischer, P.; Brox, T. U-Net: Convolutional networks for biomedical image segmentation. In Medical Image Computing and Computer-Assisted Intervention; Navab, N., Hornegger, J., Wells, W.M., Frangi, A.F., Eds.; Springer International Publishing: Berlin/Heidelberg, Germany, 2015; pp. 234–241. [Google Scholar]
- Chen, L.-C.; Papandreou, G.; Schroff, F.; Adam, H. Rethinking atrous convolution for semantic image segmentation. arXiv 2017. [Google Scholar] [CrossRef] [Scilit]
- Aszkowski, P.; Kraft, M.; Drapikowski, P.; Pieczyński, D. Estimation of corn crop damage caused by wildlife in UAV images. Precis. Agric. 2024, 25, 2505–2530. [Google Scholar] [CrossRef] [Scilit]
- Ullah, M.; Islam, F.; Bais, A. Quantifying consistency of crop establishment using a lightweight U-Net deep learning architecture and image processing techniques. Comput. Electron. Agric. 2024, 217, 108617. [Google Scholar] [CrossRef] [Scilit]
- Zhou, Y.; Wang, J.; Song, Z.; Zhou, M.; Lv, M.; Han, X. Estimation of tree canopy closure based on U-Net image segmentation and machine learning algorithms. Remote Sens. 2025, 17, 1828. [Google Scholar] [CrossRef] [Scilit]
- Wang, Y.; Gao, X.; Sun, Y.; Liu, Y.; Wang, L.; Liu, M. Sh-DeepLabv3+: An improved semantic segmentation lightweight network for corn straw cover form plot classification. Agriculture 2024, 14, 628. [Google Scholar] [CrossRef] [Scilit]
- Liu, Y.; Zhang, J.; Wang, Y.; Luo, Y.; Sui, P.; Ren, Y.; Liu, X.; Wang, J. GCF-DeepLabv3+: An improved segmentation network for maize straw plot classification. Agronomy 2025, 15, 1011. [Google Scholar] [CrossRef] [Scilit]
- Otsu, N. A threshold selection method from gray-level histograms. IEEE Trans. Syst. Man Cybern. 1979, 9, 62–66. [Google Scholar] [CrossRef] [Scilit]
- Canny, J. A computational approach to edge detection. IEEE Trans. Pattern Anal. Mach. Intell. 1986, 8, 679–698. [Google Scholar] [CrossRef] [Scilit]
- Kirillov, A.; Mintun, E.; Ravi, N.; Mao, H.; Rolland, C.; Gustafson, L.; Xiao, T.; Whitehead, S.; Berg, A.C.; Lo, W.-Y. Segment anything. In Proceedings of the IEEE/CVF International Conference on Computer Vision, Paris, France, 1–6 October 2023; pp. 4015–4026. [Google Scholar]
- Paszke, A.; Gross, S.; Chintala, S.; Chanan, G.; Yang, E.; DeVito, Z.; Lin, Z.; Desmaison, A.; Antiga, L.; Lerer, A. Automatic differentiation in pytorch. In Proceedings of the Advances in Neural Information Processing Systems 30 (NIPS 2017), Long Beach, CA, USA, 4–9 December 2017. [Google Scholar]
- Chen, L.-C.; Zhu, Y.; Papandreou, G.; Schroff, F.; Adam, H. Encoder-decoder with atrous separable convolution for semantic image segmentation. In Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany, 8–14 September 2018; pp. 801–818. [Google Scholar]
- Krig, S. Computer Vision Metrics, 1st ed.; Springer: Cham, Switzerland, 2016. [Google Scholar] [CrossRef] [Scilit]
- Taha, A.A.; Hanbury, A. Metrics for evaluating 3D medical image segmentation: Analysis, selection, and tool. BMC Med. Imaging 2015, 15, 29. [Google Scholar] [CrossRef] [Scilit]








| Feature | Description |
|---|---|
| Load Folder | Imports all image files in selected directory |
| Segmentation Modes | Otsu, Canny, Manual, SAM (to get started with initial mask) |
| Draw Polygon Mask | Adds selected region to mask |
| Draw Subtract Polygon | Removes selected region from mask |
| Brush/Eraser | Freehand pixel-wise editing with adjustable size |
| Invert Mask | Toggles black/white (foreground/background) pixels |
| ROI Crop + Resize | Crops region of interest and rescales to full image size |
| Overlay Mode | Shows mask transparency on original image |
| Histogram Plot | Visual aid for grayscale distribution |
| Batch Segment + Export | Folder-wide mask generation with structure |
| Confirm Mask | Required step to confirm the current mask before saving. Also displays crop residue cover percentage on current segmented image once confirmed |
| Save Image + Mask | Exports matching .png files into images/and masks/folders |
| Metrics | U-Net | DeepLabV3 | ||||
|---|---|---|---|---|---|---|
| DS = 70 | DS = 175 | DS = 350 | DS = 70 | DS = 175 | DS = 350 | |
| Dice (mean) | 0.634 | 0.728 | 0.748 | 0.540 | 0.660 | 0.684 |
| Dice (std) | 0.264 | 0.170 | 0.180 | 0.246 | 0.204 | 0.206 |
| IoU (mean) | 0.517 | 0.599 | 0.627 | 0.410 | 0.526 | 0.555 |
| IoU (std) | 0.276 | 0.201 | 0.212 | 0.244 | 0.224 | 0.235 |
| Accuracy (mean) | 0.740 | 0.834 | 0.864 | 0.731 | 0.825 | 0.848 |
| Accuracy (std) | 0.171 | 0.141 | 0.113 | 0.201 | 0.116 | 0.119 |
| Precision (mean) | 0.553 | 0.708 | 0.719 | 0.592 | 0.648 | 0.658 |
| Precision (std) | 0.294 | 0.229 | 0.226 | 0.248 | 0.212 | 0.197 |
| Recall (mean) | 0.937 | 0.847 | 0.864 | 0.651 | 0.744 | 0.758 |
| Recall (std) | 0.128 | 0.178 | 0.170 | 0.305 | 0.233 | 0.223 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Regmi, S.; Allen, C.M. Segmentation of Crop Residue Using an Open-Source Labeling Tool with U-Net and DeepLabV3. AgriEngineering 2026, 8, 228. https://doi.org/10.3390/agriengineering8060228
Regmi S, Allen CM. Segmentation of Crop Residue Using an Open-Source Labeling Tool with U-Net and DeepLabV3. AgriEngineering. 2026; 8(6):228. https://doi.org/10.3390/agriengineering8060228
Chicago/Turabian StyleRegmi, Sagar, and Cody M. Allen. 2026. "Segmentation of Crop Residue Using an Open-Source Labeling Tool with U-Net and DeepLabV3" AgriEngineering 8, no. 6: 228. https://doi.org/10.3390/agriengineering8060228
APA StyleRegmi, S., & Allen, C. M. (2026). Segmentation of Crop Residue Using an Open-Source Labeling Tool with U-Net and DeepLabV3. AgriEngineering, 8(6), 228. https://doi.org/10.3390/agriengineering8060228
