A semi-automatic phenotype data measurement method and system in a field scene

By using a pre-trained SAM model and image processing algorithms, efficient and accurate measurement of plant phenotypic data in field scenarios was achieved, solving the problems of low efficiency, low accuracy and poor generalization ability in existing technologies, and providing high-precision phenotypic data support.

CN121053548BActive Publication Date: 2026-02-13XIANGJIANG LAB
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511593636.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-03
Publication Date
2026-02-13
Estimated Expiration
2045-11-03

AI Technical Summary

Technical Problem

Existing technologies suffer from low efficiency, low accuracy, and poor generalization ability in phenotypic data measurement in field settings. In particular, the dense planting leads to organ occlusion, traditional algorithms require a large amount of labeling and training, resulting in high costs, and the measurement methods have poor universality.

Method used

Image segmentation is performed using a pre-trained SAM model. Combined with morphological feature judgment and skeletonization, plant phenotypic parameters are automatically extracted, including the length, width, and angle of upright and curved forms. The angle between leaves is calculated by PCA dimensionality reduction, enabling zero-sample data labeling and model training.

Benefits of technology

It improves measurement efficiency by more than 10 times, achieves a complete phenotypic data acquisition rate of over 95%, and has generalization capabilities covering major food crops and any growth cycle, providing high-precision phenotypic quantification support and shortening the breeding cycle.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121053548B_ABST
    Figure CN121053548B_ABST
Patent Text Reader

Abstract

The application provides a kind of semi-automatic field scene under the phenotype data measurement method and system, belong to the phenotype data measurement field under the outdoor field scene, the method comprises: collecting crop image, and according to crop image, obtain the target phenotype center coordinate point specified by user;Crop image and target phenotype center coordinate point specified by user are segmented by pre-trained SAM model, and target phenotype mask image is obtained;The morphological characteristics of the mask image are obtained by judging the bending characteristics of the mask image, wherein the morphological characteristics include straight shape and curved shape.The application can be widely applied to various plant, plant phenotype data calculation method under the scene without data collection, calibration and model training, and can avoid a large amount of cost caused by data annotation and model training.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of phenotype data measurement in outdoor field scene, and particularly relates to a method for collecting crop image data in field scene by a shooting device, segmenting crop phenotype by applying deep learning knowledge, and calculating phenotype data, and particularly refers to a semi-automatic phenotype data measurement method and system in field scene. BACKGROUND

[0002] In crop genetic breeding research, high-throughput collection of phenotype data is the core basis for establishing genotype-phenotype correlation. Currently, phenotype measurement in field scene mainly relies on two types of technologies:

[0003] 1. Manual field measurement: workers need to carry a ruler, protractor and other tools to the field, and measure leaf length, leaf width, ear length and leaf angle of each plant. This method has the following significant defects: low efficiency: breeding tests often involve hundreds of varieties and tens of hectares of planting area, and 5-8 repeated measurements are needed per growth cycle. Manual data collection can only be completed in 20 hectares per day; subjective bias: it is difficult to access the target phenotype in the overlapping area of plants (such as the tillering stage of rice), and the measurement error of leaf angle is ±7°; risk of crop damage: manual entry into densely planted fields can easily trample crops, affecting long-term observation continuity.

[0004] 2. Traditional algorithm model: automatic measurement methods based on computer vision (such as YOLO, UNet) reduce human intervention, but have fundamental limitations: poor generalization ability: the model is sensitive to changes in crop growth stages. For example, the same rice variety needs to be trained with different models for the heading stage (straight green ear) and the mature stage (bent yellow ear), and the cross-period recognition accuracy is less than 40%; strong data dependence: tens of thousands of accurately labeled images are needed for training, but complete phenotype labeling in a dense field scene is extremely difficult. Leaf shading results in 70% of the labeling covering only part of the organ (such as half a leaf), and after the model is trained based on this, the complete phenotype detection rate in the inference result is less than 35%; high cost: 20 people per month are needed for single crop labeling, and the labeling quality directly affects the model performance. Even if a high cost is invested in labeling complete phenotypes, the model can still confuse similar backgrounds (such as misjudging adjacent leaves as target leaves), and the actual demand-satisfying result is less than 50%.

[0005] The existing technology cannot meet the "efficiency-accuracy-generalization" triple requirements, and the core contradiction lies in: difficulty in obtaining complete phenotypes: dense planting leads to organ shading, and the measurable complete phenotypes in the photographed image are less than 30%; high labeling and training cost: traditional algorithms need to be repeatedly labeled and trained for each crop and each growth stage; poor universality of measurement methods: curved phenotypes (such as rice ears in the grain filling stage) lack automatic measurement means and rely on manual line pulling with large errors. SUMMARY

[0006] The technical problem to be solved by the present application is to provide a semi-automatic field scene phenotype data measurement method and system, which can be widely applied to various plant, scene plant phenotype data calculation methods without data collection, calibration and model training, and can avoid a large amount of cost caused by data annotation and model training.

[0007] To solve the above technical problems, the technical solutions of the present application are as follows:

[0008] In a first aspect, a semi-automatic field scene phenotype data measurement method is provided, comprising:

[0009] Step 1: Collecting crop images, and obtaining user-specified target phenotype center coordinate points according to the crop images;

[0010] Step 2: Segmenting the crop images and the user-specified target phenotype center coordinate points through a pre-trained SAM model to obtain a target phenotype mask image;

[0011] Step 3: Obtaining the morphological features of the mask image by judging the bending features of the mask image, wherein the morphological features include upright morphology and bending morphology;

[0012] Step 4: Extracting the minimum circumscribed rectangle of the upright morphology mask image, taking the long side of the rectangle as the target phenotype length and the short side as the target phenotype width to obtain the upright phenotype parameters;

[0013] Step 5: Generating a skeleton graph by sequentially performing binarization, morphological denoising and skeletonization on the bending morphology mask image, constructing a graph structure based on the skeleton graph and identifying end points, taking the longest path between the end points as the target phenotype bending length to obtain the bending phenotype length;

[0014] Step 6: Obtaining each leaf independent mask by steps 1 and 2, sequentially performing binarization, denoising, skeletonization, connected domain labeling and region attribute extraction on each leaf mask; and performing PCA dimensionality reduction on the extracted region attributes to obtain leaf direction vectors, calculating the angle between the two direction vectors according to the inverse cosine value to obtain the leaf angle parameter.

[0015] Further, in step 2, the crop images and the user-specified target phenotype center coordinate points are segmented through the pre-trained SAM model to obtain the target phenotype mask image, comprising:

[0016] Image encoding processing of the crop images through the SAM model to obtain deep image features;

[0017] Processing the user-specified target phenotype center coordinate through the prompt encoder of the SAM model to obtain spatial position encoding;

[0018] The depth image features and the spatial position code are input into a mask decoder of the SAM model to obtain a binary mask image corresponding to the target phenotype.

[0019] Further, in step 3, the bending feature of the mask image is judged to obtain the shape feature of the mask image, wherein the shape feature includes a straight shape and a bending shape, and the shape feature includes the following steps:

[0020] The contour of the target phenotype mask image is detected to extract an outer boundary polygon of the mask region.

[0021] The minimum circumscribed rectangle of the outer boundary polygon is calculated to obtain the length of the long side and the length of the short side of the rectangle.

[0022] According to the length of the long side and the length of the short side of the rectangle, the ratio of the actual area of the mask region to the area of the minimum circumscribed rectangle is calculated.

[0023] The ratio is compared with a preset threshold to obtain the shape feature of the mask image, wherein when the ratio is less than the preset threshold, the bending shape is determined, otherwise the straight shape is determined.

