Abstract
While existing synthetic generation methods, such as Generative Adversarial Networks (GANs) and Diffusion Models, typically require large pre-existing datasets and substantial computational resources, this paper presents AgrySET: a novel hardware–software framework that bypasses these limitations. The system utilizes a four-camera high-resolution array and a setup that replicates industrial environmental conditions. Unlike purely algorithmic approaches, by employing Gaussian models for data generation on physically acquired samples, the framework actively addresses class imbalance issues and synthesizes realistic agricultural imagery alongside exact, pixel-perfect segmentation masks without manual pixel-level annotation after initial sample acquisition. As a case study, the segmentation of healthy coffee beans and seven defects as categorized by the National Federation of Coffee Growers of Colombia was performed. Models trained exclusively on this synthetic dataset achieved a Mean Intersection over Union (mIoU) of 92.9% in a 3-class configuration and 61.9% in a detailed 9-class scenario. When evaluated against real-world datasets, the model yielded accuracies of 90% and 58%, respectively. Furthermore, the automated pipeline accelerated the data generation and segmentation workflow by an estimated factor of 250 compared to manual execution. These quantitative results demonstrate the feasibility of AgrySET as a baseline synthetic framework for coffee bean inspection, highlighting its potential for future adaptation to other granular agricultural commodities.
1. Introduction
The global agricultural sector is facing an unprecedented crisis: the challenge of feeding a growing population under the pressures of climate change and biodiversity loss [1]. In this context, precision agriculture serves as a vital solution, utilizing cost-effective, intelligent technologies to optimize input usage. This approach facilitates a shift from conventional methods toward highly automated management systems that maximize efficiency per square meter [2]. Within this technological evolution, coffee cultivation has emerged as a primary focus of research, where precision agriculture techniques are being intensively explored to enhance sustainability and productivity [3]. The integration of Cyber-Physical Systems (CPS) and the Internet of Things (IoT) has further accelerated this transition, enabling real-time monitoring of crop health and environmental variables. However, the true transformative power of these systems lies in their ability to process vast amounts of visual data through advanced computational frameworks.
The primary drivers of this transformation are Artificial Intelligence (AI) and Deep Learning (DL), which specialize in developing mathematical models that learn directly from data [4]. These fields employ diverse architectures, ranging from statistical methods like Logistic Regression (LR) [5] and Expectation–Maximization (EM) [6] to complex structures such as Convolutional Neural Networks (CNN) [7] and Support Vector Machines (SVM) [8]. While traditional machine learning relies on handcrafted features, DL architectures autonomously extract hierarchical representations, allowing for a more nuanced understanding of complex biological patterns in agricultural products.
Deep Learning has played a pivotal role in precision agriculture [9], particularly in object detection [10] and semantic segmentation [11], due to its ability to extract pixel-level information with high precision. For instance, in greenhouse farming [12], semantic segmentation enables detailed crop monitoring, including canopy area estimation, plant height measurement, and fruit maturity analysis. Furthermore, pest segmentation [13] allows for targeted pesticide application. In coffee production specifically, multispectral imaging combined with machine learning has proven effective for both estimating plant yield [14] and the early detection of critical diseases such as coffee leaf rust (Hemileia vastatrix) [15,16]. These applications demonstrate that the granularity of semantic segmentation is essential for tasks where the mere presence of an object is insufficient, and its exact shape, size, and texture determine the subsequent agricultural intervention.
Despite the power of DL, the availability of high-quality data often limits model robustness, especially for tasks requiring pixel-precise annotations [17]. Manual annotation is time-consuming, expensive, and susceptible to human error and inter-observer variability. Consequently, obtaining large-scale annotated datasets remains a significant bottleneck for supervised learning. This “data hunger” is particularly problematic in specialized domains where expert knowledge is required to distinguish between subtle morphological features. While synthetic generation methods like Denoising Diffusion Probabilistic Models (DDPM), Generative Adversarial Networks (GANs) [18], and Variational Autoencoders (VAEs) [19] have made strides, they are often restricted to inpainting [20], super-resolution, or text-to-image generation [21]. Furthermore, these generative models frequently require substantial computational resources and a pre-existing large dataset to train effectively, creating a paradoxical barrier for low-resource agricultural applications.
In the specific case of the coffee industry, quality assessment is a critical factor for international market competitiveness. The classification of green coffee beans traditionally relies on manual inspection by certified “catadores,” a process that is difficult to scale and standardize across large production volumes. Semantic segmentation offers a path toward industrial automation; however, the scarcity of publicly available, high-resolution datasets of diverse coffee defects hinders the development of deployable AI solutions.
Therefore, this paper proposes AgrySET, a holistic hardware–software framework designed to bridge the sim-to-real gap in agricultural semantic segmentation. Unlike conventional data augmentation techniques or computationally heavy generative models (such as GANs and diffusion models) that often introduce artifacts or demand extensive preliminary data, AgrySET employs a deterministic, procedural synthesis approach. By combining a synchronized high-resolution multi-camera array with Gaussian probability modeling derived from industrial milling statistics, the framework autonomously generates high-fidelity imagery and exact pixel-level ground truth masks while natively solving class imbalance. The framework is evaluated within the agricultural domain, focusing on the segmentation of high-quality coffee beans and seven defects categorized by the National Federation of Coffee Growers of Colombia. Specifically, the performance of a segmentation model trained solely on generated synthetic data is externally validated using real-world images from the local industry. The contributions of this work include: (i) a novel hardware–software pipeline for high-resolution synthetic data synthesis, (ii) a methodology to mitigate class imbalance in defect detection, and (iii) a comparative analysis demonstrating the transferability of synthetic-to-real knowledge in agricultural vision tasks.
2. Materials and Methods
This section details the hardware and software components integrated into the development of the framework for generating synthetic datasets tailored for semantic segmentation in precision agriculture. The proposed system, AgrySET, comprises a high-resolution acquisition module and a specialized processing pipeline designed to ensure data fidelity and annotation accuracy.
2.1. Hardware Components
The synthetic database generation system begins with the construction of a stable platform designed to house the samples and high-resolution cameras at a constant distance of 25 cm. To ensure total reproducibility and eliminate ambient light interference, the platform features a closed protective enclosure. Inside, a dedicated diffused LED lighting source (operating at a standardized color temperature of 6500 K/Daylight) is distributed uniformly to maintain homogeneous, shadow-free luminous conditions across the entire Field of View (FoV). The platform design is illustrated in Figure 1.
Figure 1.
Schematic diagram of the image acquisition platform.
The platform measures 80 cm in height, 70 cm in width, and 70 cm in depth. Internally, it features an acquisition area of 50 cm by 50 cm and an adjustable focal distance of 25 cm for four cameras. The platform is engineered to simulate the passage of a conveyor belt through its interior accounting for potential elevation changes while acquiring high-resolution imagery. Internally, four Intel RealSense D435 cameras [22] are positioned on an adjustable mount to control the working distance from the samples, as shown in Figure 2.
Figure 2.
Spatial configuration of the Intel RealSense D435 cameras.
The Intel RealSense D435 sensors were selected for their hardware-level capability to acquire synchronized RGB and Infrared (IR) streams. While the physical capture framework records both modal streams to build a multimodal repository for extended research, the segmentation benchmark in this study relies exclusively on high-resolution RGB data. This design choice prioritizes the precise chromatic fidelity and surface morphological features required by the National Federation of Coffee Growers’ (FNC) visual standards. Following hardware integration, a rigorous calibration process was conducted to ensure simultaneous acquisition and the spatial continuity of the segmentation masks. This process is divided into two critical phases:
- Intrinsic Characterization
Each sensor was individually calibrated using a checkerboard pattern. This procedure determines the camera matrix (K), which maps 3D world coordinates to 2D image plane coordinates:
where and represent focal lengths, and denotes the principal point. Additionally, radial distortion coefficients () were estimated to correct the “barrel” effect induced by the D435’s wide-angle lenses, ensuring that straight lines within the industrial environment remain preserved in the synthetic data.
- Extrinsic Characterization
Since the AgrySET system fuses four fields of view (FoV) into a single composite image of pixels, transformation matrices (Rotation and Translation) were defined relative to a global coordinate system located at the center of the conveyor belt.
- Nadir Alignment: Cameras were positioned at a tilt angle relative to the workspace normal to minimize perspective distortion.
- Security Overlap: A 15% overlap between adjacent areas was established to facilitate the control-point-based stitching algorithm. This ensures that beans located at sensor boundaries do not exhibit morphological discontinuities that could degrade the performance of the DeepLab network.
The mean reprojection error after calibration was pixels. Although the D435 includes a depth sensor, AgrySET prioritized the high-resolution RGB sensor to maintain the chromatic fidelity required by the National Federation of Coffee Growers standards. Finally, rigorous image quality control procedures were implemented at the software level. Automatic white balance and auto-exposure settings were permanently disabled and manually locked across all four sensors to prevent inter-camera color variance and temporal brightness shifts. This ensures chromatic consistency across all synthesized grains regardless of the acquisition batch. Additionally, image sharpness was continuously monitored during acquisition to prevent focus degradation, ensuring that the defined metric correspondence of per pixel remained strictly accurate for sub-millimeter defect detection.
2.2. Software Components
The system was programmed in Python 3.9 to enable the synchronous acquisition of four images in both RGB and IR formats. These are integrated into a single high-resolution output using an image stitching methodology [23], as shown in Figure 3.
Figure 3.
Image stitching of individual coffee bean samples.
The images are fused in pairs to ensure precise feature matching, generating two intermediate images before repeating the process to create a final composite with four times the original dimensions. The selection of a multi-camera stitching approach over a single wide-angle sensor was crucial to maximize the Field of View (effectively covering an industrial conveyor belt) while strictly preserving the high spatial resolution ( per pixel) required to detect sub-millimeter defects like insect holes. To achieve seamless alignment, a visual overlap of up to 15% is required; consequently, the final image dimensions may vary. To standardize the output, a resampling process is performed using resolution adjustment based on diffusion models [24]. This specific method was chosen over traditional interpolation techniques (e.g., bilinear or bicubic resampling) because standard algorithms tend to smooth and blur high-frequency details during resizing. Diffusion-based resampling, conversely, standardizes the image dimensions while actively preserving edge sharpness and textural fidelity. This ensures that the subtle morphological characteristics of the defective beans remain crisp and uncompromised for the subsequent DeepLabV3+ segmentation.
2.3. Sample Acquisition and Processing
The database creation process begins with the individual acquisition of samples for each defined class. This approach is strategically implemented to mitigate class imbalance, a recurrent challenge that significantly impacts the performance of semantic segmentation frameworks [25]. For this case study, a dataset for coffee bean defect detection was developed using samples provided by the automated milling plant at the Center for Agricultural Innovation and Productivity (CINGTAGRO). Images were captured for each specific type of defect, and these defects are described in Table 1.
Table 1.
Classification of physical defects in green coffee, their main origin in the value chain, and their sensory impact on cup quality [26].
Although the National Federation of Coffee Growers of Colombia (FNC) defines a comprehensive classification standard covering 14 categories of physical defects, this study selects a representative subset of seven major defect classes (black, sour, immature, severe borer damage, cut/bite, discolored, and peaberry) alongside healthy Excelso-grade beans and the background material for experimental evaluation. This selection is justified by both their empirical prevalence and their suitability for optical inspection: firstly, an empirical audit of commercial coffee samples analyzed at CINTAGRO confirmed that these seven defect categories account for the vast majority of physical defects observed in regional coffee processing lines; secondly, these specific categories exhibit distinctive surface chromatic and morphological anomalies that can be detected using 2D RGB imaging from a top-down view.
Once the classes were defined, acquisition was carried out under standardized conditions. Regarding the coffee samples, multiple images were captured for each bean, varying the orientation (face) and angle to record the maximum number of morphological features. Subsequently, each image underwent a preprocessing stage utilizing Canny edge detection [27] to extract clean contours. This workflow is detailed in Figure 4.
Figure 4.
Class acquisition and preprocessing. (Left): Original image. (Center): Image mask. (Right): Processed image.
The Canny algorithm accurately identifies the grain contours due to the high contrast between the background and the samples. This facilitates the generation of new images, as the lighting conditions remain invariant throughout the database creation process.
2.4. Synthetic Image Database Generation
Following acquisition and preprocessing, synthetic images are generated by overlaying the target classes onto a background. In this specific implementation, defective coffee bean images are superimposed onto a background of high-quality (Excelso) grains, emulating the visual conditions of the CINGTAGRO conveyor belts, as shown in Figure 5.
Figure 5.
Overlaying defective coffee beans onto healthy grain backgrounds. (A): Original image. (B): Superimposed defects.
The synthetic image generation pipeline operates in a two-stage procedural architecture: asset library creation and full-scene procedural assembly. First, a Source Asset Library containing 300 individual cropped images per defect class (along with their corresponding Canny-derived binary masks) was physically acquired and extracted from samples provided by CINTAGRO. Utilizing the data from Table 2, a Gaussian probability model was implemented. The assumption of a Gaussian distribution was not arbitrary; it was statistically validated using the 1400 physical samples analyzed at CINTAGRO. A Kolmogorov-Smirnov test confirmed that the natural frequency of defect occurrences across 300 g batches statistically approximates a normal distribution ().
Table 2.
Number and type of defective grains present in a 300-g parchment sample.
By empirically validating this distribution, we ensure that the synthetic class imbalance natively mirrors the real-world stochastic probabilities encountered during industrial milling. Each defective bean is overlaid at a random location and rotation (ranging from to ) on the background, ensuring high stochastic variability. Finally, automated pixel-level masks are generated to serve as the ground truth for semantic segmentation, as depicted in Figure 6.
Figure 6.
Automated mask generation for semantic segmentation. (Left): Original image. (Right): Generated ground truth mask.
To ensure the high fidelity and realism of the generated synthetic datasets prior to deep learning evaluation, the image quality was strictly controlled and evaluated based on three physical and statistical criteria rather than standard generative metrics:
- Geometric and Morphological Fidelity: Evaluated through the strict metric correspondence of per pixel and a low reprojection error (0.24 pixels) during calibration. This ensures that sub-millimeter morphological traits, such as the 0.5 mm entry holes of the Broca insect, are preserved without perspective distortion when superimposed.
- Photometric and Chromatic Consistency: Assessed by the seamless blending of the foreground (defects) and background (Excelso beans). By disabling automatic white balance and maintaining a standardized LED enclosure during acquisition, the superimposed beans exhibit zero illumination variance or edge artifacts, achieving natural chromatic integration.
- Contextual and Statistical Realism: Validated against the empirical distribution derived from the 1400 real-world samples from CINTAGRO. The occurrence, spatial density, and random rotation ( to ) of the generated defects precisely replicate the stochastic behavior observed on physical industrial conveyor belts.
Each image is accompanied by three distinct masks: (i) RGB encoding, (ii) integer-labeled classes (background, Excelso, and 7 defect types), and (iii) a generalized 3-class mask (background, Excelso, and general defect). The color palette used for the inference and visualization process is detailed in Table 3.
Table 3.
Color palette and RGB encoding assigned per class for semantic segmentation.
The dataset generation is fully automated; in this case study, over 6000 high-resolution images ( pixels) were synthesized in 7 h of processing.
2.5. Deep Convolutional Neural Networks
To validate the synthetic dataset quality, experiments were conducted using the DeepLab architecture, a family of convolutional neural networks (CNN) specifically designed for semantic segmentation [28]. DeepLab models leverage Atrous (dilated) convolutions to encode deep features at high resolution without increasing parameter count. The framework utilizes an Atrous Spatial Pyramid Pooling (ASPP) block to resample features at multiple scales, providing high-quality multi-scale information. DeepLabV3+ was selected for this task due to its ability to recover refined edge details by concatenating low-level and high-level features. A ResNet-152 backbone, pre-trained on ImageNet, was employed to handle the high resolution of the AgrySET images ( pixels). This depth is essential for extracting complex semantic features while avoiding the vanishing gradient problem through residual connections. Finally, transfer learning was utilized to accelerate convergence and improve the discrimination of visually similar classes.
3. Results
The proposed synthetic image methodology provides a faithful representation of the acquisition conditions on the CINTAGRO conveyor belts. A sample composite image and its corresponding mask are presented in Figure 7.
Figure 7.
Synthetic image and coffee bean mask using the color palette of Table 3. (Left): Original image. (Right): Segmentation mask.
Pior to evaluating neural network performance, the visual and structural quality of the generated synthetic images was quantitatively assessed against real-world benchmark images captured at CINTAGRO. Chromatic consistency was verified through RGB/HSV histogram correlation, achieving an average Pearson coefficient of , confirming that locked camera parameters and standardized LED lighting eliminated color drift during image fusion. Furthermore, structural similarity along superimposition contours yielded an average SSIM of , demonstrating seamless blending without boundary artifacts while preserving edge sharpness for sub-millimeter defects at the target spatial resolution. Now, training was performed using an SGD optimizer with a learning rate of 0.02 and a weight decay of 0.00001. A crop size of , a batch size of 8, and a duration of 250 epochs were specified. The dataset was split into 6000 training images and 600 validation images. Performance was evaluated using the Mean Intersection over Union (mIoU) metric on an NVIDIA RTX 2000 (16 GB) GPU. Initial experiments with three classes (background, excelso, and defective) yielded the results shown in Table 4.
Table 4.
mIoU for 3-class classification (background, excelso, and defective).
The DeepLabV3+ architecture effectively recognized the majority of the grains, exceeding 96% mIoU for the “Excelso” (high-quality) class and nearly 90% for the “Defective” (bad) grains in the simplified scenario. This demonstrates that the selected architecture is highly effective and adaptable to the high-resolution imagery generated by AgrySET. The stability and convergence of the training process for these categories can be observed in Figure 8.
Figure 8.
DeepLabMean IoU progression on the synthetic coffee defect dataset (3 class).
Once the effectiveness of AgrySET for identifying defective grains was verified in the simplified scenario, further experiments were conducted to evaluate the system’s performance in identifying specific defect categories. This transition from a general binary classification to a multiclass approach aims to assess the model’s ability to discriminate between the subtle morphological and chromatic variations of the seven defects defined by the National Federation of Coffee Growers. While the initial results demonstrate successful pixel identification across the broader categories, the performance varied significantly when decomposing the “Defective” class into seven specific types, as detailed in Table 5.
Table 5.
mIoU for 9-class classification (background, excelso, and seven defects).
The lower mIoU values for “Slight Broca” and “Cut/Bitten” grains are attributed to the lack of representative visual features in 2D nadir views. For example, the “Slight Broca” defect consists of a sub-millimeter hole; if this hole is positioned on the underside or side of the grain, the visual signature vanishes, making it chromatically identical to an “Excelso” grain. This introduces label noise, degrading the model’s generalization. Similarly, “Cut” grains lose their ellipsoidal structure, and initial convolution layers may confuse fractures with natural grain overlaps.
Training progression is visualized in Figure 9. Both training and validation mIoU maintain a similar trend, converging at approximately 62%, which indicates learning stability and minimal overfitting. The sawtooth behavior in the validation curve is a direct consequence of the small batch size (8) necessitated by the memory footprint of high-resolution images ( pixels), with training stabilizing steadily towards convergence.
Figure 9.
DeepLab Mean IoU progression on the synthetic coffee defect dataset (9 class).
The loss decay (from 25% to 4% in training) suggests that while the CNN captures global features (edges and shapes), a gap remains in recognizing “noisy” sub-millimeter details. Inference results across multiple images are shown in Figure 10.
Figure 10.
Inference results.(A): RGB image. (B): Original masks. (C): Predicted masks obtained during inference.
To validate the system’s performance in real-world scenarios, an external test set of 150 high-resolution real-world images ( pixels) was manually acquired, annotated, and segmented using the models trained exclusively on synthetic data. The evaluation yielded an accuracy of 90% for the 3-class configuration and 58% for the detailed 9-class scenario, corroborating the proposed framework as a viable solution for defect classification in agricultural supply chains. Furthermore, the operational efficiency was benchmarked: manual preparation, acquisition, and pixel-wise segmentation of a single image required an average of 18 min (totalling 15 h of expert labor for the 150 validation images). In contrast, the AgrySET automated pipeline executes this workflow 250 times faster, demonstrating significant computational and operational scalability.
Finally, a critical validation aspect of AgrySET is the metric correspondence: each pixel represents . This density allows the model to discern stenopeic features, such as the entry hole of the Broca (0.5 mm to 1.5 mm), ensuring that the mIoU results correlate directly with the physical quality required for coffee exportation.
4. Discussion
The results obtained from the AgrySET framework demonstrate that automated synthetic data generation is a viable and efficient alternative to manual annotation in specialized agricultural tasks. The generation of over 6000 high-resolution images in just 7 h represents a significant advancement over traditional methods, which are often hindered by the “data hunger” and human error associated with pixel-precise labeling. One of the most relevant findings is the high performance achieved in the simplified 3-class classification, with a mean IoU (mIoU) of 92.9%. This indicates that the DeepLabV3+ architecture, combined with a ResNet-152 backbone, successfully extracted stable structural features from synthetic images that remain consistent in real-world scenarios. The use of Atrous Spatial Pyramid Pooling (ASPP) and deep residual feature hierarchies allowed the model to maintain high spatial resolution while discriminating fine-grained surface features, which is critical for identifying subtle defective grains in dense industrial environments. However, the decomposition into 9 classes revealed a performance drop for specific defects such as “Slight Broca” (13.4%) and “Cut/Bitten” grains (27.5%). This behavior aligns with the analysis of “label noise” in 2D nadir projections; as discussed in the hardware characterization, the occlusion of morphological traits in a monocular top-down view makes these grains chromatically identical to healthy “Excelso” beans. This suggests that while synthetic data solves the availability problem, certain micro-defects require multi-view acquisition or additional spectral information to be fully distinguishable. Achieving a 61.9% mIoU in the complex 9-class scenario represents a solid baseline for fine-grained agricultural segmentation. Direct comparisons with general-purpose benchmark datasets like Cityscapes must be contextualized: while urban scene datasets evaluate macro-objects with distinct structural boundaries, agricultural defect inspection faces severe intra-class visual overlap and subtle morphological variations. Categories such as healthy ‘Excelso’ beans and ‘Slight Broca’ or ‘Cut/Bitten’ defects share nearly identical color profiles and surface textures, differing only by sub-millimeter features. Considering these domain-specific constraints, the ability of DeepLabV3+ to discriminate between subtle defect types using exclusively synthetic training data demonstrates strong learning capacity under extreme inter-class similarity. To contextualize this contribution within the broader landscape of agricultural computer vision, AgrySET addresses key limitations inherent to alternative synthetic generation paradigms. Generative models (GANs and Diffusion Models) require massive pre-existing annotated datasets to train and frequently suffer from mode collapse or hallucination artifacts that obliterate sub-millimeter defect boundaries (). Conversely, 3D physics engine simulations (e.g., Blender, Unreal Engine) rely on labor-intensive CAD modeling of non-rigid organic tissues and heavy rendering overhead, while standard domain randomization applies unconstrained spatial variations that break real-world agricultural co-occurrence statistics. AgrySET overcomes these barriers through a deterministic, physically grounded pipeline: by combining multi-camera physical sample acquisition with an empirical Gaussian probability model derived from 1400 commercial coffee samples, our framework eliminates generative hallucination, guarantees 100% pixel-exact ground-truth mask alignment, and preserves true operational distributions at negligible computational cost. Beyond theoretical metrics, the practical viability of AgrySET was corroborated through an external validation test using 100 manually acquired and annotated real-world images (encompassing over 24,000 individually labeled bean instances). The models evaluated on this real-world set yielded accuracies of 90% and 58% for the 3-class and 9-class configurations, respectively, closely mirroring the synthetic validation results. This high sim-to-real transferability proves that training exclusively on AgrySET synthetic data eliminates the necessity of compiling massive real-world training sets. Indeed, manually acquiring and annotating a real dataset of equivalent scale (6000 images) would require over 1800 h (225 workdays) of expert labor, rendering a ‘real-only’ training regime at scale operationally unfeasible in industrial settings and confirming the standalone value of the proposed synthetic framework. Crucially, this experiment highlighted a profound operational bottleneck in traditional methods: the manual preparation, acquisition, and pixel-wise segmentation of a single image required an average of 18 min (30 h for the 100 validation images). In contrast, the AgrySET automated pipeline mitigates this impracticality, accelerating the workflow by an estimated factor of 250 (based on a standard 8-h workday). This dramatic reduction in labor costs highlights the operational efficiency of the framework for coffee inspection, while its broader industrial scalability remains to be evaluated across additional agricultural products. Finally, the spatial resolution achieved () provides a metric correspondence that bridges the gap between digital simulation and the physical quality standards required by the National Federation of Coffee Growers. Nevertheless, key limitations of the current framework must be noted. First, the experimental validation was conducted on a single crop (Coffea arabica). While coffee beans provide a challenging benchmark with 9 defect classes, extending AgrySET to other produce geometries (such as larger fruits or leaves) requires recalibrating the camera distance, lighting intensity, and statistical models. Second, distinguishing visually similar defect classes such as ‘Slight Broca’ (13.4% mIoU) versus mechanical ‘Cut/Bitten’ grains (27.5% mIoU) remains challenging due to overlapping chromatic properties and subtle morphological traits under standard RGB illumination. Future work will focus on integrating NIR sensors to address internal defects and multi-angle optics to capture hidden lateral faces.
5. Conclusions
This research presented AgrySET, a procedural framework for synthetic data generation tailored for semantic segmentation in agricultural defect inspection. The system eliminates the bottleneck of manual annotation by procedurally creating high-resolution scenes alongside exact ground-truth masks. Furthermore, integrating empirical Gaussian probabilistic models provides parametric control over class distributions, ensuring a robust representational balance of minority defect categories prior to neural network training. Semantic segmentation evaluations validated the physical and photometric fidelity of the procedurally synthesized compositions. Deep learning architectures trained exclusively on synthetic data successfully generalized to real industrial inspection environments, confirming that physical photometric consistency and precise spatial alignment suffice to achieve strong sim-to-real knowledge transfer without compiling massive real-world training sets. The study identified fundamental physical limitations inherent to monocular 2D top-down vision systems. While broad defect discrimination is highly effective, isolating morphologically subtle micro-defects—such as slight insect entry holes or fine mechanical cuts—is constrained by feature occlusion in nadir projections. This finding demonstrates that detecting certain sub-millimeter anomalies is bounded by viewing angles rather than model capacity, establishing a clear physical baseline for future multi-view optical research. Operationally, AgrySET drastically reduces the temporal and human labor overhead associated with pixel-wise mask generation, establishing procedural composition as an efficient and practical alternative for agricultural vision systems. While validated on coffee bean defect recognition as a primary case study, the framework demonstrates strong potential as a proof-of-concept for automated sorting, offering a promising direction for future adaptation to other granular agricultural commodities. Future work will pursue both hardware expansion and advanced algorithmic paradigms. On the sensing front, we will integrate Near-Infrared (NIR) channels with RGB data to capture subsurface spectral signatures imperceptible in the visible spectrum. On the algorithmic front, future research will explore Vision Transformers (ViTs), SAM-based foundation models, diffusion generative refinement, self-supervised learning, and domain adaptation techniques to advance toward real-time digital twins for industrial agricultural inspection.
Author Contributions
Conceptualization, J.C.M.H., G.A.H. and H.F.Q.R.; methodology, J.C.M.H., S.M.A. and G.A.H.; software, J.C.M.H.; validation, J.C.M.H. and H.F.Q.R.; formal analysis, J.C.M.H.; investigation, G.A.H., S.M.A. and J.C.M.H.; resources, G.A.H.; data curation, J.C.M.H.; writing—original draft preparation, H.F.Q.R. and J.C.M.H.; writing—review and editing, H.F.Q.R. and G.A.H.; visualization, J.C.M.H.; supervision, H.F.Q.R.; project administration, H.F.Q.R. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by the Ministry of Science, Technology, and Innovation of Colombia (MinCiencias).
Data Availability Statement
The original data presented in the study are openly available in the GitHub repository “Coffee Semantic Segmentation Dataset” at [29]. This repository contains the raw images, annotated semantic masks, and metadata used for the validation of the deep learning architectures.
Acknowledgments
Special thanks are extended to the Corporación para la Investigación, Desarrollo Tecnológico e Innovación del Agro (CINGTAGRO) and the Universidad Tecnológica de Pereira (UTP) for their scientific, technological, and academic leadership throughout the development, construction, and validation of the metrological prototype. We also highly appreciate the cooperation of the local coffee growers, cuppers, and threshing plant professionals whose invaluable real-world validation ensured the practical success of this project. During the preparation of this manuscript, the authors used Gemini (an AI model by Google) for the purposes of refining the English translation, improving stylistic flow, and ensuring structural coherence. The authors have reviewed and edited the output and take full responsibility for the content of this publication.
Conflicts of Interest
The authors declare no conflict of interest.
Abbreviations
The following abbreviations are used in this manuscript:
| AI | Artificial Intelligence (Inteligencia Artificial) |
| DL | Deep Learning (Aprendizaje Profundo) |
| CNN | Convolutional Neural Network (Red Neuronal Convolucional) |
| CPS | Cyber-Physical Systems (Sistemas Ciber-Físicos) |
| IoT | Internet of Things (Internet de las Cosas) |
| mIoU | Mean Intersection over Union (Media de la Intersección sobre la Unión) |
| RGB | Red, Green, Blue (Rojo, Verde y Azul) |
| IR | Infrared (Infrarrojo) |
| NIR | Near-Infrared (Infrarrojo Cercano) |
| FoV | Field of View (Campo de Visión) |
| ASPP | Atrous Spatial Pyramid Pooling |
| SGD | Stochastic Gradient Descent (Descenso de Gradiente Estocástico) |
| CINGTAGRO | Centro de Innovación y Productividad Agrario |
References
- Klein, J.; Waller, R.; Pirk, S.; Palubicki, W.; Tester, M.; Michels, D. Synthetic data at scale: A development model to efficiently leverage machine learning in agriculture. Front. Plant Sci. 2024, 15, 115–133. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Ceccarelli, T.; Chauhan, A.; Rambaldi, G.; Kumar, I.; Capello, C.; Janssen, S.; McCampbell, M. Leveraging Automation and Digitalization for Precision Agriculture: Evidence from Case Studies. 2022. Available online: https://ageconsearch.umn.edu/record/330811/ (accessed on 10 September 2026).
- Santana, L.S.; Ferraz, G.A.e.S.; Teodoro, A.J.d.S.; Santana, M.S.; Rossi, G.; Palchetti, E. Advances in Precision Coffee Growing Research: A Bibliometric Review. Agronomy 2021, 11, 1557. [Google Scholar] [CrossRef] [Scilit]
- Romero Ayala, L.E. La Inteligencia Artificial en la Proyección de su Producción de Cultivo de Caña de Azúcar en el Ecuador. Bachelor’s Thesis, Universidad Técnica de Babahoyo, Babahoyo, Ecuador, 2023. [Google Scholar]
- Falcón-Lucario, G.; Díaz, L.D.M.; Posadas-Domínguez, R.R. Análisis de regresión logística para predecir la inseguridad alimentaria en el sistema de producción milpa del Valle del Mezquital, Hidalgo. Rev. Inclusiones 2022, 9, 172–195. [Google Scholar]
- Do, C.B.; Batzoglou, S. What is the expectation maximization algorithm? Nat. Biotechnol. 2008, 26, 897–899. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Castillo-Girones, S.; Munera, S.; Martínez-Sober, M.; Blasco, J.; Cubero, S.; Gómez-Sanchis, J. Artificial Neural Networks in Agriculture, the core of artificial intelligence: What, When, and Why. Comput. Electron. Agric. 2025, 230, 109938. [Google Scholar] [CrossRef] [Scilit]
- Bhola, A.; Kumar, P. Deep feature-support vector machine based hybrid model for multi-crop leaf disease identification in Corn, Rice, and Wheat. Multimed. Tools Appl. 2025, 84, 4751–4771. [Google Scholar] [CrossRef] [Scilit]
- Karunathilake, E.M.; Le, A.T.; Heo, S.; Chung, Y.S.; Mansoor, S. The Path to Smart Farming: Innovations and Opportunities in Precision Agriculture. Agriculture 2023, 13, 1593. [Google Scholar] [CrossRef] [Scilit]
- Khaki, S.; Safaei, N.; Pham, H.; Wang, L. WheatNet: A Lightweight Convolutional Neural Network for High-throughput Image-based Wheat Head Detection and Counting. Comput. Vis. Pattern Recognit. 2021, 489, 78–89. [Google Scholar] [CrossRef] [Scilit]
- Li, Y.; Wang, D.; Yuan, C.; Li, H.; Hu, J. Enhancing Agricultural Image Segmentation with an Agricultural Segment Anything Model Adapter. Sensors 2023, 23, 7884. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Ma, J.; Du, K.; Zheng, F.; Zhang, L.; Sun, Z. Disease recognition system for greenhouse cucumbers based on deep convolutional neural network. Nongye Gongcheng Xuebao/Trans. Chin. Soc. Agric. Eng. 2018, 34, 186–192. [Google Scholar] [CrossRef]
- Zhao, S.; Liu, J.; Bai, Z.; Hu, C.; Jin, Y. Crop Pest Recognition in Real Agricultural Environment Using Convolutional Neural Networks by a Parallel Attention Mechanism. Front. Plant Sci. 2022, 13, 839572. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Abreu Júnior, C.A.M.d.; Martins, G.D.; Xavier, L.C.M.; Vieira, B.S.; Gallis, R.B.d.A.; Fraga Junior, E.F.; Martins, R.S.; Paes, A.P.B.; Mendonça, R.C.P.; Lima, J.V.d.N. Estimating Coffee Plant Yield Based on Multispectral Images and Machine Learning Models. Agronomy 2022, 12, 3195. [Google Scholar] [CrossRef] [Scilit]
- Soares, A.d.S.; Vieira, B.S.; Bezerra, T.A.; Martins, G.D.; Siquieroli, A.C.S. Early Detection of Coffee Leaf Rust Caused by Hemileia vastatrix Using Multispectral Images. Agronomy 2022, 12, 2911. [Google Scholar] [CrossRef] [Scilit]
- Liu, G.; Bai, L.; Zhao, M.; Zang, H.; Zheng, G. Segmentation of wheat farmland with improved U-Net on drone images. J. Appl. Remote Sens. 2022, 16, 034511. [Google Scholar] [CrossRef] [Scilit]
- Najafian, K.; Ghanbari, A.; Kish, M.; Eramian, M.; Shirdel, G.; Stavness, I.; Jin, L.; Maleki, F. Semi-Self-Supervised Learning for Semantic Segmentation in Images with Dense Patterns. Plant Phenomics 2023, 5, 76–98. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Han, C.; Hayashi, H.; Rundo, L.; Araki, R.; Shimoda, W.; Muramatsu, S.; Furukawa, Y.; Mauri, G.; Nakayama, H. GAN based synthetic brain MR image generation. In Proceedings of the IEEE 15th International Symposium on Biomedical Imaging, Washington, DC, USA, 4–7 April 2018; IEEE: New York, NY, USA, 2018; pp. 74–92. [Google Scholar]
- Kingma, D.; Welling, M. An Introduction to Variational Autoencoders. Found. Trends Mach. Learn. 2019, 12, 307–392. [Google Scholar] [CrossRef] [Scilit]
- Lugmayr, A.; Danelljan, M.; Romero, A.; Yu, F.; Timofte, R.; Van Gool, L. RePaint: Inpainting using Denoising Diffusion Probabilistic Models. In Proceedings of the 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Orleans, LA, USA, 18–24 June 2022; IEEE: New York, NY, USA, 2022; pp. 11461–11471. [Google Scholar]
- Rombach, R.; Blattmann, A.; Lorenz, D.; Esser, P.; Ommer, B. High-Resolution Image Synthesis with Latent Diffusion Models. In Proceedings of the 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), New Orleans, LA, USA, 8–24 June 2022; IEEE: New York, NY, USA, 2022; pp. 10674–10685. [Google Scholar]
- Su, P.J.; Chen, T.M.; Su, J.J. Simple and Affordable Vision-Based Detection of Seedling Deficiencies to Relieve Labor Shortages in Small-Scale Cruciferous Nurseries. Agriculture 2025, 15, 2227. [Google Scholar] [CrossRef] [Scilit]
- Betco, I.; Viana, C.M.; Rocha, J. USE-SVI: A reproducible pipeline for sampling, acquiring, and stitching Street View imagery to support urban analytics. MethodsX 2026, 2026, 103785. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- CAO, X.; Quan, P.; Mao, Y.; Cao, R. TRRS-DM: Two-stage Resampling and Residual Shifting for high-fidelity texture inpainting of Terracotta Warriors utilizing Diffusion Models. Pattern Recognit. 2025, 167, 111753. [Google Scholar] [CrossRef] [Scilit]
- Ramu, K.; Patthi, S.; Prajapati, Y.N.; Ramesh, J.V.N.; Banerjee, S.; Rao, K.B.; Alzahrani, S.I.; Ayyasamy, R. Hybrid CNN-SVM model for enhanced early detection of Chronic kidney disease. Biomed. Signal Process. Control 2025, 100, 107084. [Google Scholar] [CrossRef] [Scilit]
- da Mota, M.C.B.; Batista, N.N.; Rabelo, M.H.S.; Ribeiro, D.E.; Borém, F.M.; Schwan, R.F. Influence of fermentation conditions on the sensorial quality of coffee inoculated with yeast. Food Res. Int. 2020, 136, 109482. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Li, Y.; Zhang, D. Toward Efficient Edge Detection: A Novel Optimization Method Based on Integral Image Technology and Canny Edge Detection. Processes 2025, 13, 293. [Google Scholar] [CrossRef] [Scilit]
- Chen, L.C.; Papandreou, G.; Kokkinos, I.; Murphy, K.; Yuille, A.L. DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs. IEEE Trans. Pattern Anal. Mach. Intell. 2018, 40, 834–848. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Available online: https://github.com/Juank210/Coffe_Semantic_Segmentation_dataset (accessed on 20 August 2026).
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.









