Stomatal analysis method and system for wheat leaves
Patent Information
- Application Number
- CN202611014763.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-09
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2046-07-09
AI Technical Summary
1、无精确像素级实例掩膜:现有方法多为边界框检测、语义分割、关键点检测,无法获取单个气孔精确像素级掩膜,形态参数测量精度受限;
1、同时实现高精度像素级分割、密集场景无遗漏、移动端离线、边缘感知统计、模型解耦扩展和高效批量推理。
Smart Images

Figure CN122598169B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of plant phenotypic identification technology, and in particular to stomatal instance segmentation, morphological phenotypic parameter measurement, dense target detection optimization, and real-time analysis technology for wheat leaf epidermal micrographs on mobile devices. Background Technology
[0002] Stomata are micropores formed by guard cells on the epidermis of plant leaves. They control the balance between CO2 (carbon dioxide) absorption and water transpiration, directly affecting photosynthetic efficiency and water use efficiency. The morphological traits of wheat stomata, such as density, size, and area, are core indicators of drought resistance and yield potential. Genetic studies such as genome-wide association analysis and genome selection require precise and high-throughput stomatal phenotypic identification of a large number of wheat genotypes.
[0003] Microscopic images of wheat leaf epidermis are characterized by extremely high stomatal density (100-200 per image), small target size (40-50 pixels × 25-35 pixels), similar morphology with blurred boundaries, and stomatal truncation at image edges. Existing technologies have the following drawbacks: 1. Lack of precise pixel-level instance masks: Existing methods are mostly bounding box detection, semantic segmentation, and key point detection, which cannot obtain precise pixel-level masks for individual pores, thus limiting the accuracy of morphological parameter measurement; 2. Omissions in dense scene detection: The current model has a detection limit of only 100, resulting in a large number of stomata being missed in wheat high-density stomata scenes; 3. Mobile devices rely on dedicated hardware and lack offline segmentation: Existing portable solutions require dedicated hardware such as Raspberry Pi, and can only perform detection box analysis locally. Segmentation requires a cloud connection, and complete analysis cannot be completed offline. 4. Morphological analysis without edge perception: Density calculation simply counts the total number / area without distinguishing between intact and truncated pores, introducing statistical bias; 5. Poor coupling and scalability of detection and segmentation models: a single end-to-end model with tight coupling between detection and segmentation, requiring retraining of the entire model for iteration, and limited resolution of the segmentation branch; 6. Low inference efficiency in dense scenes: Basic segmentation models such as SAM (Segment All Model) require inference for each target individually, which takes a very long time when there are 100+ pores in a single image. Summary of the Invention
[0004] This application provides a method and system for analyzing the stomata of wheat leaves to solve the problems in the prior art.
[0005] On the one hand, embodiments of this application provide a method for analyzing the stomata of wheat leaves, including: S1. Acquire microscopic images of wheat leaf epidermis, input the microscopic images into the target detection model, and obtain the coordinates and confidence of the bounding box of each stoma. S2 adopts a two-stage decoupled cascaded architecture for detection and segmentation, using the bounding boxes of all pores as selection prompts, and feeding them into the basic segmentation model in batches during a single forward propagation to generate a pixel-level binary mask for each pore. S3 performs contour extraction, ellipse fitting, and artifact filtering on pixel-level binary masks, extracting morphological parameters including pore length, width, area, aspect ratio, eccentricity, and orientation angle. S4. An edge-aware effective counting strategy is adopted to determine whether the mask outline of each pore in the pixel-level binary mask touches the image boundary. Based on the judgment result, the pores are divided into complete pores and edge-truncated pores. Only the morphological parameters of complete pores are counted. When calculating the density, complete pores are counted as 1, and edge-truncated pores are counted as fractional contributions based on the area ratio. S5. Deploy an end-to-end lightweight instance segmentation model on the mobile device. In offline mode, execute the lightweight instance segmentation model through ONNX Runtime (Open Neural Network Exchange Runtime Engine) for offline real-time inference. When the network is available, send the microscopic image to the server through WebSocket. The server executes the methods in steps S1-S4 to realize the analysis of stomata.
[0006] In one possible embodiment, the target detection model in step S1 is either YOLOv8m-seg (a medium-sized version of YOLOv8 for segmentation tasks) or RT-DETR-L (a real-time detection Transformer-L model).
[0007] In one possible embodiment, the basic segmentation model in step S2 is EfficientSAM-Ti (Lightweight and Efficient Segmentation Model for All Segments), which uses the ViT-Tiny (Small Version of Visual Transformer) encoder to generate pixel-level binary masks by using box selection prompts with zero samples. During batch inference, all bounding boxes of a single image are merged into a single forward propagation.
[0008] In one possible embodiment, the geometric rule used for artifact filtering in step S3 is: targets with a pixel area < 200 or a bounding box aspect ratio < 0.35 are identified as artifacts and automatically removed.
[0009] In one possible embodiment, the formula for the effective counting strategy of edge sensing in step S4 is: Effective count = Number of complete pores + Density = Effective count / Field area.
[0010] In one possible embodiment, the lightweight instance segmentation model in step S5 is an end-to-end NMS-free (non-maximum suppression) instance segmentation model based on the YOLO26n-seg (YOLO26n model for segmentation tasks) architecture, which is quantized by FP16 (half-precision floating-point number).
[0011] In one possible embodiment, a web analysis platform is also included. After the microscopic image is uploaded to the web analysis platform, the web analysis platform performs steps S1-S4 to complete the online analysis of the pores.
[0012] On the other hand, embodiments of this application also provide a wheat leaf stomatal analysis system, including: The target detection module is used to acquire microscopic images of wheat leaf epidermis, input the microscopic images into the target detection model, and obtain the coordinates and confidence scores of the bounding box of each stoma. The segmentation module employs a two-stage decoupled cascaded architecture for detection and segmentation, using the bounding boxes of all pores as selection prompts, and feeding them in batches into the basic segmentation model during a single forward propagation to generate a pixel-level binary mask for each pore. The morphological analysis module is used to extract contours, fit ellipses, and filter artifacts from pixel-level binary masks, extracting morphological parameters including pore length, width, area, aspect ratio, eccentricity, and orientation angle. The edge-aware statistics module is used to determine whether the mask outline of each pore in the pixel-level binary mask touches the image boundary using an effective edge-aware counting strategy. Based on the judgment result, the pores are divided into complete pores and edge-truncated pores. Only the morphological parameters of complete pores are counted. When calculating the density, complete pores are counted as 1, and edge-truncated pores are counted as fractional contributions based on their area ratio. On the mobile device, an end-to-end lightweight instance segmentation model is deployed. In offline mode, the mobile device executes the lightweight instance segmentation model through ONNXRuntime for offline real-time inference. When the network is available, the microscopic images are sent to the server via WebSocket. The server performs stomata analysis through the target detection module, segmentation module, morphological analysis module, and edge perception statistics module.
[0013] The method and system for analyzing wheat leaf stomata in this application have the following advantages: 1. Simultaneously achieves high-precision pixel-level segmentation, no omissions in dense scenes, offline performance on mobile devices, edge-aware statistics, model decoupling and expansion, and efficient batch inference.
[0014] 2. Detection limit of 300+, suitable for high-density scenes with 100-200 stomata per wheat image.
[0015] 3. Highly practical for field use; can be analyzed offline in real time using ordinary smartphones, without the need for dedicated hardware or network.
[0016] 4. Accurate phenotypic data and effective edge detection for counting effectively resolve statistical bias in edge-truncended stomata.
[0017] 5. The architecture is flexible and easily expandable, with detection and segmentation decoupled, eliminating the need to retrain the segmentation model and enabling rapid iteration of the adaptation model.
[0018] 6. High throughput and high efficiency: Laboratory batch analysis efficiency is about 280 times higher than manual measurement (about 2 minutes / image). Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a general framework diagram of the wheat leaf stomatal analysis method provided in the embodiments of this application.
[0021] Figure 2 This is a diagram of a dual-mode inference architecture for a mobile terminal provided in an embodiment of this application.
[0022] Figure 3 The flowchart for the detection-segmentation two-stage inference provided in the embodiments of this application is shown.
[0023] Figure 4 A flowchart for morphological feature extraction provided in an embodiment of this application.
[0024] Figure 5 A diagram of the Web analytics platform interface provided in an embodiment of this application.
[0025] Figure 6 Photos of mobile devices used in the field, provided as embodiments of this application. Detailed Implementation
[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0027] Figure 1 A framework diagram of the wheat leaf stomatal analysis method provided in this application embodiment. This application embodiment provides a wheat leaf stomatal analysis method, including: S1. Acquire microscopic images of wheat leaf epidermis, input the microscopic images into the target detection model, and obtain the coordinates and confidence of the bounding box of each stoma. S2 adopts a two-stage decoupled cascaded architecture for detection and segmentation, using the bounding boxes of all pores as selection prompts, and feeding them into the basic segmentation model in batches during a single forward propagation to generate a pixel-level binary mask for each pore. S3 performs contour extraction, ellipse fitting, and artifact filtering on pixel-level binary masks, extracting morphological parameters including pore length, width, area, aspect ratio, eccentricity, and orientation angle. S4. An edge-aware effective counting strategy is adopted to determine whether the mask outline of each pore in the pixel-level binary mask touches the image boundary. Based on the judgment result, the pores are divided into complete pores and edge-truncated pores. Only the morphological parameters of complete pores are counted. When calculating the density, complete pores are counted as 1, and edge-truncated pores are counted as fractional contributions based on the area ratio. S5. Deploy an end-to-end lightweight instance segmentation model on the mobile device. In offline mode, execute the lightweight instance segmentation model through ONNX Runtime for offline real-time inference. When the network is available, send the microscopic image to the server via WebSocket. The server executes the methods in steps S1-S4 to realize the analysis of pores.
[0028] For example, in the target detection stage of step S1, this application embodiment supports two target detectors, which users can choose according to their accuracy and speed requirements: YOLOv8m-seg detector and RT-DETR-L detector.
[0029] YOLOv8m-seg is a single-stage instance segmentation model. Its backbone network is CSPDarknet53 (cross-stage local Darknet53), composed of multiple C2f (double convolutional cross-stage fusion) modules, with the number of channels increasing sequentially from 48 to 96, 192, 384, and 576. Each C2f module contains multiple Bottleneck sub-modules (3×3 convolutions + residual connections), employing the SiLU (Sigmoid linear unit) activation function and BatchNorm (eps=0.001, momentum=0.03). The neck network uses a PANet (path aggregation network) structure, implementing top-down and bottom-up feature fusion at three scales: P3 / 8, P4 / 16, and P5 / 32. Specifically, it uses Upsample + Concat + C2f modules. The detection head is a decoupled head, independently outputting 4D bounding box regression and 1D class confidence at each scale. The loss function includes CIoU (Comprehensive Intersection over Union) bounding box regression loss (weight 7.5), cross-entropy classification loss (weight 0.5), and distribution focus loss (DFL) (weight 1.5). The final output is a 32-channel mask prototype with a resolution of 1 / 4 of the input. In the two-stage architecture of this application, only the detection head is used to output the bounding box, and no segmentation branch is used.
[0030] The YOLOv8m-seg detector has 27.2M parameters, and the training process is as follows: Pre-trained weights: yolov8m-seg.pt pre-trained on the COCO (Common Objects in Context) dataset; Training data: 1000 wheat leaf epidermal micrographs (COCO format annotation, 128263 stomatal instances, 800 / 200 split training / validation set); Input resolution: 1280×1280 pixels; Training rounds: 200 rounds, early stop patience value: 30 rounds; Optimizer: AdamW, initial learning rate lr=0.001, final learning rate decay factor lrf=0.01, weight decay weight_decay=0.0005; Preheating: 5 rounds of linear preheating; Data augmentation: HSV (Hue, Saturation, and Brightness) gamut transformation (h=0.015, s=0.4, v=0.3), random rotation (±15°), random translation (0.1), random scaling (0.3), horizontal flip (probability 0.5), vertical flip (probability 0.5), Copy-Paste enhancement (probability 0.1), random erasure (probability 0.4), and RandAugment automatic enhancement; mosaic enhancement is off (dense scenes will disrupt spatial distribution). AMP (Automatic Mixed Precision) Training: Enabled; Hardware environment: NVIDIA RTX4090 (24GB VRAM), training time approximately 1.4 hours.
[0031] The RT-DETR-L detector is a Transformer-based real-time object detector employing an encoder-decoder architecture. Its core consists of a hybrid encoder and uncertainty-aware query selection. The backbone network is ResNet-50, outputting multi-scale feature maps (C3, C4, C5). The hybrid encoder includes AIFI (intra-scale feature interaction, applying Transformer self-attention to the highest-level feature map to capture global context) and CCFF (cross-scale feature fusion, an FPN+PAN (feature pyramid network + path aggregation network) structure + deformable convolution). The Transformer decoder has six decoding layers, including self-attention, cross-attention, and feedforward networks. It receives 300 learnable queries and outputs detection results end-to-end without NMS post-processing. The output consists of 300 fixed detection slots, each containing the coordinates of a 4D bounding box and a 1D class confidence score.
[0032] The RT-DETR-L detector has approximately 32M model parameters, and its training process is as follows: Pre-trained weights: rtdetr-l.pt pre-trained on the COCO dataset; Training data: The same 1000 images as YOLOv8m-seg; Input resolution: 1280×1280 pixels; Number of training rounds: 200 rounds; Optimizer: AdamW, initial learning rate lr=0.0001 (adapted to Transformer architecture), final learning rate decay factor lrf=0.01, weight decay weight_decay=0.0005; Preheating: 3 rounds of linear preheating; Data augmentation: HSV color gamut transformation (h=0.015, s=0.7, v=0.4), random translation (0.1), random scaling (0.5), and horizontal flip (probability 0.5); Mosaic enhancement off; AMP training: Enabled; Patience level: 100 rounds; Hardware environment: Same as YOLOv8m-seg, training time is about 3.5 hours.
[0033] The key parameters in the detection phase are: Input resolution: 1280×1280 (preserving details of small targets); Confidence threshold: 0.25 (recall priority); Maximum number of detections: 300 (adapted to high-density wheat fields, solving the problem of omissions in dense fields); NMS deduplication: IoU (Intersection over Union) threshold 0.3 (only required for YOLOv8m-seg, not required for RT-DETR).
[0034] like Figure 3 As shown, in the segmentation stage of step S2, all the bounding boxes output in step S1 are used as selection prompts and fed into EfficientSAM-Ti to generate pixel-level binary masks.
[0035] The EfficientSAM-Ti model is a lightweight distillation variant of SAM, distilled from SAM-ViT-H (Segmentation Everything Model - a giant version of the Visual Transformer) through MAE (Mask Autoencoder) pre-training, with 10.22M parameters (1.6% of SAM-ViT-H). The image encoder is ViT-Tiny, with an input resolution of 1024×1024, a 16×16 convolutional projection patch embedding, 12 Transformer Block layers, 3 attention heads, a 768-dimensional MLP (Multilayer Perceptron) hidden layer, and GELU (Gaussian Error Linear Unit) activation function + LayerNorm (Layer Normalization) + residual connections. The neck layer consists of two 1×1 convolutional layers, with the number of channels increasing from 192 to 256. The cue encoder supports bounding box cueing, assigning labels [2,3] to the two corner points, converting them into a 256-dimensional cue vector. The mask decoder is a 2-layer bidirectional Transformer with 8 attention heads, transposed convolution upsampling, and multiple mask outputs (each prompt has 3 candidates). The IoU prediction head selects the optimal mask. Pixel normalization uses ImageNet mean [0.485, 0.456, 0.406] and standard deviation [0.229, 0.224, 0.225]. No retraining is required for the stomata dataset, and segmentation is achieved with zero-sample transfer.
[0036] In the batch processing of forward propagation, the input data are: image tensor [1,3,H,W] (RGB, float32, normalized [0,1]), bounding box coordinates [1,N,2,2] (N is the number of pores, 2 corner points), and cue labels [1,N,2] (corner label [2,3]). The output of a single forward propagation is mask prediction [1,N,3,H,W] and IoU prediction [1,N,3]. The post-processing is to sort by IoU score and select the optimal mask. Pixels with logit≥0 are marked as foreground, resulting in a pixel-level binary mask.
[0037] When the maximum side of the input image is greater than 1536 pixels, inference is scaled down to a maximum side of 1536 pixels. The mask is then restored to its original resolution using nearest neighbor interpolation to avoid memory overflow. Verification shows that an average of 128 vents per image can be achieved. Batch inference is approximately 300 times faster than individual inference (0.3 FPS for individual inference versus 107.8 FPS for batch inference). The two-stage pipeline speed is 18.9 FPS (YOLO) / 3.4 FPS (RT-DETR), and 9888 images can be processed in approximately 42 minutes.
[0038] The mobile terminal in this embodiment supports dual modes: local offline inference and remote high-precision inference. Figure 2 As shown, it is compatible with ordinary Android smartphones and requires no special hardware.
[0039] In local inference mode, the data processing flow is as follows: USB (Universal Serial Bus) portable microscope → UVC (USB video class) driver to acquire NV21 (half-plane 21) video stream → NV21 → JPEG (Joint Image Experts Group) encoding (70% quality) → Bitmap decoding → Letterbox preprocessing (scaled to 640×640, gray fill) → StomataLive-Nano FP16 quantization model ONNX Runtime inference (8 threads) → Postprocessing (confidence filtering → coordinate inverse mapping → ellipse contour generation) → Morphological feature calculation → Artifact filtering + edge-aware density calculation → UI overlay rendering + statistics panel.
[0040] In remote inference mode, the data processing flow is as follows: USB portable microscope → UVC driver acquires NV21 video stream → NV21 → JPEG encoding (70% quality) → WebSocket sends JPEG binary frames to GPU (Graphics Processing Unit) server (port 8502) → Server performs two-stage inference (YOLO / RT-DETR + EfficientSAM batch segmentation) → Server performs morphological analysis → JSON (JavaScript Object Notation) results are returned to mobile device → UI (User Interface) renders fine mask contours + statistics panel.
[0041] The difference between the two modes is as follows: the local mode uses a lightweight end-to-end model (3.13M parameters), outputting a bounding box + segmentation coefficients, and an elliptical approximation contour (20 sampling points); the remote mode uses a complete two-stage pipeline, outputting a pixel-level mask, and using approxPolyDP (polygon approximation) to simplify the contour before transmission. Both modes require the same morphological analysis process after completion.
[0042] In local inference mode, the end-to-end NMS-free instance segmentation model based on the YOLO26n-seg architecture is called StomataLive-Nano. This model is YOLO's latest lightweight instance segmentation model, with the core being the elimination of DFL and native end-to-end NMS-free segmentation. It has 3.13M parameters and is adapted for mobile devices. Its backbone network is a lightweight CSP structure, with Stem modules (Conv2d(3→16,3×3,stride=2)→Conv2d(16→32,3×3,stride=2)), 4 downsampling stages, and the number of channels 16→32→64→128→256. Each stage contains a C3k2 module (Bottleneck + residual connection), SiLU activation + BatchNorm2d. The detection head is a one-to-one design with a fixed output of 300 detection slots. Each slot contains a 4-dimensional bounding box, a 1-dimensional confidence score, a 1-dimensional class, and 32-dimensional mask coefficients, with a total output tensor [1,300,38]. Output a 32-channel mask prototype tensor [1,32,160,160].
[0043] The training process of the model is as follows: no pre-training, 1000 dataset images, input 1280×1280, 200 rounds of training (93 rounds of early stopping), AdamW optimizer, cosine annealing learning rate, 5 rounds of linear warm-up, data augmentation including mosaic augmentation, random erasure and RandAugment, loss function including CIoU, cross-entropy and RLE (run-length encoding) mask loss, mixed precision training, RTX4090 training for about 2 hours.
[0044] The model is exported as PyTorch weightsbest.pt (6.7MB), ONNX FP16 quantization (5.4MB, Android), and ONNX FP32 quantization (11MB).
[0045] The end-to-end NMS-free approach in this application embodiment has the following advantages: Predictable inference latency: Fixed 300 detection slots, O(N) latency without NMS 2 Time consumption, but constant latency in intensive scenarios; ONNX Runtime Deployment: Loads model configuration with 8 threads and the highest optimization level, returns all detection results in one call, and requires no additional NMS operator; The model size is extremely small: 5.4MB after FP16 quantization, and it is embedded in the APP (application) installation package, requiring no additional download.
[0046] Taking the Android mobile client as an example, its local inference process is as follows: Video frame acquisition: USB OTG (plug and play) connection to portable microscope, AUSBC (Android USB camera) 3.2.7 library to implement UVC driver, read 1280×960@15fps NV21 video stream; Frame throttling: Latest-Frame-Only strategy, atomic references are used to save the latest frame, old frames are discarded when inference is busy, and the latest frame is always processed; Image preprocessing: NV21→JPEG→Bitmap→Letterbox scaled to 640×640, gray fill (RGB=114 / 255), converted to CHW (channel, height, and width) format FloatBuffer; ONNX Runtime Inference: Input a tensor of [1,3,640,640], run session.run, and output a detection slot of [1,300,38] and a mask prototype of [1,32,160,160]. Post-processing: Filter low-confidence results, inversely map the coordinates back to the original image, and generate a 20-point elliptical contour. Morphological feature calculation: Convert pixels to physical units (1px=1.389um), calculate length, width, area, and aspect ratio; Statistical summary + UI rendering: edge-aware density calculation, real-time overlay of outlines, and display of count, density, and mean parameters.
[0047] like Figure 4 As shown, in the morphological analysis of step S3, the maximum area contour is extracted from the pixel-level binary mask. The main method is fitEllipse ellipse fitting, the backoff scheme is minAreaRect, and the extreme backoff is boundingRect. The major axis, minor axis, and orientation angle are output. If the contour is ≤2px from the image boundary, it is marked as an edge-trunculated pore; otherwise, it is a complete pore. The pixel values are converted to physical units according to the microscope calibration parameters (1px = 1.389um at 220X), and the area, length, width, aspect ratio, eccentricity, orientation angle, whether it is an edge, and fitting method are extracted.
[0048] Artifact filtering automatically removes false detections based on geometric rules: pixels with an area < 200 are identified as artifacts, or bounding box aspect ratios (min / max sides) < 0.35 are identified as artifacts (cell walls / leaf veins); in this dataset, 1.27% of the detection results (15894 / 1246880) were filtered.
[0049] The effective counting strategy is: Effective count = Number of intact stomata + Density (numbers / mm) 2 = Effective count / Field area (mm) 2Morphological statistics (mean / standard deviation of length, width, etc.) use only complete pores to avoid edge truncation bias.
[0050] In embodiments of this application, a web analytics platform is also included, with an interface as shown below. Figure 5 As shown, this platform is a web service built on FastAPI (Fast Application Programming Interface), and its core functions are: RESTAPI (Representational State Transition Application Programming Interface): Supports single-graph analysis and batch SSE (Server Push Events) streaming analysis; Canvas interactive viewer: enables mask overlay, annotation hovering, and statistics panel display; Automatic calibration: Matches microscope calibration parameters according to image size; GPU locks: Asynchronous locks ensure inference serialization; Input validation: magicbytes file type check, size / resolution validation; Data export: Supports CSV / XLSX (comma-separated values / spreadsheet file based on Extensible Markup Language) format, exporting data tables for each pore and each image; Interface Functions: The homepage displays the number of training annotations, the number of analyzed stomata, segmentation accuracy, and inference speed, and supports switching between Chinese and English; the sample image library displays pre-analyzed images and supports switching between fast and accurate modes; image upload supports PNG (Portable Network Graphics), JPG (Joint Image Experts Group), TIFF (Tagged Image File Format), and BMP (Bitmap Image) formats, and the detection model, confidence level, and calibration coefficients can be configured.
[0051] This application also provides a wheat leaf stomatal analysis system, which includes the following modules: The target detection module is used to acquire microscopic images of wheat leaf epidermis, input the microscopic images into the target detection model, and obtain the coordinates and confidence scores of the bounding box of each stoma. The segmentation module employs a two-stage decoupled cascaded architecture for detection and segmentation, using the bounding boxes of all pores as selection prompts, and feeding them in batches into the basic segmentation model during a single forward propagation to generate a pixel-level binary mask for each pore. The morphological analysis module is used to extract contours, fit ellipses, and filter artifacts from pixel-level binary masks, extracting morphological parameters including pore length, width, area, aspect ratio, eccentricity, and orientation angle. The edge-aware statistics module is used to determine whether the mask outline of each pore in the pixel-level binary mask touches the image boundary using an effective edge-aware counting strategy. Based on the judgment result, the pores are divided into complete pores and edge-truncated pores. Only the morphological parameters of complete pores are counted. When calculating the density, complete pores are counted as 1, and edge-truncated pores are counted as fractional contributions based on their area ratio. On the mobile device, an end-to-end lightweight instance segmentation model is deployed. In offline mode, the mobile device executes the lightweight instance segmentation model through ONNXRuntime for offline real-time inference. When the network is available, the microscopic images are sent to the server via WebSocket. The server performs stomata analysis through the target detection module, segmentation module, morphological analysis module, and edge perception statistics module.
[0052] To verify the superiority of the method proposed in this application, experimental comparisons were conducted in the following six aspects.
[0053] 1. The results of the segmentation accuracy experiment are shown in Table 1.
[0054] Table 1. Experimental results of segmentation accuracy
[0055] As can be seen from Table 1, although Mask R-CNN (masked region convolutional neural network) achieves the highest mask mAP of 50-95, it requires training the segmentation branch on the stomata dataset; EfficientSAM in this application does not require retraining and has zero-sample transfer.
[0056] 2. The results of the counting accuracy experiment in dense scenes are shown in Table 2.
[0057] Table 2. Experimental Results of Technical Accuracy in Dense Scenes
[0058] 3. From "impossible" to "real-time" in the field mobile terminal, the experimental results are shown in Table 3.
[0059] Table 3 Comparison of Equipment Dependency Results
[0060] 4. High-throughput processing efficiency experiment, the results are shown below: The server (RTX 4090) uses Mask R-CNN, with a processing speed of 2.3 images / second. It completed the processing of 9888 images in 70.5 minutes, extracting all morphological parameters of 1,246,880 stomata. Compared with manual measurement (about 2 minutes / image), the efficiency is improved by about 280 times.
[0061] 5. Biological validation experiments of phenotypic data, the results are shown below: Pore complex length: mean 46.49 μm; Pore complex width: mean 32.18 μm; Pore density: mean 51.22 ± 4.34 pores / mm² 2 .
[0062] 6. The size of the dataset is shown in Table 4.
[0063] Table 4 Comparison of Dataset Sizes
[0064] The dataset in this application consists of 1000 wheat leaf epidermal microscopic images. Each stomatal instance polygon mask was manually annotated image by image using the CVAT (Computer Vision Annotation Tool) annotation platform, resulting in 128263 annotated instances. The dataset was divided into a training set and a validation set (seed=42) with a ratio of 800 / 200.
[0065] Example 1: Server-side large-scale phenotypic analysis.
[0066] Scene: 546 wheat genotypes (WSP-I population n=275, WSP-II population n=271), 2 environments, 10 microscopic images per genotype, totaling 9888 images.
[0067] Steps: 1. Organize images according to the "Environment × Group" directory structure. 2. Batch load and send to the detection-segmentation inference engine (Mask R-CNN, with optimal mask boundary accuracy; the detection-segmentation two-stage decoupling process protected in this application is described in the specific implementation method and examples 2-4). 3. Morphological analysis: ellipse fitting → artifact filtering → edge-aware statistics. 4. Output per_stoma.csv (one stomata per row) and per_image.csv (one image per row).
[0068] Results: Completed in approximately 70.5 minutes (Mask R-CNN), 1,246,880 pores were detected, and artifact filtering was 1.27%.
[0069] Example 2: Real-time data collection from mobile devices in the field (local inference mode).
[0070] Scenario: Breeders use an Android smartphone connected to a Dino-Lite USB portable microscope in a field without internet access, such as... Figure 6 As shown.
[0071] Steps: 1. Launch the StomataLive app; the USB microscope will be automatically recognized. 2. Load the StomataLive-Nano FP16 quantization model (5.4MB) using the ONNX Runtime. 3. Enter session mode and import the genotype list. 4. LIVE mode: Real-time preview + stomatal elliptical outline overlay. 5. Capture: Freeze the image; the side panel displays stomatal counts and statistics. 6. Save: Save the screenshot to the album; write the data to the Room database, automatically incrementing the repeating number. 7. Export as a CSV file after all collections are complete.
[0072] Results: Pore detection and contour overlay were completed completely offline, without the need for a network.
[0073] Example 3: Real-time data collection from mobile devices in the field (remote inference mode).
[0074] Scenario: A WiFi environment is available, and fine segmentation is required.
[0075] Steps: Same APP and workflow as in Example 2, but the frame is sent to the GPU server via WebSocket to perform YOLO+EfficientSAM inference and return pixel-level mask contours.
[0076] Result: End-to-end latency of approximately 300ms / frame, achieving a fine SAM mask.
[0077] Example 4: Web interaction analysis.
[0078] Scenario: Researchers upload images via a browser for analysis.
[0079] Steps: 1. Access the StomaSeg Web platform and upload the image. 2. Select the detection model (YOLO / RT-DETR) and confidence level. 3. Canvas viewer: mask overlay, hover to view parameters, statistics panel. 4. Supports recalibration (instant recalculation of physical unit values after modifying μm / px).
[0080] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0081] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for analyzing the stomata of wheat leaves, characterized in that, Includes the following steps: S1, acquire microscopic images of wheat leaf epidermis, input the microscopic images into the target detection model, and obtain the coordinates and confidence level of the bounding box of each stoma; S2 employs a two-stage decoupled cascaded architecture for detection and segmentation. The bounding boxes of all pores are used as selection cues and are batched into the basic segmentation model in a single forward propagation to generate a pixel-level binary mask for each pore. The basic segmentation model is EfficientSAM-Ti, which uses a ViT-Tiny encoder. The pixel-level binary mask is generated using zero-sample bounding box cues. During batch inference, all the bounding boxes of a single image are merged into a single forward propagation. S3, perform contour extraction, ellipse fitting and artifact filtering on the pixel-level binary mask, and extract morphological parameters including pore length, width, area, aspect ratio, eccentricity and orientation angle. S4, employing an edge-aware effective counting strategy, it determines whether the mask outline of each pore in the pixel-level binary mask touches the image boundary. Based on the determination result, the pores are divided into complete pores and edge-truncated pores. Only the morphological parameters of the complete pores are counted. When calculating the density, complete pores are counted as 1, and edge-truncated pores are counted as fractional contributions based on their area ratio. The formula for the edge-aware effective counting strategy is: Effective count = Number of complete pores + Density = Effective count / Field area; S5. Deploy an end-to-end lightweight instance segmentation model on the mobile device. In offline mode, execute the lightweight instance segmentation model through ONNX Runtime to perform offline real-time inference. When the network is available, send the microscopic image to the server through WebSocket. The server executes the methods of steps S1-S4 to realize the analysis of pores.
2. The method for analyzing the stomata of wheat leaves according to claim 1, characterized in that, The target detection model mentioned in step S1 is YOLOv8m-seg or RT-DETR-L.
3. The method for analyzing the stomata of wheat leaves according to claim 1, characterized in that, The geometric rule used for artifact filtering in step S3 is as follows: targets with a pixel area < 200 or a bounding box aspect ratio < 0.35 are identified as artifacts and automatically removed.
4. The method for analyzing the stomata of wheat leaves according to claim 1, characterized in that, The lightweight instance segmentation model mentioned in step S5 is an end-to-end NMS-free instance segmentation model based on the YOLO26n-seg architecture, which has been quantized by FP16.
5. The method for analyzing the stomata of wheat leaves according to claim 1, characterized in that, It also includes a Web analysis platform. After the microscopic image is uploaded to the Web analysis platform, the Web analysis platform executes steps S1-S4 to complete the online analysis of stomata.
6. A system for analyzing the stomata of wheat leaves according to any one of claims 1-5, characterized in that, Includes the following modules: The target detection module is used to acquire microscopic images of wheat leaf epidermis, input the microscopic images into the target detection model, and obtain the coordinates and confidence of the bounding box of each stoma. The segmentation module employs a two-stage decoupled cascaded architecture for detection and segmentation, using the bounding boxes of all pores as selection prompts, and feeds them into the basic segmentation model in batches during a single forward propagation to generate a pixel-level binary mask for each pore. The morphological analysis module is used to perform contour extraction, ellipse fitting and artifact filtering on the pixel-level binary mask, and extract morphological parameters including pore length, width, area, aspect ratio, eccentricity and orientation angle. The edge-aware statistics module is used to determine whether the mask outline of each hole in the pixel-level binary mask touches the image boundary using an effective edge-aware counting strategy. Based on the determination result, the holes are divided into complete holes and edge-truncated holes. Only the morphological parameters of the complete holes are counted. When calculating the density, the complete holes are counted as 1, and the edge-truncated holes are counted as fractional contributions based on their area ratio. On the mobile device, an end-to-end lightweight instance segmentation model is deployed. In offline mode, the mobile device executes the lightweight instance segmentation model through ONNXRuntime for offline real-time inference. When the network is available, the microscopic image is sent to the server via WebSocket. The server analyzes stomata through the target detection module, the segmentation module, the morphological analysis module, and the edge-aware statistics module.
Citation Information
Patent Citations
Microscopic image-based gramineous plant leaf stomatal index measurement method
CN111860459A
Poplar leaf pore detection method based on microscopic image
CN120912533A