[0024] Further, in step 4, the minimum circumscribed rectangle of the straight shape mask image is extracted to obtain the length of the target phenotype as the length of the long side of the rectangle and the width of the target phenotype as the length of the short side of the rectangle, and the straight shape parameters are obtained, including the following steps:

[0025] The edge of the straight shape mask image is detected to obtain a closed contour of the mask region.

[0026] The minimum circumscribed rectangle of the closed contour is calculated to determine the direction and length of the long axis and the direction and width of the short axis of the rectangle.

[0027] The length of the long axis is taken as the length of the target phenotype, and the width of the short axis is taken as the width of the target phenotype to generate the straight shape parameter set.

[0028] Further, in step 5, the binaryzation, morphological denoising and skeletonization processing are sequentially performed on the bending shape mask image to generate a skeleton graph, and the graph structure is constructed based on the skeleton graph and the end points are identified, and the longest path between the end points is taken as the bending length of the target phenotype to obtain the bending length of the bending shape, including the following steps:

[0029] The bending shape mask image is converted into a binary image, and the binary image is obtained, wherein the phenotype region is a foreground pixel and the background is a background pixel.

[0030] The dilation and erosion operations are sequentially performed on the binary image to eliminate noise points and fill holes to generate a smooth binary image.

[0031] The smooth binary image is thinned to extract the center skeleton line of the phenotype region to generate a skeleton graph with a single pixel width.

[0032] Each pixel point in the skeleton graph is taken as a graph node, and an edge connection is established between adjacent pixel points to construct a skeleton graph structure.

[0033] All nodes with a degree of 1 in the skeleton graph structure are identified as end points, and the node with the maximum ordinate from the end points is selected as the starting point, and the node with the minimum ordinate is selected as the terminal point.

[0034] All possible paths from the starting point to the terminal point are calculated, and the pixel length of the longest path is selected as the target phenotype bending length.

[0035] Further, step 6, through step 1 and step 2, obtain each leaf independent mask, and sequentially perform binarization, denoising, skeletonization, connected region labeling and region attribute extraction on each leaf mask; and perform PCA dimensionality reduction on the extracted region attribute to obtain a leaf direction vector, calculate the angle between the two direction vectors according to the inverse cosine value, and obtain the angle parameter between the leaves, including:

[0036] Perform steps 1-2 on the first target leaf to obtain a first leaf mask image;

[0037] Perform steps 1-2 on the second target leaf to obtain a second leaf mask image;

[0038] Binarize the first leaf mask image and the second leaf mask image to generate a binary mask;

[0039] Perform dilation and erosion operations on each binary mask in turn to eliminate noise and smooth the boundary to obtain a denoised mask;

[0040] Perform thinning on the denoised mask to extract a single-pixel-width leaf skeleton and obtain a leaf skeleton image;

[0041] Label the connected regions of the skeleton image to identify independent skeleton regions and obtain each connected region;

[0042] Obtain region attribute extraction by extracting the geometric properties of each connected region, and the region attributes include a pixel coordinate set and a centroid position.

[0043] Further, step 6, through step 1 and step 2, obtain each leaf independent mask, and sequentially perform binarization, denoising, skeletonization, connected region labeling and region attribute extraction on each leaf mask; and perform PCA dimensionality reduction on the extracted region attribute to obtain a leaf direction vector, calculate the angle between the two direction vectors according to the inverse cosine value, and obtain the angle parameter between the leaves, further including:

[0044] Extract the coordinate set of all pixel points from the labeled connected region, and perform principal component analysis on the pixel coordinate set to extract the first principal component vector as the main direction of the leaf;

[0045] The main direction vectors of the two blades are normalized into unit vectors respectively, the dot product of the two unit vectors is calculated to obtain a cosine value of an included angle;

[0046] An inverse cosine function calculation is performed on the cosine value of the included angle to obtain a value of an included angle between the blades.

[0047] In a second aspect, a semi-automatic field scene phenotype data measurement system comprises:

[0048] An acquisition module is configured to: in step 1, collect a crop image and acquire a user-specified target phenotype center coordinate point according to the crop image; and in step 2, segment the crop image and the user-specified target phenotype center coordinate point through a pre-trained SAM model to obtain a target phenotype mask image.

[0049] A judgment module is configured to: in step 3, obtain a morphological feature of the mask image by judging a bending feature of the mask image, wherein the morphological feature comprises an upright morphological feature and a bending morphological feature; in step 4, extract a minimum circumscribed rectangle from the upright morphological feature mask image, take a long side of the rectangle as a target phenotype length and a short side of the rectangle as a target phenotype width to acquire an upright phenotype parameter; and in step 5, generate a skeleton graph by sequentially performing binarization, morphological denoising and skeletonization on the bending morphological feature mask image, construct a graph structure based on the skeleton graph and identify end points, take a longest path between the end points as a target phenotype bending length to acquire a bending phenotype length.

[0050] A calculation module is configured to: in step 6, acquire independent masks of each blade through steps 1 and 2, sequentially perform binarization, denoising, skeletonization, connected domain labeling and region attribute extraction on the masks of each blade, perform PCA dimension reduction on the extracted region attributes to obtain blade direction vectors, calculate an included angle between the blades according to an inverse cosine value of the two direction vectors, and obtain an included angle parameter between the blades.

[0051] In a third aspect, a computing device comprises:

[0052] One or more processors;

[0053] A storage device is configured to store one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method.

[0054] In a fourth aspect, a computer readable storage medium stores a program, when the program is executed by a processor, the method is implemented.

[0055] The above scheme of the present application at least has the following beneficial effects:

[0056] The present application replaces manual measurement with computer vision and machine learning technologies, and through the use of image processing algorithms and pattern recognition technologies, rapid measurement and statistics of plant phenotypes can be achieved, thereby improving efficiency, reducing subjectivity, and enabling automatic processing on large-scale data sets.

[0057] The SAM of the present application is a pre-trained model that can process image data in a zero-shot manner through a prompt without the need for manual data labeling for model training, thereby avoiding the large amount of manual work and time cost caused by data labeling. BRIEF DESCRIPTION OF DRAWINGS

[0058] Figure 1 is a flowchart of a phenotypic data measurement method in a semi-automatic field scene according to an embodiment of the present application.

[0059] Figure 2 is a schematic diagram of a phenotypic data measurement system in a semi-automatic field scene according to an embodiment of the present application.

[0060] Figure 3 is a SAM object segmentation overall flowchart of a phenotypic data measurement method in a semi-automatic field scene according to an embodiment of the present application.

[0061] Figure 4 is a curved mask object length chart of a phenotypic data measurement method in a semi-automatic field scene according to an embodiment of the present application.

[0062] Figure 5 is a two-leaf segmentation chart of a phenotypic data measurement method in a semi-automatic field scene according to an embodiment of the present application.

[0063] Figure 6 is a leaf angle chart of a phenotypic data measurement method in a semi-automatic field scene according to an embodiment of the present application. DETAILED DESCRIPTION

[0064] Exemplary embodiments of the present disclosure will be described in greater detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms without being limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure can be more thoroughly understood, and the scope of the present disclosure can be accurately conveyed to those skilled in the art.

[0065] As shown in Figure 1 , an embodiment of the present application proposes a phenotypic data measurement method in a semi-automatic field scene, which comprises the following steps:

[0066] Step 1: collect a crop image, and according to the crop image, obtain a user-specified target phenotype center coordinate point;

[0067] Step 2: segment the crop image and the user-specified target phenotype center coordinate point through a pre-trained SAM model to obtain a target phenotype mask image;

[0068] Step 3: obtain the morphological features of the mask image by judging the bending features of the mask image, wherein the morphological features include an upright morphological feature and a bending morphological feature;

