Skip to Content
AgriEngineeringAgriEngineering
  • Article
  • Open Access

7 June 2026

20 Pages

Leaf Image Segmentation in Urochloa Pastures: A Comparative Analysis of Preprocessing Strategies Using Smartphone Imagery

,
,
,
,
and
1
Faculty of Animal Science and Food Engineering, University of São Paulo—USP, Pirassununga 13635-900, SP, Brazil
2
Cuanza Sul Higher Polytechnic Institute, Sumbe 14 409, Angola
3
Facultad de Ingeniería de Industrias Alimentarias y Biotecnología, Universidad Nacional de Frontera, Sullana 20103, Peru
*
Author to whom correspondence should be addressed.

Abstract

Smartphone-based proximal sensing has emerged as a promising low-cost approach for pasture monitoring. A critical component of this methodology is accurate leaf segmentation, as it directly affects the reliability of subsequent image-based analyses. Despite advances in computer vision, the role of preprocessing strategies in segmentation performance remains insufficiently explored, particularly under resource-constrained conditions. This study presents a systematic comparative evaluation of three preprocessing pipelines based on HSV and CIELab color spaces for the segmentation of Urochloa grass leaves (Urochloa hybrid Mavuno and Urochloa decumbens) using smartphone imagery acquired field conditions. The pipelines were assessed using a multi-criteria framework, including the Fisher Discriminant Ratio (FDR), Intersection over Union (IoU), Overlap Error (OE), Structural Similarity Index (SSIM), and Edge Preservation Index (EPI), complemented by discordance map analysis. The results demonstrate that preprocessing design significantly influences segmentation stability, boundary preservation, and robustness to illumination variability. Pipelines based on HSV channels showed high sensitivity to shadows and non-uniform lighting, leading to reduced segmentation consistency. In contrast, the CIELab-based pipeline relying on the a* channel achieved superior performance, with higher discriminative capacity, improved edge preservation, and lower computational cost. These findings highlight that carefully designed classical preprocessing strategies remain highly effective for low-cost, real-time applications, even in the absence of computationally intensive models. This work establishes a robust segmentation foundation for future integration with advanced analytical methods, including machine learning approaches, and supports the development of scalable smartphone-based tools for pasture monitoring.

1. Introduction

Precision technologies based on computer vision, particularly those using low-cost platforms and sensors [1], have enabled the development of accessible and fast solutions for crop monitoring [2,3]. Image-based approaches using proximal sensors acquired relevance due to their low computational requirements, accessibility, and portability, especially when implemented on devices such as smartphones [4]. Some applications include plant species identification [5], classification for diseases severity and nutrients status monitoring [1,6]. However, such advances are limited for tropical grass pastures, for which important gaps still prevent the availability of robust tools for smart monitoring.
Currently, one of the main demands for pasture-based systems relies on the development of fertilization protocols based on the strategic use of nitrogen (N) [7,8]. Once it is recognized that restriction on N supply limits pasture growth and yield [9], it is also well established that unconscious fertilization practices contribute to environmental pollution and greenhouse gas emissions [10,11]. The portable devices commercially available are costly and require technical expertise for interpretation, limiting wider adoption. Thus, smartphone-based applications still represent a technological advance, being also tools more accessible for small farmers at many countries [6].
However, the development of reliable image-based systems still depends critically on the initial stages of image processing, particularly preprocessing and segmentation [12]. These steps typically include scale and orientation standardization, color space transformations (e.g., RGB (Red, Green, Blue), HSV (Hue, Saturation, Value) and the L*a*b* (Lightness, green–red axis and blue–yellow axis) defined from the CIE (International Commission on Illumination)), illumination normalization, noise filtering, morphological operations, mask generation, and background removal to isolate regions of interest (ROI) [13].
The absence of standardized preprocessing pipelines means that inappropriate combinations of methods can significantly affect segmentation performance, leading to over-segmentation or under-segmentation [14,15]. Previous studies [16,17], in agreement with [1,18], highlight that the impact of preprocessing strategies remains insufficiently explored.
Several approaches have been proposed in the literature. For instance, ref. [6] employed color-based thresholding in the HSV space for rice leaf analysis, although preprocessing details were limited. In [19], CLAHE was applied to the V channel to mitigate noise amplification under non-uniform illumination. The study in [20] evaluated denoising and contrast enhancement techniques for rice leaves (Oryza sativa L.), reporting performance variability depending on noise characteristics.
More recently, ref. [21] proposed a segmentation approach combining CIELab (L* and b*) and HSV (S channel), followed by morphological post-processing, achieving good performance under heterogeneous illumination. However, these approaches often involve increased pipeline complexity and do not explicitly assess the impact of individual preprocessing steps.
In this scenario, this study focuses on the role of preprocessing in leaf segmentation for proximal sensing applications. We hypothesize that the appropriate selection and combination of preprocessing techniques can improve segmentation robustness under heterogeneous illumination conditions, even when using low-cost imaging devices such as smartphones. To test this hypothesis, we evaluate three different preprocessing pipelines based on HSV and CIELAB color spaces for the segmentation of grass leaf images (Urochloa hybrid Mavuno and Urochloa decumbens) acquired under field conditions.
Recent advances in deep learning have significantly improved image segmentation performance, particularly through convolutional neural networks (CNNs) and transformer-based architectures. These approaches have demonstrated high accuracy in complex scenarios involving occlusion, heterogeneous backgrounds, and varying illumination conditions. However, such models typically require large annotated datasets, high computational resources, and specialized hardware, which limit their applicability in low-cost, real-time agricultural systems, particularly for smartphone-based implementations.
In this context, classical image processing techniques remain relevant, especially for applications where interpretability, computational efficiency, and ease of deployment are critical. Therefore, this study does not aim to compete with deep learning approaches, but rather to investigate how preprocessing strategies influence segmentation performance in smartphone-based applications, providing a methodological foundation for future integration with more advanced models.
The main contribution of this work is a systematic comparative analysis of preprocessing strategies for leaf segmentation under controlled proximal acquisition conditions. The focus is on understanding how different color spaces and preprocessing pipelines affect segmentation stability, edge preservation, and robustness to illumination variability. This study is not intended to perform nitrogen diagnosis directly, but to establish a reliable segmentation foundation for subsequent image-based analytical models.