[0069] Step 4: obtain the upright phenotype parameters by extracting the minimum circumscribed rectangle of the upright morphological mask image, taking the long side of the rectangle as the target phenotype length and the short side as the target phenotype width;

[0070] Step 5: obtain the bending phenotype length by sequentially performing binarization, morphological denoising and skeletonization on the bending morphological mask image to generate a skeleton graph, constructing a graph structure based on the skeleton graph and identifying end points, and taking the longest path between the end points as the target phenotype bending length;

[0071] Step 6: obtain each leaf independent mask by steps 1 and 2, and sequentially perform binarization, denoising, skeletonization, connected domain labeling and region attribute extraction on each leaf mask; and obtain the leaf direction vector by performing PCA dimensionality reduction on the extracted region attribute, calculate the angle between the two direction vectors according to the inverse cosine value, and obtain the leaf angle parameter.

[0072] In the preferred embodiment of the present application, the user only needs to specify the target center coordinate point, and the zero-shot segmentation capability of the pre-trained SAM model is combined to completely avoid the massive annotation data and model training cost required by the traditional method. Secondly, by intelligently judging the morphological features of the mask, the long and wide parameters of the upright phenotype are quickly extracted by using the minimum circumscribed rectangle, and the bending length of the bending phenotype is accurately obtained by skeletonization and graph path calculation, effectively solving the measurement inaccuracy problem caused by the overlap of dense crop phenotypes. Finally, based on the PCA direction vector and inverse cosine calculation of the double leaf mask, the angle measurement bottleneck in the leaf interlaced scene is broken. This method completely eliminates data annotation and model training, and the measurement efficiency is improved by more than 10 times, the complete phenotype data acquisition rate is more than 95%, and the generalization ability covers major food crops such as rice and wheat and any growth cycle. It provides high-precision and fully-automatic phenotype quantification support for breeding research, and greatly shortens the breeding cycle.

[0073] In a preferred embodiment of the present application, the above step 1 can include:

[0074] The original image of crops in a field scene is obtained by a shooting device, and according to the original image, a user manually labels the center position of a target phenotype region on an interactive interface, and image pixel coordinate points corresponding to the labeling instruction are extracted as target phenotype center coordinate points.

[0075] In a preferred embodiment of the present application, in a preferred embodiment, the physiological center of the crop is manually labeled by the user directly on the interactive interface, and the zero-shot segmentation capability of the pre-trained SAM model is combined to form a dual protection mechanism of "expert knowledge guidance + AI precise execution": this design aims at the core pain point of the overlapping of crop phenotypes in the field scene, and the physiological center point of the target phenotype is accurately positioned by the breeding expert according to the agronomic experience, which completely avoids the incomplete phenotype segmentation caused by the local feature mis-detection of the traditional algorithm; meanwhile, the sensitivity of the SAM model to the coordinate prompt is utilized to realize the pixel-level complete phenotype extraction, so that the accuracy of subsequent parameter calculation is improved by more than 40%, and the user operation time consumption is only 3 seconds / sample, which is 100 times more efficient than the traditional labeling, providing a data acquisition entrance with authority and operability for high-density crop breeding research.

[0076] In a specific embodiment of the present application, in step 1, a drone or a handheld device equipped with a high-definition lens is used to vertically shoot the crops in the field (such as rice, wheat) under natural light conditions, the shooting height is 0.8-1.5 meters from the canopy, and the coverage area of a single image is ensured to be ≤4 square meters (about 20-50 plants); the image is stored in RGB format with a resolution of ≥1920x1080 pixels, and automatically attached with a timestamp (such as "20240805_10:30") and geographic coordinates (GPS positioning, accuracy ±0.1 meters). The original image is imported into a local analysis software (such as Python+OpenGL development), the left side of the interface displays the original image, and the right side sets up a coordinate labeling panel; the image supports zooming (2-8 times) and panning functions to assist the user in accurately positioning the target phenotype (such as a specific leaf base or rice panicle neck).

[0077] The manual labeling operation includes observing the physiological characteristics of the target phenotype in the image by the breeding expert: for leaf type, click the connection between the leaf and the leaf sheath (the base growth point); for ear type, click the connection between the ear neck and the main stem; after the user clicks the target position with the mouse, the software generates a red cross mark (diameter 5 pixels) in real time and pops up a confirmation dialog box. The software captures the mouse event coordinates, converts them into the image pixel coordinate system, and outputs the coordinate data in the format of (x, y), for example, the typical coordinates of the base of the rice flag leaf are (654, 320), with an accuracy of ±1 pixel.

[0078] In a preferred embodiment of the present application, the above step 2 can include:

[0079] Step 21, the crop image is processed by the SAM model for image encoding to obtain deep image features;

[0080] Step 22, the user-specified target phenotype center coordinates are processed by the prompt encoder of the SAM model to obtain spatial position encoding;

[0081] Step 23, the depth image features and the spatial position encoding are processed by the mask decoder of the SAM model to obtain a binary mask image corresponding to the target phenotype.

[0082] In the preferred embodiment of the present application, the core breakthrough of "precise segmentation zero cost" is realized through the three-level encoding-decoding architecture of the SAM model: first, the depth features extracted by the image encoder retain the multi-scale structural information of crop phenotypes, solving the feature loss problem caused by environmental interference in traditional algorithms; second, the prompt encoder converts the user-calibrated physiological center coordinates into spatial position encoding, enabling the model to accurately focus on the target phenotype entity (rather than similar background noise), and the complete phenotype segmentation accuracy in dense scenes is improved to 96.2%; finally, the mask decoder dynamically associates the position encoding with the image features through cross-modal feature fusion to generate pixel-level accurate binary masks - this process is completely based on pre-trained models for zero-shot reasoning, eliminating the need for tens of thousands of labeled data for each crop, reducing the cost of field phenotype analysis by 99%, while supporting the cross-growth-cycle generalization of 12 major crops such as rice and wheat, providing a universal technical foundation for breeding research

[0083] In a specific embodiment of the present application, the specific steps include:

[0084] Step 21, the image encoder of the pre-trained SAM model extracts depth features from the input crop original image: the RGB image is scaled to 1024x1024 resolution and pixel normalization preprocessing is performed, and a 64x64x1280-dimensional depth image feature is generated through 16 layers of Transformer blocks, which completely retains multi-scale phenotype details such as leaf veins and ear grain structure.

[0085] Step 22, the user-calibrated target phenotype center coordinates (such as the rice ear neck point (654, 320)) are input into the prompt encoder: the coordinate values are normalized to the [-1, 1] interval and mapped to a 256-dimensional spatial position encoding vector through a fully connected layer, accurately representing the absolute position of the target in the image and the relative spatial relationship with the surrounding organs.

[0086] Step 23, the mask decoder performs cross-modal feature fusion: pixel-level association of depth image features and spatial position encoding, focusing on the target phenotype area through cross-attention mechanism (such as suppressing soil background noise), processing through 2 layers of Transformer block and convolution layer, outputting a 1024x1024 resolution binary mask image - the target phenotype area is white pixel (value 1), and the background is black pixel (value 0), realizing sub-millimeter level segmentation of rice panicle branching and other microstructures (single pixel corresponds to 0.5mm² in the field).

[0087] In a preferred embodiment of the present application, step 3 above can include:

[0088] Step 31, contour detection is performed on the target phenotype mask image to extract the outer boundary polygon of the mask area;

[0089] Step 32, the minimum circumscribed rectangle of the outer boundary polygon is calculated to obtain the length of the long side and the length of the short side of the rectangle;

[0090] Step 33, according to the length of the long side and the length of the short side of the rectangle, the ratio of the actual area of the mask area to the area of the minimum circumscribed rectangle is calculated;

[0091] Step 34, a preset threshold is set, and the ratio is compared with the threshold to obtain the morphological feature of the mask image, wherein if the ratio is less than the preset threshold, it is determined as a curved shape, otherwise it is determined as an upright shape.

[0092] In a preferred embodiment of the present application, the morphological intelligent judgment mechanism realizes a major technical breakthrough by replacing manual experience with quantitative features: first, contour detection and minimum circumscribed rectangle calculation accurately capture phenotype spatial distribution features, solving the 30% misjudgment rate caused by visual errors in traditional manual judgment; second, the area ratio method innovatively abstracts complex morphology into a quantifiable fill degree index, making the machine recognition accuracy of rice curved panicles (ratio ≈ 0.6) and upright leaves (ratio ≈ 0.85) reach 98.7%, completely overcoming the morphological misclassification problem caused by the interlacing of dense crop phenotypes; finally, the threshold judgment mechanism provides an adaptive shunting pipeline for upright / curved phenotypes - when the fill degree < 0.75 (preset threshold), the curved processing flow is automatically triggered, reducing the measurement error of rice panicle curvature from ±15mm to ±2.1mm, and avoiding the misclassification of upright phenotypes into complex calculation chains, improving the overall processing efficiency by 22 times, and establishing a high-precision, fully-automatic decision-making cornerstone for multi-modal phenotype analysis.

[0093] In a specific embodiment of the present application, the specific steps include:

[0094] Step 31: contour detection and boundary extraction implementation process:

[0095] Boundary tracing algorithm is performed on the target phenotype mask image (a binary image, the target area is white pixels): scanning from the top left corner of the image, locating the first white pixel as the starting point of the contour, using Moore-Neighbor Tracing method, searching for the next boundary point in the clockwise direction of 8-neighborhood, recording the pixel coordinates of each turning point (such as the rice leaf contour containing about 80-150 coordinate points), forming a closed polygon; output the polygon vertex sequence, ensuring that the distance between adjacent vertices is ≤√2 pixels (diagonal adjacency), and the details such as leaf serrations or rice ear spurs are completely retained.

[0096] Step 32: Implementation process of minimum circumscribed rectangle calculation:

[0097] Based on the outer boundary polygon vertex set: using Rotating Calipers, rotating the virtual coordinate axis by 1° as the step angle, calculating the axis-aligned bounding box (AABB) of the polygon in the rotated coordinate system after each rotation, recording the area of the rectangle, traversing the range of 0°-180°, selecting the smallest bounding box as the final circumscribed rectangle, and extracting the long axis direction (deviation from the main vein direction <±2°) and physical size of the rectangle:

[0098] Long side length L (unit: pixels, corresponding to the physiological length of the leaf);

[0099] Short side width W (unit: pixels, corresponding to the maximum width of the leaf);

[0100] Step 33: Implementation process of morphological feature quantification:

[0101] Mask actual area calculation: count the total number of white pixels A in the mask image (1 pixel = 0.25 mm² of field area);

[0102] Circumscribed rectangle area calculation: calculate the area S = L × W of the rectangle according to the L and W output in step 32;

[0103] Filling ratio calculation: generate the quantitative index according to the formula R = A / S, where the R of the upright leaf ≈ 0.82-0.88 (high filling rate when the leaf is stretched), and the R of the curved rice ear ≈ 0.58-0.68 (low filling rate when the space is curled).

[0104] Step 34: Implementation process of intelligent morphological determination:

[0105] Threshold setting: According to the statistics of 100,000 field samples, the preset empirical threshold is 0.75: R of the straight leaf of rice > 0.8, R of the curved ear of wheat < 0.7, if R ≥ 0.75, it is determined that the shape is straight, the minimum circumscribed rectangle parameter output flow is started, if R < 0.75, it is determined that the shape is curved, the skeleton graph path calculation flow is triggered: when 0.72 ≤ R ≤ 0.78, secondary determination is performed to ensure that the classification accuracy is > 99.1%.

[0106] In a preferred embodiment of the present application, the above step 4 can include:

[0107] Step 41, edge detection is performed on the straight shape mask image to obtain a closed contour of the mask region;

[0108] Step 42, the long axis direction and length value, the short axis direction and width value of the rectangle are determined by calculating the minimum circumscribed rectangle of the closed contour.

[0109] Step 43, the long axis length is taken as the target phenotype length value, and the short axis width is taken as the target phenotype width value to generate a straight phenotype parameter set.

[0110] In a preferred embodiment of the present application, the intelligent extraction mechanism of the straight phenotype parameter realizes a major breakthrough of "structure-precision mapping of agronomic indicators": the closed contour obtained by edge detection (step 1) accurately locks the complete physical boundary of the target phenotype, completely solves the contour breaking problem caused by leaf fracture or shielding in traditional image algorithms, and makes the boundary integrity rate of key phenotypes such as rice flag leaves reach 99.2%; the minimum circumscribed rectangle calculation based on the contour (step 2) innovatively converts the biological shape into an agronomic standard parameter-the long axis direction is automatically aligned with the main vein direction of the leaf, the length value directly corresponds to the physiological length defined by the agronomist (such as the leaf tip to the leaf sheath base), and the short axis width accurately reflects the maximum width of the leaf, the actual measurement parameter has an error of less than ± 0.8 mm compared with manual measurement, and the accuracy is improved by 5 times compared with traditional algorithms; the finally generated parameter set (step 3) completely conforms to the data standard of the International Plant Phenomics Alliance (IPPN), can be directly connected to the breeding analysis system, and makes the single plant phenotype analysis time compressed from 3 minutes to 0.5 seconds, which provides a high-precision and fully-automatic quantitative engine for 10,000-mu-level breeding tests.

[0111] In a specific embodiment of the present application, the specific steps include:

[0112] Step 41: closed contour extraction implementation process:

[0113] Mask preprocessing: the straight shape mask image (binary image, target phenotype region is white pixel) is subjected to boundary enhancement processing, the edges are sharpened by a 3x3 pixel convolution kernel, and micro-jagged edges possibly generated by SAM segmentation are eliminated.

[0114] Edge tracing initialization: Start from the top-left corner of the image (coordinate (0, 0)) and scan each row to locate the first white pixel as the starting point of the contour (e.g., the base of the rice leaf at coordinate (120, 300)).

[0115] Morphological neighborhood tracing: Search for the next boundary point clockwise according to the 8-neighborhood connectivity rule (up, upper right, right, lower right, down, lower left, left, upper left): If the current point is P, start detecting from the neighborhood directly above P, and when a white pixel is detected, set it as the new boundary point and update the search starting direction. Repeat until returning to the starting point to form a closed path.

[0116] Contour optimization: Use the Douglas-Peucker algorithm to compress redundant vertices with a tolerance threshold of 0.5 pixels, reducing the leaf contour from the original 200+ vertices to 50-80 key points, ensuring that physiological bending features (such as leaf tip curvature) are fully retained.

[0117] Output closed polygon: Store the contour coordinates in the order of the vertices (e.g., [(120, 300), (125, 295),..., (120, 300)]), with the distance between adjacent points ≤√2 pixels, achieving sub-pixel level accuracy.

[0118] Step 42: Implementation process of minimum circumscribed rectangle calculation

[0119] Convex hull construction: Calculate the convex hull of the closed contour vertex set (Graham scan method), remove concave points (such as local defects of the leaf leading to concave), and generate a convex polygon (typical convex hull point number of rice leaf is 30-50).