2. Material and Methods

2.1. Experimental Site and Grass Species

Field experiments for image acquisition were carried out in Pirassununga, São Paulo, Brazil (21°57′31″ S, 47°27′07″ W, 620 m above sea level). In the experimental area, the slope is moderately undulating, and the soil is classified as Rhodic Hapludox [22]. The grass species were hybrid Urochloa Mavuno, common name Mavuno grass, registered in the Ministry of Agriculture, Livestock and Food Supply as MIXE DRWN 12, n o 30488 and Urochloa decumbens Stapf. The climate in the region is Cwa (Köppen), sub-tropical with dry winters, and pasture management followed the specific recommendation of the species: Mavuno grass was cut always reaching 40 cm and 20 cm of residual height was maintained, while U. decumbens pastures were cut at 30 cm leaving 10 cm residual height.
Field experiments were designed to generate gradients in the leaf N content using N fertilization. For both experiments, the treatments consisted of N rates, using urea (45% N), applied at the beginning of the regrowth and after each cutting procedure, following a complete randomized block design. For Mavuno grass, N rates consisted of no-nitrogen (D0), 15 (D15), 30 (D30) and 45 (D45) kg ha−1 of N, while for U. decumbens were no-nitrogen (D0), (D15) and 30 (D30) kg ha−1 of N.

2.2. Images Acquisition

The image acquisition protocol was designed to ensure the collection of representative, reproducible, and standardized visual information, while maintaining operational simplicity suitable for non-specialized users under field conditions, see Figure 1. The adopted procedures aimed to minimize operator-induced variability and preserve the spectral–spatial characteristics of the leaves, critical for subsequent digital image processing and machine learning analyzes. For image acquisition, diagnostic leaves (the youngest completely expanded leaves) were collected from each plot at the pre-cutting. After being detached from the tillers, the diagnostic leaves were placed side by side on a white matte background clipboard. For Mavuno pastures, each image, containing three leaves, was captured at 23 cm from the base using a Samsung Galaxy J5 Duos SM-J500M/D smartphone (Samsung Electronics, Suwon, Republic of Korea), with a 13 MP camera, stored as 24-bit color images, with a resolution of 800 × 600 pixels and saved in JPEG format. A total of five image subsamples with three leaves were captured in each regrowth cycle of the plots always between 11 am and 1 pm, with the sun closest to the vertical (Zenith), under full sunlight.
Figure 1. Field images acquisition using smartphones.
For U. decumbens pastures, each image, containing five leaves, was captured 23 cm from the base using a Xiaomi Redmi Note 7 smartphone (Xiaomi Corporation, Beijing, China). The acquisition followed a different protocol: leaves were placed side by side on an imaging collect table, constructed with an opaque white background, and images were acquired under artificial shadow. The smartphone was configured with ISO 100 (camera sensitivity level to available light), lighting 100, and white balance 6500 K.
It is important to note that the adopted acquisition protocol prioritizes reproducibility and controlled variability, allowing the isolation of preprocessing effects. This design does not aim to replicate fully complex field scenarios (e.g., occlusion, overlapping leaves, or cluttered backgrounds), but rather to provide a stable experimental basis for methodological evaluation.

2.3. Preprocessing and Segmentation Methods