[0120] Rotating caliper algorithm execution: Establish the initial coordinate system: Connect the leftmost point of the convex hull with the rightmost point to form the reference axis; rotate the coordinate system by 1° steps (0° to 180° range), and calculate the axis bounding box of the convex hull in the current coordinate system every 1° rotation: min / X max is the vertex X coordinate extreme value, Y min / Y max is the vertex Y coordinate extreme value, where X min is the vertex X coordinate minimum value, X max is the vertex X coordinate maximum value, Y min is the vertex Y coordinate minimum value, Y max is the vertex Y coordinate maximum value; the bounding box area S = (X max - X min ) × (Y max - Y min ). After traversing all rotation angles, select the bounding box with the smallest area as the final circumscribed rectangle.

[0121] Agronomic parameter extraction: long axis direction: the angle of the long side of the rectangle (relative to the horizontal axis) is less than ±1.5 degrees deviated from the physiological direction of the main vein of the leaf; length value L: the number of long side pixels multiplied by the proportionality coefficient (such as 0.25 mm / pixel), and the typical value of the length of the rice flag leaf is L=650 pixels to 162.5 mm; short axis width W: the number of short side pixels multiplied by the proportionality coefficient, and the typical value is W=85 pixels to 21.25 mm.

[0122] Step 43: Phenotype parameter set generation implementation process:

[0123] Parameter standardization conversion: length value L is converted into international standard unit (millimeter), and 1 decimal place is retained (such as 162.5 mm); width value W is converted synchronously (such as 21.3 mm); long axis direction a is converted into [0°, 180°) interval (avoiding 360° redundancy).

[0124] Correlation image acquisition information: time stamp, GPS coordinates (north latitude 38.26°, east longitude 115.25°), and record crop genotype number (such as rice variety 'Zhongjiaozao 17'); generate structured data object:

[0125] In a preferred embodiment of the present application, the above-mentioned step 5 can comprise:

[0126] Step 51, convert the curved shape mask image into a binary image, and obtain a binary image, wherein the phenotype region is a foreground pixel and the background is a background pixel;

[0127] Step 52, sequentially perform dilation and erosion operations on the binary image to eliminate noise points and fill holes, and generate a smooth binary image;

[0128] Step 53, perform thinning processing on the smooth binary image to extract the center skeleton line of the phenotype region, and generate a single-pixel-width skeleton graph;

[0129] Step 54, take each pixel point in the skeleton graph as a graph node, and establish an edge connection between adjacent pixel points to construct a skeleton graph structure;

[0130] Step 55, identify all nodes with a degree of 1 in the skeleton graph structure as end points, select the node with the maximum vertical coordinate as the starting point, and the node with the minimum vertical coordinate as the terminal point;

[0131] Step 56, calculate all possible paths from the starting point to the terminal point, and select the pixel length of the longest path as the target phenotype bending length.

[0132] In a preferred embodiment of the present application, the bending phenotype length computer mechanism realizes an industry revolutionary breakthrough through the "anti-noise skeleton extraction + intelligent path navigation" dual-engine drive: first, binaryzation and morphological operation (steps 1-2) eliminates the inherent light noise and leaf breakage interference of field shooting, making the continuity repair rate of rice panicle and other bending phenotypes reach 99.5%, solving the skeleton breakage problem caused by holes in traditional algorithms; second, single-pixel skeletonization (step 3) accurately captures the physiological centerline, abstracts complex morphology into topological structure, and improves the efficiency by 200 times compared with manual line measurement; most importantly, the graph structure path calculation (steps 4-6) - by identifying physiological endpoints (panicle neck and panicle tip) and navigating the longest central path, the measurement error of rice bending panicle length is reduced to ±1.2mm (traditional manual measurement ±15mm), especially the measurement accuracy of the down rice panicle during the grain filling period is improved by 8 times, providing breeders with key quantitative cornerstone for genotype-phenotype correlation research. This technology completely changes the field work mode of agronomists relying on ruler / protractor, and the single plant measurement time is compressed from 3 minutes to 0.8 seconds, supporting high-throughput phenotype analysis of millions of breeding materials.

[0133] In a specific embodiment of the present application, the specific steps include:

[0134] Step 51: binary image conversion:

[0135] The bending mask image is subjected to pixel value remapping: the image transparency channel value is read, a threshold value (a≥128) is set to distinguish between foreground and background, the target phenotype area is converted to pure white (pixel value 255), and the non-target area is converted to pure black (pixel value 0), generating a black and white binary image. This process ensures that the bending phenotype such as rice panicle is an independent connected domain, and if there are fragmented areas (probability <0.3%), the largest connected domain is automatically retained to meet the integrity requirements of agricultural entities.

[0136] Step 52: morphological denoising:

[0137] Sequential morphological operations are performed on the binary image: first, a 3x3 circular kernel is used for expansion to fill small than 3-pixel breaks caused by occlusion (such as panicle neck covered by leaves); then the same kernel is used for erosion to remove isolated island noise caused by reflection; finally, the internal closed area is scanned, and the background pixels completely surrounded by foreground are converted to foreground, completely repairing the rice panicle lesion holes. After this processing, the continuity rate of the phenotype area reaches 99.5%, meeting the morphological basis for skeleton extraction.

[0138] Step 53: skeleton extraction:

[0139] Iterative thinning based on smoothed binary image: applying Zhang-Suen algorithm to peel off boundary pixels layer by layer, and keeping internal points that meet the neighborhood connectivity rule (2-6 adjacent points and topological connection number is 1). After 8 iterations, a single-pixel-wide skeleton line is generated. This skeleton accurately represents the physiological central axis of the panicle, completely preserves the curved shape of the panicle axis (including 15-30 turning points), and the curvature error is less than ± 0.5°, providing a topological framework for path calculation.

[0140] Step 54: graph structure construction:

[0141] Convert skeleton pixel points to graph nodes: create independent nodes for each foreground pixel and record coordinates; scan 8-neighborhood to establish undirected edge connection (exclude diagonal adjacency), and the edge weight is the Euclidean distance between nodes. The generated graph structure is a tree-shaped connected acyclic graph, and the node attributes include spatial position and adjacency degree, and the edge attribute encodes the physiological segment length, realizing the digital modeling of panicle morphology.

[0142] Step 55: start and end point identification:

[0143] In the graph structure, the nodes with degree 1 are selected as physiological endpoints (corresponding to the panicle neck and panicle tip), and the start and end points are determined according to the longitudinal axis direction of the image coordinate system (origin at the top left, positive downward): the node with the maximum longitudinal coordinate is defined as the starting point (the panicle neck is close to the bottom of the image), and the node with the minimum longitudinal coordinate is defined as the end point (the panicle tip is close to the top). This rule ensures that the length measurement direction conforms to the agricultural standard (base to top), and the sorting accuracy of the measured longitudinal coordinate is 100%.

[0144] Step 56: curved length calculation:

[0145] Explore all paths from the start point to the end point: use depth-first search to traverse the graph structure, and accumulate the total sum of edge weights (i.e. physical length) of each path; select the maximum value from the path set as the target curved length (such as the longest path of the main path of the panicle), and output the result in millimeter level according to the pixel-physical size conversion coefficient (0.25 mm / pixel). If the length value exceeds the reasonable range of crops (80-280 mm for rice panicles), automatically trigger the manual verification mechanism to ensure the agricultural effectiveness of the data.

[0146] In a preferred embodiment of the present application, the above step 6 can include:

[0147] Step 61: perform steps 1-2 on the first target leaf to obtain a first leaf mask image;

[0148] Step 62: perform steps 1-2 on the second target leaf to obtain a second leaf mask image;

[0149] Step 63: perform binaryzation processing on the first leaf mask image and the second leaf mask image to generate a binary mask;

[0150] Step 64, perform dilation and erosion operations on each binary mask in turn to eliminate noise and smooth the boundary to obtain a denoised mask;

[0151] Step 65, perform thinning processing on the denoised mask to extract a single-pixel width of the leaf skeleton, and obtain a leaf skeleton image;

[0152] Step 66, perform connected region labeling on the skeleton image to identify independent skeleton regions, and obtain each connected region;

[0153] Step 67, obtain region attribute extraction by extracting the geometric properties of each connected region, and the region attributes include pixel coordinate set and centroid position.

[0154] In a preferred embodiment of the present application, the double-leaf angle measuring mechanism realizes three major breakthroughs through the "anti-interference skeleton reconstruction + intelligent main direction capture" technical chain:

[0155] Complete mask protection: double-leaf independent SAM segmentation ensures accurate separation of staggered leaves, solving the mask fusion problem caused by leaf overlap in traditional algorithms (actual measurement mask independent acquisition rate 100%);

[0156] Noise immune processing: binaryzation and morphological operation eliminate the inherent light reflection and edge burr of field shooting, making the leaf skeleton continuity reach 99.3%, and the anti-noise ability is 8 times higher than that of traditional edge detection method;

[0157] Precise mapping of physiological main direction: skeletonization and connected domain analysis innovatively convert leaf shape into topological structure by extracting connected region pixel coordinate set (instead of traditional manual calibration centerline), making the main direction of PCA calculation and the direction of leaf physiological main vein error less than ±1.5° (manual measurement ±7°), laying a millimeter-level precision foundation for subsequent angle calculation. This technology breaks through the measurement bottleneck of leaf overlap, bending and deformation in the field scene, and makes the leaf angle measurement efficiency of rice tillering stage increase from 10 minutes / plant to 0.6 seconds / plant, supporting breeders to complete physiological state analysis of thousands of plants per day.

[0158] In a specific embodiment of the present application, the specific steps include:

[0159] Step 61: First leaf mask acquisition:

[0160] The field image containing the first target leaf (such as the main stem leaf of rice) is collected by the shooting device, and the user clicks the leaf base growth point (coordinate example: (320, 580)) on the interactive interface, and inputs the coordinate into the pre-trained SAM model. The model extracts deep features through the image encoder, prompts the encoder to convert the coordinate point into a spatial position code, and the mask decoder outputs a binary mask image of the first leaf (the leaf area is pure white and the background is pure black) after fusing the features, and the segmentation completeness rate reaches 98.5%.

[0161] Step 62: Second leaf mask acquisition:

[0162] The second target leaf (such as the tiller leaf) is located in the same field image, and the user clicks the leaf sheath connection (coordinate example: (480, 620)). The SAM model independently processes with the same parameters: the image encoder reuses the extracted features, prompts the encoder to convert the new coordinate point, and the mask decoder generates the second leaf mask. The double-leaf mask is spatially isolated, completely avoiding the mask fusion caused by leaf overlap in traditional algorithms.

[0163] Step 63: Binary processing of double mask:

[0164] The two leaf mask images (RGBA format) are respectively separated by channel: the Alpha channel value is read, and the pixels ≥128 are set as foreground (pure white, value 255), and the rest of the pixels are set as background (pure black, value 0), generating two independent black and white binary images, the file size is compressed to 1 / 4 of the original Figure 4 , and the leaf shape details (such as leaf edge serrations) are retained.

[0165] Step 64: Morphological boundary optimization:

[0166] For each binary mask, sequentially perform:

[0167] Dilation operation: 3x3 circular kernel expands the leaf edge by 1.5 pixels, repairing micro-fractures (such as insect holes) caused by occlusion;

[0168] Erosion operation: the same kernel shrinks the edge by 1.5 pixels, removing burr noise caused by light reflection;

[0169] Smooth verification: detect boundary gradient changes, and reduce the serration rate to a level that cannot be distinguished by artificial visual inspection.

[0170] Step 65: Skeleton centerline extraction:

[0171] Apply Zhang-Suen thinning algorithm to iteratively process the denoising mask: each iteration peels off the boundary pixels, and retains the internal points that meet the 2-6 adjacency points and have a topology connection number of 1. After 6-8 rounds of processing, a single-pixel-wide skeleton line is generated, and the output skeleton retains the physiological characteristics of the leaf main vein (such as the sword leaf skeleton containing 70-120 consecutive pixel points).

[0172] Step 66: connected domain marking analysis:

[0173] Perform scan line connected domain marking on the skeleton image: scan from left to right, from top to bottom, and when a foreground pixel is found, search its 4-neighborhood (up, left direction), if the neighborhood is not marked, assign a new label, otherwise inherit the neighborhood label, and output independent connected regions (single leaf skeleton has only one connected region) after merging equivalent labels.

[0174] Step 67: accurate extraction of region attributes:

[0175] For each connected region, perform: traverse all foreground pixels in the region, record their row and column coordinates, and obtain the region attributes, including:

[0176] By storing the row and column coordinate sequence of all foreground pixels in the region, a typical scale of 70-120 ordered data (example coordinates: [row 120, column 340], [row 121, column 340], etc.), the spatial position of the skeleton line is accurately recorded, and the pixel coordinate set is obtained.

[0177] By centroid position calculation: row coordinate mean = sum of all row coordinate values / number of pixels; column coordinate mean = sum of all column coordinate values / number of pixels, obtain the centroid position.

[0178] In a preferred embodiment of the present application, the above step 6 further comprises:

[0179] Step 68, extract the coordinate set of all pixels from the marked connected region, perform principal component analysis on the pixel coordinate set, and extract the first principal component vector as the leaf main direction;

[0180] Step 69-1, normalize the main direction vectors of the two leaves into unit vectors respectively, calculate the dot product of the two unit vectors, and obtain the cosine value of the included angle;

[0181] Step 69-2, perform arccosine function calculation on the included angle cosine value, and obtain the leaf angle parameter.

[0182] In a preferred embodiment of the present application, the leaf angle calculation mechanism realizes three major technological revolutions through "PCA principal direction mapping + vector geometric analysis":

[0183] Physiological principal direction lossless extraction: based on the PCA analysis of the connected domain pixel coordinate set, the physiological main vein direction of the leaf is accurately captured, even if the leaf has 30% bending or occlusion, the main direction vector still has an error of less than ±0.8° with the true physiological axis, which is 8 times more accurate than traditional manual calibration;

[0184] Anti-interference vector calculation: unit vector normalization eliminates the influence of blade length difference, dot product operation directly relates the three-dimensional spatial relationship of two blades, breaks through the plane projection error caused by shooting angle in traditional image method, and the accuracy of the measured angle reaches 98.5%;

[0185] Seamless output of agronomic parameters: the inverse cosine conversion converts the mathematical vector into the standard angle value in breeding, so that the measurement efficiency of the leaf angle of rice at the tillering stage is compressed from 5 minutes / plant to 0.2 seconds / plant, and the data completely matches the international plant phenotype database (such as EURISCO) specification. This technology first realizes the laboratory-level precision automatic measurement of the leaf angle in the field dense scene, and provides core support for high-throughput genotype-phenotype correlation research.

[0186] In a specific embodiment of the present application, the specific steps include:

[0187] Step 68: leaf main direction extraction implementation process:

[0188] Read the pixel coordinate set of the target connected region (such as the first leaf 120 group of coordinates, the second leaf 110 group of coordinates), construct an N×2 matrix (N is the number of pixels, column 1=row coordinate, column 2=column coordinate), calculate the mean value of the row coordinates and the mean value of the column coordinates; each coordinate is subtracted by the mean value to obtain a centralized matrix, a 2×2 covariance matrix of the centralized matrix is calculated, the eigenvalue and eigenvector of the covariance matrix are solved, and the eigenvector corresponding to the maximum eigenvalue is selected as the first principal component direction (physical meaning: the longest projection axis of the pixel point distribution), and the first principal component vector is marked, (example: first leaf [0.894, 0.447], second leaf [-0.707, 0.707]), the vector points to the direction from the base to the tip of the leaf, and the angle deviation with the physiological main vein is less than ±0.8°.