The main steps of the proposed methodology are shown in Figure 2 and are detailed in the following paragraphs.
Figure 2. Proposed methodology.
For pipeline A (Algorithm 1) each image was read in RGB color space and subjected to Gaussian smoothing using a 7 × 7 kernel; next, the smoothed images were converted from RGB color space to the Hue–Saturation–Value (HSV) color model. This transformation allows for the separation of chromatic information (Hue), color purity (Saturation), and illumination intensity (Value), thereby increasing robustness to non-uniform lighting conditions.
Algorithm 1 Preprocessing and segmentation steps applied on grass leaves in pipeline A
1:
Gaussian blur:  applied on the RGB images, using a 7 × 7 kernel size.
2:
Conversion to HSV color space
3:
Morphological erosion:  applied to each HSV channel, using a 11 × 11 elliptical structuring element.
4:
Thresholding:  Otsu’s method using automatic threshold selection on the S channel.
5:
Segmentation: Combined segmentation on H and V (adapted from [6]), where 30 < H < 90 and V > 20 , and S from the step 4, using a bitwise conjunction (AND)
6:
Morphological operations:  Morphological operations using closing and opening operators.
7:
Global segmented mask:  Final images with a transparent background.
Morphological erosion was applied independently on the H, S and V channels. An elliptical structure element with a large kernel size was used to promote strong smoothing, ensuring isotropic erosion while preserving the natural geometry of elongated biological structures such as grass leaves. An automatic threshold was estimated on the eroded S channel using Otsu’s method. This adaptive approach aims for an optimal separation between high-saturation regions associated with vegetation and low-saturation background elements, without requiring manual parameter tuning. Leaf segmentation was performed by combining logical masks derived from eroded HSV channels [16]. Specifically, the pixels were classified as belonging to leaf tissue only if they simultaneously satisfied predefined hue, saturation, and value constraints. The preliminary segmentation mask was refined through sequential morphological closing followed by opening operations, using the same elliptical structuring element. Closing was used to fill small gaps and internal discontinuities within leaf regions, while opening removed isolated noise components. This step aims to maintain the spatial coherence and biological plausibility of the segmented leaf shapes. Each detected leaf was identified from the original RGB image using its bounding box and associated binary mask. This procedure preserved the original color information and spatial resolution of each leaf, enabling independent downstream analyzes.
In pipeline B (Algorithm 2) each image was read in RGB color space and subjected to Gaussian smoothing using a 5 × 5 kernel. This kernel size was defined to provide moderate smoothing, preserving sharp edges. The smoothed images were initially converted from the RGB color space to the CIELab color space, and the Contrast Limited Adaptive Histogram Equalization (CLAHE) was applied to the L (Luminance) channel, using a 5 × 5 tile grid size and a clip limit of 2. The illumination-corrected image was converted to both the HSV and LAB color spaces, and an initial segmentation was performed on the S channel using Otsu’s adaptive thresholding method. Morphological erosion followed by dilation, employing an elliptical structure element, was applied to remove isolated noise and reinforce spatial continuity of the leaf region (Algorithm 2). This step primarily identifies vegetative regions characterized by high color saturation.
Algorithm 2 Preprocessing and segmentation steps applied on grass leaves in pipeline B
1:
Gaussian blur:  applied on the RGB images, using a 5 × 5 kernel size.
2:
Color space conversion:  Conversion to CIELab and HSV color spaces.
3:
Illumination correction:  CLAHE to the L channel.
4:
Thresholding:  Otsu’s method using automatic threshold selection on the S channel.
5:
Morphological operations:  erosion followed by dilation applied to S mask, using a 5 × 5 elliptical structuring element.
6:
Thresholding:  Otsu’s method using automatic threshold selection on the a* channel.
7:
Morphological operations:  erosion followed by dilation applied to a* mask, using a 5 × 5 elliptical structuring element.
8:
Combined segmentation:  Combined segmentation on S and a* (adapted from  [21] using a bitwise conjunction (AND).
9:
Morphological operations:  Erosion followed by dilation applied to the combined mask, using a 3 × 3 elliptical structuring element
10:
Flood-fill operation:  using a 8 way connectivity.
11:
Refinement of mask:  using connected components with 8-connectivity and excluding objects with area lower than 10,000 pixels.
12:
External contours detection:  applied to isolate boundaries of each single leaf in the image
13:
Global segmented mask:  Final images with a transparent background.
In parallel, segmentation was performed on the a* channel, which discriminates green from red components. The a* channel was inverted to enhance the green leaf regions prior to thresholding using Otsu’s method. Subsequently, morphological opening and closing operations were applied to suppress residual noise and fill small spaces within the leaf areas. This stage reinforces the chromatic distinction between leaf tissue and background elements. The binary masks obtained from the segmentation were combined using a logical AND operation. This fusion retained only pixels satisfying both spectral criteria. The combined mask was further refined using minimal erosion followed by a stronger dilation with a 3 × 3 elliptical structuring element. This step aimed to remove thin spurious connections between adjacent leaves while restoring leaf boundaries and tip regions. Then, internal holes within segmented leaf regions were filled using a flood-fill-based approach and connected component labeling was applied to the refined binary mask using 8-connectivity. Finally, the external contours of the detected leaves were isolated and an RGBA (Red, Green, Blue, Alpha channel, where Alpha represents transparency) representation was obtained using the refined binary mask as the alpha channel. It is important to note that multiple morphological operations were applied at different stages of the pipeline to progressively suppress noise, enhance chromatic consistency, and enforce object separability, rather than trying to correct all segmentation errors in a single operation.
The pipeline C (Algorithm 3) consisted of five main steps: blurring and color space transformation, segmentation, morphological refinement, area-based filtering, and generation of output representations. Unlike the previous protocols, only one channel was used in the segmentation step, performed exclusively on the a* channel. It was expected that this channel provides a reliable separation of vegetation from non-vegetative elements such as blue, white, or black backgrounds. Thus, an automatic global threshold was calculated using Otsu’s method, combined with binary inversion, resulting in a preliminary binary mask in which leaf regions are highlighted while background regions are suppressed.
Algorithm 3 Preprocessing and segmentation steps applied on grass leaves in Pipeline C
1:
Gaussian blur:  Applied to RGB images using a 5 × 5 kernel.
2:
Color space conversion:  Conversion to the CIELab color space.
3:
Segmentation:  Otsu’s method with automatic threshold selection applied to the a* channel.
4:
Morphological operations:  Opening followed by closing applied to the a* mask using a 5 × 5 elliptical structuring element.
5:
External contour detection:  Applied to isolate the boundaries of each individual leaf in the image.
6:
Global segmented mask:  Final segmented image with a transparent background.
To improve the structural consistency of the segmented regions, morphological operations were applied to the binary mask, using an elliptical structuring element of size 5 × 5. First, a morphological opening operation is applied to remove small isolated artifacts and residual noise. This was followed by a morphological closure operation with multiple iterations to fill small gaps and ensure the continuity of leaf regions. The refined binary mask was further processed through contour detection, considering only external contours. Each detected region was evaluated on the basis of its area, and only contours exceeding a predefined threshold (10,000 pixels) are retained, effectively eliminating small objects and spurious detections. The selected contours are then filled to generate a final binary mask, and segmented images with a transparent background were created by converting the original image to RGBA format and assigning the final binary mask to the alpha channel.

2.4. Performance Assessment

For a preliminary evaluation, the leaf area (in pixels) was estimated as the total number of foreground pixels in the binary segmentation mask produced by each method. To quantitatively assess the discriminative capacity of each segmentation method, the Fisher Discriminant Ratio (FDR) was calculated based on a vegetation-related spectral index derived from the original RGB images. First, the Excess-Green (ExG) index was calculated for each image according to Equation (1):
ExG = 2 G − R − B
where R, G, and B denote the red, green, and blue channels, respectively.
The ExG index improves the contrast between vegetation and background, making it suitable for evaluating leaf–background separability. Thus, for each segmentation method, the resulting binary mask was applied to the ExG map to partition the pixel values into two classes: leaf pixels and background pixels. Let μ L and α L 2 represent the mean and variance of ExG values within the leaf class, and the corresponding statistics μ B and α B 2 for the background class. The Fisher Discriminant Ratio (FDR) was then computed according to Equation (2):
F D R = ( μ L − μ B ) 2 α L 2 + α B 2
The FDR quantifies the degree of separation between the two classes considering the inter-class distance and the intra-class variability. Higher FDR values indicate a clearer separation between the leaf and background regions, reflecting a more effective segmentation. The FDR was computed independently for each segmentation method and each image and subsequently used as a comparative indicator of segmentation quality between methods.
In the absence of ground truth annotations, disagreement-based indices were computed from consensus maps. Disagreement maps explicitly highlight regions where segmentation outputs diverge, allowing both visual inspection and numerical analysis of inter-method variability. The binary masks produced by each segmentation algorithm were first aligned and converted to a common binary representation. Then a global disagreement map was generated by identifying pixels for which at least one pair of segmentation methods produced different class assignments. Pixels classified identically by all methods were considered consensus regions, whereas pixels with inconsistent labels were marked as disagreement regions. This spatial representation enables the localization of ambiguous boundaries, over-segmentation, and method-specific artifacts, which are often obscured when using scalar performance metrics alone. In addition to visualization of global disagreement, pairwise disagreement metrics were calculated to quantify the level of inconsistency between individual segmentation methods. For each pair of methods, a Disagreement Ratio (DR) was calculated as the ratio between the number of pixels classified differently by the two methods and the union of pixels segmented as foreground by either method. This formulation normalizes disagreement by the effective segmented area, ensuring comparability across images with different object sizes and background proportions. For two binary segmentation masks μ i and μ j , the Disagreement Ratio is defined in Equation (3):
D R i j = | μ i ⨁ μ j | | μ i ∪ μ j |
where ⨁ denotes the exclusive OR operation (pixels for which two segmentation methods produce different labels, thus isolating disagreement regions) and ∪ denotes the logical union.
The lower values of D R i j indicate higher agreement and structural similarity between the two segmentation methods, whereas the higher values reveal substantial methodological divergence. To ensure a comprehensive and unbiased comparison of the segmentation algorithms, a set of complementary metrics was used (Table 1). This multi-criteria evaluation framework was designed to assess not only pixel-level agreement but also boundary fidelity and structural consistency [23].
Table 1. Summary of evaluation metrics and mathematical formulations used for segmentation algorithm pairwise comparisons.
The Intersection over Union (IoU) was used as a primary geometric metric to quantify the spatial overlap between two segmentation masks. Higher IoU values indicate greater spatial agreement between the segmentation results, reflecting improved geometric consistency. The Overlap Error (OE) was employed as a complementary geometric metric derived from IoU. OE explicitly quantifies the proportion of non-overlapping pixels between two masks, providing a direct measure of segmentation error. Lower OE values correspond to more accurate segmentation and penalize both over-segmentation and under-segmentation.
The Structural Similarity Index (SSIM) was used to assess structural consistency between segmentation masks. Unlike purely pixel-based metrics, SSIM incorporates luminance, contrast, and structural information, allowing the evaluation of global shape preservation. This metric is particularly relevant for evaluating the preservation of leaf morphology, and their values range from −1 to 1, with values closer to 1 indicating greater structural similarity. The Edge Preservation Index (EPI) was adopted to quantify the accuracy of boundary delineation. EPI measures the proportion of edges in a reference segmentation that are correctly preserved in a comparative segmentation. Higher EPI values indicate better preservation of leaf contours, which is critical for morphometric analyzes such as area and shape estimation. Geometric and structural metrics (IoU, OE, SSIM, and EPI) were calculated directly from the binary segmentation masks produced by each algorithm, either through pairwise comparisons between methods.

3. Results

Image segmentation is an essential step of systems based on image analysis, and it is considered a complex task, particularly for protocols of field images capturing. Image noise, uneven lighting conditions, object shape variation, and irregular boundaries are among the common challenges for segmentation algorithms, impacting their accuracy and generalization power [23]. The metrics of quantitative and qualitative performance provide objective parameters to identify strengths and possible gaps in the preprocessing steps designed to segment the leaf image.

3.1. Leaf Area Estimation and Discriminative Capability

The preliminary assessment revealed significant discrepancies in the estimation of the leaf area among the tested pipelines (Table 2), indicating that the preprocessing strategies adopted affected the spatial definition of the segmented objects and the stability of the segmentation. For both Urochloa hybrid Mavuno and U. decumbens, Pipeline B resulted in substantially higher average leaf area values compared to Pipelines A and C. This trend is visually corroborated by the radar map (Figure 3), in which each azimuthal axis represents an individual leaf sample (image), while the radial axis corresponds to the estimated leaf area in pixels. In this representation, the polygon corresponding to Pipeline B exhibits a pronounced expansion, suggesting a tendency towards the inclusion of background elements as regions of interest. In contrast, Pipelines A and C produced more conservative and comparable area estimates, particularly for U. decumbens.
Table 2. Metrics for performance assessment of the segmentation algorithms and pairwise comparisons.
Figure 3. Radar map of the leaf area (in pixels) obtained from Pipelines A (black), B (red), and C (blue) in images of Mavuno ((a), n = 80) and Decumbens ((b), n = 72) grass.
Regarding discriminative capacity, the Fisher Discriminant Ratio (FDR) indicated that Pipeline C provided the most consistent separation between leaf and background pixels. While Pipeline A showed moderate performance, Pipeline B exhibited the lowest minimum FDR values (0.272 and 0.09 for Mavuno and Decumbens, respectively), reinforcing the hypothesis that the color space transformation and thresholding strategies employed in this pipeline failed to adequately suppress the background under the tested illumination conditions and the instability of this pipeline for discriminative tasks. High intra-sample variability and low spatial stability are undesirable properties for further machine learning-based analyzes. Although Pipeline A exhibited intermediate behavior in terms of segmented area, its minimum FDR values were lower than those observed for pipeline C, suggesting greater susceptibility to noise and lighting variability. Pipeline C achieved the highest average minimum and maximum FDR values for both grasses, demonstrating superior robustness in distinguishing vegetation from the background.

3.2. Inter-Method Disagreement

The global discordance maps allowed visual inspection of the main disagreement points in the segmented area of each image (Figure 4). The preprocessing methods and the image-dependent factors affect the disagreement ratio (DR), reflecting how the methods respond to object boundaries, illumination conditions, and noise.
Figure 4. Examples of relevant errors observed from discordance maps obtained from pipelines on images of (a–c) Mavuno grass and (d–f) Decumbens.
The pairwise disagreement analysis (Figure 5) provided further information on the structural differences between the generated masks. The DR box-plots show that the comparison between Pipeline A and Pipeline C (DR_PA_PC) yielded the lowest median values and the smallest interquartile range.
Figure 5. Box-plot of the discordance ratio (DR) obtained from images of (a) Mavuno grass and (b) Decumbens grass from pairwise comparisons between pipelines A (PA), B (PB), and C (PC).
For this pairwise comparison, the DR values ranged from 0.065 to 0.244 in Decumbens and from 0.042 to 0.247 in Mavuno images, with 57% and 22% of the images exceeding a DR greater than 0.1, respectively. This indicates a high degree of consensus between these two methods regarding the location of leaf pixels. In contrast, comparisons involving Pipeline B (DR_PA_PB and DR_PB_PC) resulted in significantly higher disagreement ratios, with a wide dispersion of data points. This quantitative evidence aligns with the disagreement maps, which highlighted extensive non-overlapping regions when Pipeline B was involved, pointing to a systematic divergence in how this pipeline defines object boundaries compared to the others.

3.3. Geometric and Boundary Consistency

The analysis of geometric and boundary preservation metrics highlighted that pipelines A and C exhibit a better discriminative power (Figure 6). However, the Intersection over Union (IOU) revealed inconsistencies between their binary masks (Figure 6a,b). These pipelines showed structural similarity, with SSIM varying from 0.93 to 0.98 for Mavuno and from 0.95 to 0.97 in Decumbens images (Figure 6c,d), while the range revealed that at least 20 % of the images (OE > 0.1) still retained differences associated with non-overlapping pixels between the two masks (Table 2). Although the OE varied between images, Pipeline C achieved the lowest minimum OE values (0.005 for Mavuno and 0.011 for Decumbens), indicating instances of near-perfect segmentation relative to the consensus. More importantly, the Edge Preservation Index (EPI) revealed a critical distinction among the methods. Pipeline C consistently achieved much higher EPI scores (up to 0.75) compared to Pipelines A and B, which maximum values did not exceed 0.044.
Figure 6. Intersection over Union (IoU) and Structural Similarity Index (SSIM) from pairwise comparison between Pipelines A, B and C in images of Mavuno grass (a,c) and Decumbens grass (b,d).
The EPI provided a relative parameter of pixel overlap ratio. The general pairwise comparisons were based on Canny edge detection directly on binary masks, which is sensitive to small contour irregularities. Although the first implementation of EPI quantifies the preservation of directional edge as a pixel-wise overlap ratio between Canny-derived boundaries, the EPI using Sobel gradients, computed on the edge maps, measures symmetric boundary consistency through gradient alignment of morphologically extracted contours, making it more sensitive to shape coherence (Figure 7).
Figure 7. Examples of edge-based discordance maps using Sobel operation from pairwise comparison of pipelines A (boundaries detected exclusively by this method are in red) and C (boundaries detected exclusively by this method are in blue) obtained from images of (a) Mavuno grass and (b) Decumbens.
When pipelines A and C were compared using Sobel, a high frequency of negative values (Table 2) provided strong evidence of under-segmentation events of pipeline A (Figure 7). Thus, analysis of geometric and boundary preservation metrics highlighted the superior performance of Pipeline C. This result suggests that the simplified approach of Pipeline C, relying exclusively on the a* channel and morphological refinement, was far more effective in maintaining the integrity of leaf edges and natural contours than the multi-channel or edge-detection-based approaches of Pipelines A and B.

4. Discussion

It is important to emphasize that the present study focuses specifically on the segmentation stage of image analysis pipelines. While segmentation is often treated as a preliminary step, its quality directly affects the reliability of subsequent processes, such as feature extraction and predictive modeling. In this sense, improving segmentation robustness is a necessary step before the application of more advanced analytical methods, including machine learning and deep learning approaches.

4.1. Pipeline A

Operations using HSV color space are very popular for leaf image segmentation, as decoupling brightness (luminance retained on the V channel) from color information (chromaticity) into independent channels presumably allows for a more effective color segmentation on leaf objects besides robustness to lighting variations [24]. In the present investigation, before thresholding, an erosion operation was applied to each HSV channel to suppress small structures that were not spatially homogeneous, eliminating consistent spurious high-saturation pixels. The erosion operation acts here as a conservative filter that avoids prematurely removing relevant regions, and the elliptical kernel better matches the natural leaf geometry. The ranges for setting the H channel, which filters the color content, depend on the conditions of the captured images, the background, and the characteristics of the object. Thus, for pasture grass leaves, it should be considered that greenness may range from dark to bright green due to different N fertilization rates and growth status [25]. For grass leaves, settings for H are generally in the range of 50 to 150 for maize seedlings [25] and 35 to 100 for rice plants [16]. Moreover, the V channel is mainly focused on filtering out very dark or very bright areas, thus eliminating deep shadows or specular reflection. In pipeline A, the H and V settings were defined as [16], in an adapted protocol previously tested in [26], with Decumbens grass images. In addition, intensity-based thresholding using Otsu on the S channel would allow a good contrast between leaf tissue and the background and would be more sensitive when considering differences in pigment content. The multi-channel strategy should reduce false positives caused by background, shadows, or illumination artifacts, resulting in a more robust binary mask of leaf regions. However, ref. [21] argued that the H channel frequently shows inconsistencies for segmentation tasks, particularly when images present areas with low saturation (e.g., shadows), becoming unstable and noise-sensitive. In fact, in the present investigation, this was one of the main limiting factors of Pipeline A, which affected its sensitivity and robustness to recognize and preserve edges (Figure 8).
Figure 8. Intermediate processing stages of Pipeline A for grass leaf segmentation in representative samples of Mavuno (top row) and Decumbens (bottom row): (A) eroded H channel, (B) eroded S channel, and (C) final binary masks.
Another important factor was related to the masks derived from the S channel; about this [27] argued that the intensity-threshold is rarely adequate to yield useful segmentations. Some limitations are related to morphological leaf features, such as trichomes or glands, which naturally possess lower color purity than the surrounding leaf blade, resulting in limited or uneven contrast and appearing as ‘small holles’ on the final masks. In addition, the midrib of longer and more developed leaves in some species (e.g., Mavuno grass, Figure 8) appear lighter in the original images (low pigment content and high proportion of structural tissues), being misclassified as background in the binary mask. Thus, due to the resulting under segmentation, even applying morphological operations and mask refinements, protocols for grass-leaf segmentation should consider combining channels with other color spaces rather than exclusively the HSV.

4.2. Pipeline B

The preprocessing steps and segmentation rules associated with Pipeline B intended to overcome some of the limitations of using the HSV color space through a combined strategy with CIELab channels. One of the strategies presented by [21], who argued that robust segmentation was possible in leaves of all shapes and colors, combined the L* and b* channels with the S channel. In such a case, the b* channel was chosen due to the specificity for non-grass-leaves segmentation. On the other hand, ref. [28] adopted H and a* channels in order to discriminate against plants and soil background in pre-segmented masks. The authors observed that the H channel resulted in a high degree of pixel overlapping between plant and background, leading to systematic over-segmentation, and suggested that S and a* channels could produce more stable segmentation.
Some recent approaches have suggested that shading, overexposure, and variable lighting conditions can be efficiently managed by using Contrast Limited Adaptive Histogram Equalization (CLAHE) on the L channel as a preprocessing step [29] to enhance local contrast while preserving chromatic information. However, ref. [20] highlighted that, in some situations, applying CLAHE with a high clip limit can lead to more prominent noise pixels, requiring careful settings. In the present investigation, despite the visible improvement in contrast to individual leaves, the operation did not impact the discriminative capacity of the pipeline.
Segmentation in Pipeline B was performed on the S channel using Otsu’s adaptive thresholding and on the a* channel from CIELab, while morphological operations were applied at different stages as a mask refinement strategy; fortunately, the worst results were obtained from this pipeline. For diagnosis, the resulting masks from each step were visually inspected, verifying that the Flood fill operation was the main cause of segmentation errors (Figure 9).
Figure 9. Processing stages of Pipeline B for grass leaf segmentation: CLAHE applied to L channel, S and a* masks, combined mask, Flood fill result, and final binary mask illustrating segmentation errors.
The basic principle of the classic Flood fill algorithm is to find connected components (pixels) that share the same color as the seed pixel, recoloring bounded areas in a “flooding” process according to the target color of the seed. The propagation of the fill operation to adjacent pixels is affected by connectivity (four-way vs. eight-way), which determines which neighboring regions are considered connected and therefore eligible for filling. When eight-way connectivity is used, the diagonal adjacency pixel with thin boundaries can be interpreted as open paths (Figure 9), thus flooding the entire exterior of the shape [30].
Furthermore, S channel still retained instability in detecting and preserving leaf edges, showing high sensitivity to illumination and shadows (Figure 10).
Figure 10. Sensitivity of the S channel to illumination and shadow effects: original image and CLAHE preprocessing (top), and resulting S-based masks from Pipelines A and B (bottom).

4.3. Pipeline C

The CIELab channels have been widely used for leaf detection and segmentation, showing more stable results than the HSV color space for grass species [6], even under shaded conditions [28]. For segmentation tasks, the chromatic channels (a* and b*) are considered more robust than luminance because they capture the consistent spectral signature of vegetation and are less sensitive to shading effects. Channel a* encodes the green–red axis, demonstrating effectiveness in isolating leaves, although channel b* (blue–yellow axis) may be particularly relevant for nitrogen-deficient plants, as chlorosis and senescence are more accurately represented.
In the present investigation, both the a* and b* channels showed a good discriminative capacity between background and leaves (Figure 11). The a* channel from the original images (8-bit encoded Lab representation) ranged from 88 to 155 in Mavuno grass and from 81 to 149 in Decumbens images, while b* values varied from 92 to 184 and from 117 to 200, respectively (Table 3). Values associated with the a* channel expressed lower inter-image variability (lower standard deviation) and smaller variation between species, making it more stable and efficient for leaf segmentation tasks.
Figure 11. Discriminative capacity of CIELab chromatic channels in Pipeline C: a* channel representation and b* channel representation highlighting contrast between grass leaves and background for Mavuno (a) and Decumbens (b) species.
Table 3. Descriptive statistics of a* and b* channels.
C pipeline also demonstrated superior computational efficiency, achieving the lowest average processing times for both species (3.2 s for Mavuno and 2.2 s for Decumbens). This is particularly relevant for practical field applications, where fast and robust processing is required to support real-time or near-real-time decision-making.
In general, visual evidence and quantitative statistical results demonstrate that Pipeline C provides the most stable, discriminative, and computationally efficient preprocessing strategy. Its ability to preserve structural integrity while minimizing segmentation noise reinforces its suitability as a preprocessing foundation for subsequent machine learning modeling, contributing to improved robustness and generalization performance.
Although RGB imagery does not directly capture the full spectral response associated with plant nitrogen status, it has been widely used as a proxy for vegetation condition through color-based indices and visual traits. Variations in greenness, chlorosis, and overall leaf appearance are indirectly related to physiological changes influenced by nitrogen availability. Therefore, RGB-based approaches remain relevant for low-cost and scalable monitoring systems, particularly when combined with robust preprocessing and segmentation strategies.

5. Conclusions

Image segmentation is a broad research field encompassing diverse approaches tailored to specific data characteristics, target objects, and application contexts. In pasture-based production systems, the development of accessible, real-time, and cost-effective tools remains a key challenge, particularly for applications related to crop monitoring and management. In this context, automated image analysis systems fundamentally depend on accurate object detection and segmentation while preserving fine structural details such as leaf boundaries and shape integrity.
In the present study, segmentation stability and discriminative performance were strongly influenced by the balance between algorithmic complexity and chromatic selectivity. The choice of color representation directly affected performance metrics such as Intersection over Union (IoU), spatial stability, and structural preservation, reinforcing the importance of perceptually uniform color spaces, such as CIELAB, for vegetation segmentation tasks. Excessively complex pipelines increased sensitivity to noise and illumination artifacts, leading to instability in mask refinement steps.
In contrast, chromatic segmentation strategies based primarily on the a* channel promoted greater spatial consistency, improved structural preservation, and increased robustness under varying lighting conditions. The reduced inter-image variability observed in the a* channel further contributed to more stable discrimination between vegetation and background. The convergence of spatial stability, discriminative capacity, edge preservation, and computational efficiency consolidates Pipeline C as the most robust preprocessing and segmentation strategy among the evaluated approaches. Its superior performance and lower processing time highlight its practical suitability for real-time or near-real-time field applications.
This study should be interpreted as a methodological contribution focused on preprocessing and segmentation, rather than a complete solution for nitrogen diagnosis. The results demonstrate that careful selection of color space and preprocessing design can significantly improve segmentation stability and structural preservation, even when using low-cost imaging devices. By providing a robust and computationally efficient segmentation framework, this work establishes a foundation for future integration with advanced analytical models, including machine learning and deep learning approaches, as well as for applications under more complex field conditions.

Author Contributions

Conceptualization, A.R.B.T., L.E.T.P. and I.F.C.; methodology, I.F.C., A.R.B.T., L.E.T.P. and W.M.C.S.; software, A.R.B.T. and L.E.T.P.; validation, I.F.C. and M.d.G.B.; formal analysis, I.F.C., A.R.B.T., L.E.T.P., M.M.B. and W.M.C.S.; investigation, I.F.C.; resources, A.R.B.T. and I.F.C.; data curation, I.F.C.; writing—original draft preparation, I.F.C., A.R.B.T. and L.E.T.P.; writing—review and editing, A.R.B.T., L.E.T.P., I.F.C., W.M.C.S. and M.M.B.; visualization, I.F.C., A.R.B.T., L.E.T.P., W.M.C.S., M.M.B. and M.d.G.B.; supervision, A.R.B.T. and L.E.T.P.; project administration, A.R.B.T.; funding acquisition, I.F.C. and A.R.B.T. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Ministry of Higher Education, Science, Technology and Innovation of Angola, Project 4148—No. 004/D-USP/PDCT-N003/2023. This research was also funded by the São Paulo Research Foundation (FAPESP, Brazil), grant number 2020/00345-1, and by the Brazilian National Council for Scientific and Technological Development (CNPq) through the Productivity in Technological Development and Innovative Extension fellowship awarded to Adriano R. B. Tech (Process No. 304210/2021-8).

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The datasets generated during the current study are included in the article or available from the corresponding author upon reasonable request.

Acknowledgments

The authors thank the Faculty of Animal Science and Food Engineering (FZEA/USP) for supporting the research, the Research Group on Environment, Pastures, and Large Crops Monitoring (MAPAG) and the Ministry of Higher Education, Science, Technology, and Innovation of Angola. The authors gratefully acknowledge the financial support provided by the Coordination for the Improvement of Higher Education Personnel (CAPES) under Funding Code 001. We also thank the Luiz de Queiroz Foundation for Agricultural Studies (FEALQ) for its support of the research.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Zermas, D.; Nelson, H.J.; Stanitsas, P.; Morellas, V.; Mulla, D.J.; Papanikolopoulos, N. A methodology for the detection of nitrogen deficiency in corn fields using high-resolution RGB imagery. IEEE Trans. Autom. Sci. Eng. 2021, 18, 1879–1891. [Google Scholar] [CrossRef] [Scilit]
  2. Silva, L.; Conceição, L.A.; Lidon, F.C.; Maçãs, B. Remote monitoring of crop nitrogen nutrition to adjust crop models: A review. Agriculture 2023, 13, 835. [Google Scholar] [CrossRef] [Scilit]
  3. Liu, J.; Cai, H.; Chen, S.; Pi, J.; Zhao, L. A review on soil nitrogen sensing technologies: Challenges, progress and perspectives. Agriculture 2023, 13, 743. [Google Scholar] [CrossRef] [Scilit]
  4. Bertolini, C.A.; Tech, A.R.B.; Baesso, M.M.; Rossi, F.; Pereira, L.E.T. Desafios no uso de índices de vegetação baseados no RGB para diagnóstico do status de nitrogênio em gramíneas sob pastejo. In Zootecnia de Precisão: Desafios e Aplicações; Editora Científica Digital: São Paulo, Brazil, 2021; pp. 74–93. [Google Scholar]
  5. Sachar, S.; Kumar, A. Survey of feature extraction and classification techniques to identify plant through leaves. Expert Syst. Appl. 2021, 167, 114181. [Google Scholar] [CrossRef] [Scilit]
  6. Tao, M.; Ma, X.; Huang, X.; Liu, C.; Deng, R.; Liang, K.; Qi, L. Smartphone-based detection of leaf color levels in rice plants. Comput. Electron. Agric. 2020, 173, 105431. [Google Scholar] [CrossRef] [Scilit]
  7. Pereira, L.E.T.; Sousa, L.J.; Bertipaglia, L.M.A.; Herling, V.R.; Tech, A.R.B. Critical concentration and management of nitrogen fertilization in the establishment of Brachiaria hybrid Mavuno. Rev. Ciência Agronômica 2021, 52, e20207625. [Google Scholar] [CrossRef] [Scilit]
  8. Smith, A.P.; Christie, K.M.; Rawnsley, R.P.; Eckard, R.J. Fertiliser strategies for improving nitrogen use efficiency in grazed dairy pastures. Agric. Syst. 2018, 165, 274–282. [Google Scholar] [CrossRef] [Scilit]
  9. Vendramini, J.M.; Silveira, M.L.; Moriel, P. Resilience of warm-season (C4) perennial grasses under challenging environmental and management conditions. Anim. Front. 2023, 13, 16–22. [Google Scholar] [CrossRef] [Scilit]
  10. Gray, C. Nitrogen fertiliser use in grazed pasture-based systems in New Zealand: A summary. N. Z. J. Agric. Res. 2024, 67, 670–721. [Google Scholar] [CrossRef] [Scilit]
  11. Martínez-Dalmau, J.; Berbel, J.; Ordóñez-Fernández, R. Nitrogen fertilization: A review of the risks associated with the inefficiency of its use and policy responses. Sustainability 2021, 13, 5625. [Google Scholar] [CrossRef] [Scilit]
  12. Konara, B.; Krishnapillai, M.; Galagedara, L. Recent trends and advances in utilizing digital image processing for crop nitrogen management. Remote Sens. 2024, 16, 4514. [Google Scholar] [CrossRef] [Scilit]
  13. Ge, H.; Lv, G.; Qin, Y.; Shen, M. Assessing leaf nitrogen concentration in rice using RGB imaging: A comparative study at leaf, canopy, and plot scales. Front. Plant Sci. 2025, 16, 1599177. [Google Scholar] [CrossRef] [Scilit]
  14. Rahman, M.M.; Rahman, S.; Bhatt, S.; Faezipour, M. A systematic review on advancement of image segmentation techniques for fault detection opportunities and challenges. Electronics 2025, 14, 974. [Google Scholar] [CrossRef] [Scilit]
  15. Wołk, K.; Niklewski, J.; Kopczyński, M.; Tatara, M.S.; Żero, O. Enhancing semantic forestry segmentation through advanced preprocessing with ML models. IEEE Access 2025, 13, 98602–98621. [Google Scholar] [CrossRef] [Scilit]
  16. Sridevy, S.; Devi, M.N.; Sankar, M.; Moorthi, N.R. Image pre-processing techniques utilized for the plant identification: A review. Pharma Innov. J. 2023, 12, 320–324. [Google Scholar]
  17. Govindarajan, S.; Vennila, M. A Sequential Method for Enhancing the Image Quality of Rice Leaf Diseases by Employing Various Preprocessing Techniques. In Proceedings of the 9th International Conference on Smart Structures and Systems (ICSSS), Chennai, India, 23–24 November 2023; pp. 1–7. [Google Scholar] [CrossRef] [Scilit]
  18. Barbedo, J.G.A. A review on the main challenges in automatic plant disease identification based on visible range images. Biosyst. Eng. 2016, 144, 52–60. [Google Scholar] [CrossRef] [Scilit]
  19. Trivedi, M.; Gupta, A. Automatic monitoring of the growth of plants using deep learning-based leaf segmentation. Int. J. Appl. Sci. Eng. 2021, 18, 1–9. [Google Scholar] [CrossRef]
  20. Chutia, R.; Bora, D.J. Enhancing rice leaf images: An overview of image denoising techniques. arXiv 2025, arXiv:2511.00046. [Google Scholar] [CrossRef] [Scilit]
  21. Hu, T.; Poire, R.; Way, D. Leaf Analyzer: A fully automated and open-source tool for high-throughput leaf trait measurement. Plant Phenomics 2025, 8, 100145. [Google Scholar] [CrossRef] [Scilit]
  22. Soil Survey Staff. Illustrated Guide to Soil Taxonomy; USDA-NRCS: Lincoln, NE, USA, 2015; p. 372. [Google Scholar]
  23. Vlăsceanu, G.V.; Tarbă, N.; Voncilă, M.L.; Boiangiu, C.A. Selecting the right metric: A detailed study on image segmentation evaluation. BRAIN. Broad Res. Artif. Intell. Neurosci. 2024, 15, 295–318. [Google Scholar] [CrossRef] [Scilit]
  24. Ahmad, I.; Jusman, Y.; Rahmanto, Y.; Putrawansyah, F.; Borman, R.I. Integrating Self-Organizing Map and Principal Component Analysis for Enhanced Herbal Leaf Image Classification. Proc. BIO Web Conf. 2025, 199, 01009. [Google Scholar] [CrossRef] [Scilit]
  25. Yang, W.; Wang, S.; Zhao, X.; Zhang, J.; Feng, J. Greenness identification based on HSV decision tree. Inf. Process. Agric. 2015, 2, 149–160. [Google Scholar] [CrossRef] [Scilit]
  26. Bertolini, C.A. Desenvolvimento de Software para Extração de índices de Vegetação e Implementação de Classificador de Status Nutricional em Nitrogênio em Pastos de Urochloa Decumbens ‘Basilisk’. Ph.D. Thesis, Universidade de São Paulo, São Paulo, Brazil, 2022. [Google Scholar]
  27. Xu, H.; Blonder, B.; Jodra, M.; Malhi, Y.; Fricker, M. Automated and accurate segmentation of leaf venation networks via deep learning. New Phytol. 2022, 229, 631–648. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  28. Riehle, D.; Reiser, D.; Griepentrog, H.W. Robust index-based semantic plant/background segmentation for RGB-images. Comput. Electron. Agric. 2020, 169, 105201. [Google Scholar] [CrossRef] [Scilit]
  29. Sharma, S.; Vardhan, M. Aelgnet: Attention-based enhanced local and global features network for medicinal leaf and plant classification. Comput. Biol. Med. 2025, 184, 109447. [Google Scholar] [CrossRef] [Scilit]
  30. He, Y.; Hu, T.; Zeng, D. Scan-flood fill (SCAFF): An efficient automatic, precise region filling algorithm for complicated regions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops 2019; IEEE: New York, NY, USA, 2019. [Google Scholar]
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.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.