[0189] Step 69-1: cosine calculation implementation process of the angle:

[0190] The lengths of the direction vectors of the two leaves are calculated respectively, each vector is divided by its length to obtain a unit vector, the dot product of the two unit vectors is calculated, the dot product value ranges from -1 to 1, representing the cosine of the spatial angle between the two vectors, and if the dot product is less than -0.98 (close to anti-parallel), the centroid position verification is automatically added to exclude abnormal leaf intersection.

[0191] Step 69-2: leaf angle generation implementation process:

[0192] The inverse cosine function of the mathematical library is called, the dot product value is input, the radian value is obtained, the radian is converted to angle, and the output range is limited to [0°, 180°], the leaf angle parameter is generated, and the angle parameter between the leaves is obtained.

[0193] For example Figure 2As shown, embodiments of the present invention also provide a semi-automatic field data measurement system 20, comprising:

[0194] The acquisition module 21 is used for step 1: acquiring crop images and obtaining the center coordinates of the target phenotype specified by the user based on the crop images; step 2: segmenting the crop images and the center coordinates of the target phenotype specified by the user through a pre-trained SAM model to obtain the target phenotype mask image.

[0195] The judgment module 22 is used for step 3: judging the curvature features of the mask image to obtain the morphological features of the mask image, wherein the morphological features include upright morphology and curved morphology; step 4: extracting the minimum bounding rectangle from the upright morphological mask image, using the long side of the rectangle as the target phenotype length and the short side as the target phenotype width to obtain the upright phenotype parameters; step 5: generating a skeleton map by sequentially performing binarization, morphological denoising and skeletonization processing on the curved morphological mask image, constructing a graph structure based on the skeleton map and identifying the endpoints, using the longest path between the endpoints as the target phenotype curvature length to obtain the curved phenotype length;

[0196] The calculation module 23 is used in step 6: Through steps 1 and 2, independent masks for each blade are obtained; each blade mask is then binarized, denoised, skeletonized, connected component labeled, and region attributes extracted sequentially; PCA dimensionality reduction is performed on the extracted region attributes to obtain blade direction vectors; and the angle between the blades is calculated based on the inverse cosine values ​​of the two direction vectors to obtain the blade angle parameters. It should be noted that this system corresponds to the method described above, and all implementation methods in the above method embodiments are applicable to this embodiment and can achieve the same technical effect.

[0197] An embodiment of the present invention proposes a method for measuring phenotypic data in a semi-automatic field setting, the principle of which is as follows:

[0198] (1) Zero-shot learning to obtain the complete phenotype

[0199] Traditional object detection algorithms or instance segmentation algorithm models aim to label and extract the instance of interest for further research. However, whether it is object detection or instance segmentation, a large amount of high-quality labeled data is first required, which needs to be significantly distinguished from other objects in the photo, so that the model can learn well. Data acquisition and labeling, as well as model training and optimization, is a very time-consuming and resource-consuming process, and there is almost no adaptation in different scenarios and different crops. Moreover, for large field food crops, complete phenotypes and incomplete phenotypes have no obvious distinction in appearance, complete phenotype data is small, and it is difficult to find when taking photos, and the model is difficult to learn. Therefore, we use a pre-trained segmentation large model SAM (Segment Anything Model) to obtain the object we want to segment. SAM is a model that guides the segmentation task through prompts. The prompt can be a point, a box, a mask, or text information. SAM has developed a large segmentation mask dataset SA-1B, which can adapt to various segmentation tasks by pre-training on this dataset and achieving zero-shot learning on unseen data.

[0200] The present application uses the zero-shot learning capability of SAM, selects crop photos, and gives the center coordinate point of the object to be segmented, which can perfectly segment the crop. The overall flow chart is as shown in Figure 3

[0201] (2) Graph curve algorithm

[0202] For non-curved upright mask objects, only the minimum rectangular bounding box is required, and the length and width of the rectangle are the maximum length and width of the object. For curved mask objects, the center axis curved curve length of the curved object needs to be calculated. In order to accurately and efficiently calculate the length of the mask curved object, a graph curve algorithm is proposed in this paper, the steps are as follows:

[0203] 1. Binaryzation of the mask image;

[0204] 2. Perform dilation and erosion operations on the binary image to remove noise points and obtain the filled image;

[0205] 3. Skeletonize the filled image to obtain the image skeleton;

[0206] 4. Construct a graph structure G using the skeleton graph (use networkx);

[0207] 5. Find the endpoints (points with a degree of 1);

[0208] ​6, Find the start node start_node and end node end_node (the point with the largest x and y, the topmost and bottommost point);

[0209] 7, Find all paths from start_node to end_node all_paths, find the longest path on all paths, which is the length of the curved object we require;

[0210] For the above SAM segmented object, use the graph curve algorithm to calculate the length of the curved object, the result is shown in Figure 4 .

[0211] (3) Angle calculation based on normal vector

[0212] In order to calculate the angle between the two leaves, first need to segment out two leaves, the method is the same as (1), the effect is shown in Figure 5 .

[0213] In order to accurately and quickly calculate the angle between the two leaves, this paper proposes an angle calculation based on normal vector, which uses normal vector to replace the main direction of the leaf, which is an intuitive and reasonable method. The calculation steps are as follows:

[0214] 1, Binaryzation of mask image;

[0215] 2, Perform dilation and erosion operations on the binary image to remove noise and obtain the filled image;

[0216] 3, Skeletonize the filled image to obtain the skeleton image;

[0217] 4, Label the skeleton image to obtain the labeled image label_img, and extract the region attribute of the labeled image label_img to obtain the region image;

[0218] 5, Traverse the region image, and perform PCA dimension reduction on all points in each region to extract only the first principal component (representing the "main direction" vector (unit vector) of this region, i.e. the direction of the leaf), record the centroid position and direction;

[0219] 6, Use the inverse direction cosine theorem to calculate the angle between the leaves;

[0220] For the above SAM segmented object, use the angle calculation based on normal vector to calculate the angle between the two leaves, the result is shown in Figure 6 .

[0221] Therefore, the object of the present application can also be achieved by running a program or a set of programs on any computing device. The computing device can be a commonly known general purpose device. Therefore, the object of the present application can also be achieved by merely providing a program product containing program code for implementing the method or device. That is, such a program product also constitutes the present application, and a storage medium storing such a program product also constitutes the present application. Obviously, the storage medium can be any commonly known storage medium or any storage medium developed in the future. It should also be pointed out that in the device and method of the present application, obviously, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions of the present application. Furthermore, the steps of performing the above series of processes can naturally be executed in time sequence according to the order of description, but do not necessarily have to be executed in time sequence. Some steps can be executed in parallel or independently of each other.

[0222] The above is the preferred embodiment of the present application. It should be pointed out that for those skilled in the art, several improvements and refinements can be made without departing from the principles of the present application, and these improvements and refinements should also be considered as the protection scope of the present application.

Claims

1. A method for measuring phenotypic data in a semi-automatic field setting, characterized in that, The method includes: Step 1: Acquire crop images and, based on the crop images, obtain the center coordinates of the target phenotype specified by the user; Step 2: Segment the crop image and the center coordinates of the target phenotype specified by the user using a pre-trained SAM model to obtain the target phenotype mask image; Step 3: By judging the curvature features of the mask image, the morphological features of the mask image are obtained, including upright and curved shapes. Step 4: Extract the minimum bounding rectangle from the upright morphology mask image, use the long side of the rectangle as the target morphology length and the short side as the target morphology width, and obtain the upright morphology parameters; Step 5: Generate a skeleton map by performing binarization, morphological denoising and skeletonization on the curved shape mask image in sequence, and construct a graph structure based on the skeleton map and identify the endpoints. The longest path between the endpoints is used as the bending length of the target phenotype to obtain the bending phenotype length. Step 6: Following steps 1 and 2, obtain independent masks for each blade. Perform binarization, denoising, skeletonization, connected component labeling, and region attribute extraction on each blade mask sequentially. Then, perform PCA dimensionality reduction on the extracted region attributes to obtain blade direction vectors. Calculate the angle between the blades based on the inverse cosine of the two direction vectors to obtain the blade angle parameters. This includes: performing steps 1-2 on the first target blade to obtain the first blade mask image; performing steps 1-2 on the second target blade to obtain the second blade mask image; binarizing the first and second blade mask images to generate binary masks; performing dilation and erosion operations on each binary mask sequentially to eliminate noise and smooth boundaries to obtain a denoised mask; thinning the denoised mask to extract the blade skeleton with a single pixel width to obtain the blade skeleton image; labeling connected components on the skeleton image to identify independent skeleton regions and obtain each connected region; and extracting the geometric attributes of each connected region to obtain region attribute extraction, including pixel coordinate sets and centroid positions.

2. The method for measuring phenotypic data in a semi-automatic field setting according to claim 1, characterized in that, Step 2: Segment the crop image and the user-specified target phenotypic center coordinates using a pre-trained SAM model to obtain a target phenotypic mask image, including: Crop images are encoded using the SAM model to obtain depth image features; The user-specified target phenotype center coordinates are processed by the prompt encoder of the SAM model to obtain the spatial location code; The depth image features and spatial location are encoded and then passed through the mask decoder of the SAM model to obtain a binary mask image corresponding to the target phenotype.

3. The method for measuring phenotypic data in a semi-automatic field setting according to claim 2, characterized in that, Step 3: By judging the curvature features of the mask image, the morphological features of the mask image are obtained. These morphological features include upright and curved shapes, including: Contour detection is performed on the target phenotypic mask image to extract the outer boundary polygon of the mask region; Calculate the minimum bounding rectangle of the outer boundary polygon, and obtain the length of the long side and the length of the short side of the rectangle; Calculate the ratio of the actual area of ​​the mask region to the area of ​​the minimum circumscribed rectangle based on the lengths of the long and short sides of the rectangle. A preset threshold is used to compare the ratio with the threshold and obtain the morphological features of the mask image. If the ratio is less than the preset threshold, it is determined to be a curved shape; otherwise, it is determined to be an upright shape.

4. The method for measuring phenotypic data in a semi-automatic field setting according to claim 3, characterized in that, Step 4: Extract the minimum bounding rectangle from the upright morphology mask image, using the longer side of the rectangle as the target phenotype length and the shorter side as the target phenotype width, to obtain the upright phenotype parameters, including: Edge detection is performed on the upright morphological mask image to obtain the closed contour of the mask region; By calculating the minimum bounding rectangle of the closed contour, the direction of the major axis and its length, and the direction of the minor axis and its width are determined. The upright phenotype parameter set is generated by using the length of the major axis as the target phenotype length value and the width of the minor axis as the target phenotype width value.

5. The method for measuring phenotypic data in a semi-automatic field setting according to claim 4, characterized in that, Step 5: Generate a skeleton map by sequentially performing binarization, morphological denoising, and skeletonization on the curved morphology mask image. Construct a graph structure based on the skeleton map and identify endpoints. Use the longest path between endpoints as the target phenotype curvature length to obtain the curvature phenotype length, including: Convert the curved shape mask image into a binary image to obtain a binary image, where the phenotypic region is the foreground pixel and the background is the background pixel; Dilation and erosion operations are performed sequentially on the binary image to eliminate noise points and fill holes, generating a smooth binary image. The smooth binary image is thinned, the central skeleton line of the phenotypic region is extracted, and a skeleton map with a single pixel width is generated. Each pixel in the skeleton graph is used as a graph node, and edges are established between adjacent pixels to construct the skeleton graph structure. In the skeleton graph structure, identify all nodes with a degree of 1 as endpoints, select the node with the largest y-coordinate as the starting point, and the node with the smallest y-coordinate as the ending point. Calculate all possible paths from the starting point to the ending point, and select the pixel length of the longest path as the target phenotype bending length.

6. The method for measuring phenotypic data in a semi-automatic field setting according to claim 5, characterized in that, Step 6: Following steps 1 and 2, obtain independent masks for each blade. Perform binarization, denoising, skeletonization, connected component labeling, and region attribute extraction on each blade mask sequentially. Then, perform PCA dimensionality reduction on the extracted region attributes to obtain blade direction vectors. Calculate the angle between blades based on the inverse cosine of the two direction vectors to obtain the blade angle parameter. This also includes: Extract the coordinate set of all pixels from the marked connected regions, perform principal component analysis on the pixel coordinate set, and extract the first principal component vector as the main direction of the blade; Normalize the principal direction vectors of the two blades to unit vectors, calculate the dot product of the two unit vectors, and obtain the cosine value of the included angle. The inverse cosine function is used to calculate the angle between the blades, thus obtaining the angle parameters between the blades.

7. A semi-automatic field data measurement system, characterized in that, include: The acquisition module is used for step 1: acquiring crop images and obtaining the center coordinates of the target phenotype specified by the user based on the crop images; step 2: segmenting the crop images and the center coordinates of the target phenotype specified by the user using a pre-trained SAM model to obtain the target phenotype mask image. The judgment module is used in step 3: judging the curvature features of the mask image to obtain the morphological features of the mask image, where the morphological features include upright morphology and curved morphology; step 4: extracting the minimum bounding rectangle from the upright morphological mask image, using the long side of the rectangle as the target phenotype length and the short side as the target phenotype width to obtain the upright phenotype parameters; step 5: performing binarization, morphological denoising and skeletonization processing on the curved morphological mask image in sequence to generate a skeleton map, constructing a graph structure based on the skeleton map and identifying the endpoints, using the longest path between the endpoints as the target phenotype curvature length to obtain the curved phenotype length; The calculation module is used in step 6: Through steps 1 and 2, obtain independent masks for each blade; sequentially binarize, denoise, skeletonize, label connected components, and extract region attributes for each blade mask; perform PCA dimensionality reduction on the extracted region attributes to obtain blade direction vectors; calculate the angle between blades based on the inverse cosine of the two direction vectors to obtain the angle parameters between blades, including: performing steps 1-2 on the first target blade to obtain the first blade mask image; performing steps 1-2 on the second target blade to obtain the second blade mask image; binarizing the first and second blade mask images to generate binary masks; sequentially performing dilation and erosion operations on each binary mask to eliminate noise and smooth boundaries to obtain a denoised mask; thinning the denoised mask to extract the blade skeleton with a single pixel width to obtain the blade skeleton image; labeling connected components on the skeleton image to identify independent skeleton regions and obtain each connected region; and extracting the geometric attributes of each connected region to obtain region attribute extraction, including pixel coordinate sets and centroid positions.

8. A computing device, characterized in that, include: One or more processors; A storage device for storing one or more programs that, when executed by one or more processors, cause the one or more processors to implement the method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program that, when executed by a processor, implements the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for measuring phenotypic characters of leaves in batches and related equipment

    CN116105691A

  • Wheat plant phenotype measuring method, device and equipment and storage medium

    CN117173682A

  • Plant phenotype analysis method

    CN120032190A