Image recognition-based screening method and system for gramineous forage grass seeds
By constructing a central axis topology map and an energy distribution map, and combining path orthogonality to identify the contact points of grass seeds, the problem of accurate segmentation of grass seeds adhering to each other was solved, and efficient instance segmentation and subsequent classification were achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-20
- Publication Date
- 2026-04-14
AI Technical Summary
Existing image instance segmentation methods struggle to accurately define the complete outline of grass seeds, leading to frequent missegmentation and affecting the accuracy of subsequent identification and classification.
Construct a central axis topology map and an energy distribution map of the seed adhesion region, identify conflict nodes representing the intersection of multiple seed skeletons in the central axis topology map, and find the minimum energy path connecting the region boundary to the conflict node in the energy distribution map. Select reliable primary contact points by the orthogonality of the path direction and the skeleton direction, simulate the inward evolution process of the contour to determine the final contact point and generate the dividing line.
It significantly improves the accuracy of locating the adhesion area of grass seeds, avoids misjudgment, ensures that the dividing line is generated at the actual contact point between seeds, maintains the morphological characteristics of individual seeds, and prevents over- or under-segmentation.
Smart Images

Figure CN121544969B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision image segmentation technology, and more specifically, to a method and system for screening grass seeds based on image recognition. Background Technology
[0002] Image recognition-based seed selection is a crucial technology for precision agriculture. For gramineous forage seeds, automatic sorting using computer vision technology can effectively improve seed purity and quality. This method first requires separating each individual seed region from the acquired seed image using image segmentation techniques before subsequent feature extraction and classification can be performed. Existing image instance segmentation methods provide the foundation for automating this process.
[0003] However, due to the slender, irregular shape and awn-like structure of grass seeds, they often appear densely clustered or even partially overlapping in images during automated sieving processes. This close contact blurs the boundaries between seeds in two-dimensional images, making it difficult for existing general image instance segmentation methods to accurately define the complete outline of each seed. This easily leads to erroneous segmentation results, such as misclassifying a single seed as multiple seeds or vice versa, directly affecting the accuracy of subsequent identification and classification. Summary of the Invention
[0004] In order to overcome the above-mentioned defects of the prior art, the present invention provides a method and system for screening grass seeds based on image recognition to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] Image recognition-based methods for screening grass seeds include:
[0007] S1. Obtain images of grass seeds to be screened and identify seed adhesion areas, wherein the seed adhesion areas contain at least two grass seeds in contact with each other.
[0008] S2. Construct the central axis topology map of the seed adhesion region, and simultaneously construct the energy distribution map based on image gradient within the seed adhesion region;
[0009] S3. Identify the conflict nodes in the central axis topology graph that represent the intersection of multiple seed skeletons, and find the minimum energy path from the boundary of the connecting region to the conflict node in the energy distribution graph.
[0010] S4. Select the minimum energy path from the minimum energy paths of each conflict node whose path direction is orthogonal to the direction of the central axis branch at the conflict node, and use its endpoint as the primary contact point.
[0011] S5. Using the primary contact point as a guide, simulate the inward evolution of the contour of the seed adhesion region, and determine the critical point where the contour topology splits during the inward evolution process. The critical point is then identified as the final contact point.
[0012] S6. Generate a dividing line based on the final contact point to separate the individual grass seeds in the seed adhesion area, thus completing the instance segmentation.
[0013] Further, images of the grass seeds to be screened are acquired and seed adhesion regions are identified, wherein the seed adhesion regions contain at least two grass seeds in contact with each other, including:
[0014] Acquire images of grass seeds and convert them to grayscale images;
[0015] The grayscale image is preprocessed to enhance the contrast between the seed region and the background;
[0016] Based on the preprocessed image, the overall mask of all seed regions is extracted using a semantic segmentation model.
[0017] Perform morphological opening operations on the overall mask to separate weakly connected non-seed regions;
[0018] Identify candidate contiguous regions composed of multiple pixel connected regions from the overall mask;
[0019] Candidate adhesion regions with an area greater than the preset area threshold for a single seed are selected as the final seed adhesion regions.
[0020] Furthermore, a central topological map of the seed adhesion region is constructed, and an energy distribution map based on image gradients within the seed adhesion region is simultaneously constructed, including:
[0021] Calculate the distance transformation map based on the binary mask of the seed adhesion region;
[0022] Local maxima detection is performed on the distance-transformed graph to extract the central axis point;
[0023] Connect the central axis points to form an initial skeleton and trim the initial skeleton to remove short branches caused by edge noise, thereby obtaining the central axis topology map;
[0024] Simultaneously, the gradient magnitude is calculated based on the original grayscale image corresponding to the seed adhesion region;
[0025] The gradient magnitude is nonlinearly inverted and normalized so that weak edges correspond to high energy values and strong edges correspond to low energy values, thus generating an energy distribution map.
[0026] Furthermore, conflict nodes representing the intersection of multiple seed skeletons are identified in the central axis topology graph, and the minimum energy path connecting the region boundary to the conflict node is found in the energy distribution graph, including:
[0027] Identify all skeleton branch points in the central axis topology graph. A skeleton branch point is a node that connects three or more skeleton branches.
[0028] Use the skeleton branch points as candidate conflict nodes;
[0029] Calculate the skeleton orientation complexity within a preset neighborhood around each candidate conflict node;
[0030] Candidate conflict nodes whose skeleton orientation complexity exceeds a preset threshold are identified as valid conflict nodes.
[0031] In the energy distribution map, the pixel boundaries of the seed adhesion region are used as the path starting point set, and the effective conflict nodes are used as the path ending point.
[0032] Based on the energy value of each pixel in the energy distribution map, the shortest path search algorithm is used to calculate the minimum cumulative energy path from each point in the path starting point set to each effective conflict node.
[0033] Furthermore, calculating the skeleton orientation complexity within a preset neighborhood around each candidate conflict node includes: extracting all skeleton pixels within a preset neighborhood radius centered on the candidate conflict node; calculating the dominant orientation of the skeleton pixels using principal component analysis; statistically analyzing the dispersion of the skeleton orientation relative to the dominant orientation within the neighborhood, quantifying the dispersion by calculating the standard deviation of the orientation vector, and defining the quantified value as the skeleton orientation complexity.
[0034] Furthermore, from the minimum energy paths of each conflict node, the minimum energy path whose path direction is orthogonal to the central axis branch direction at the conflict node is selected, and its endpoint is used as the primary contact point, including:
[0035] For each valid conflict node, extract all minimum cumulative energy paths connecting to the corresponding valid conflict node;
[0036] Calculate the path direction vector of each minimum cumulative energy path terminating at a valid conflict node;
[0037] Extract the direction vectors of all central axis branches connected at valid conflict nodes;
[0038] Calculate the cosine of the angle between each path direction vector and the direction vector of each central branch;
[0039] The path with the minimum cumulative energy is selected from the path direction vectors whose absolute value of the cosine of the angle with any central axis branch direction vector is less than a preset orthogonality threshold.
[0040] The endpoints of the selected minimum cumulative energy paths located at effective conflict nodes are marked as primary contact points.
[0041] Furthermore, calculating the path direction vector of each minimum cumulative energy path terminating at the effective conflict node includes: extracting the last path segment of the minimum cumulative energy path closest to the effective conflict node; performing linear regression fitting on the pixel coordinates of the last path segment to obtain a straight line; calculating the direction vector of the straight line, and defining this direction vector as the path direction vector of the minimum cumulative energy path terminating at the effective conflict node.
[0042] Furthermore, guided by the primary contact point, the inward evolution of the contour of the seed adhesion region is simulated, and the critical point where the contour topology splits during the inward evolution is determined. This critical point is then identified as the final contact point, including:
[0043] The overall mask of the seed adhesion area is used as the initial outline;
[0044] In each iteration of contour inward evolution, a morphological erosion operation is applied to the current contour: a structuring element of a preset size and shape is used; the origin of the structuring element is aligned with each foreground pixel of the current contour; the center pixel is retained as a foreground pixel in the eroded image only when all pixels covered by the structuring element belong to the foreground; this operation causes the current contour to shrink inward by one pixel width along its normal direction, completing one evolution iteration.
[0045] After each erosion operation, check whether the number of pixel connected components in the current contour has increased;
[0046] When the number of connected pixel regions is first detected to increase, the current iteration step is determined to be the critical point where the contour topology splits.
[0047] The bottom position of the contour depression corresponding to the critical point, which is guided by the primary contact point, is determined as the final contact point.
[0048] Furthermore, dividing lines are generated based on the final contact points to separate individual grass seeds within the seed-adhesive region, completing instance segmentation, including:
[0049] Pair up multiple final contact points that belong to the same contour splitting event;
[0050] For each pair of final contact points, connect the two points on the overall mask of the seed adhesion area to generate a dividing line segment.
[0051] Overlay all generated segmentation lines onto the overall mask of the seed adhesion region;
[0052] Based on the overall mask after superimposing segmented line segments, the originally connected pixel region is divided into multiple independent pixel connected regions.
[0053] Each independent pixel connected region obtained from the segmentation is labeled as an independent grass seed region, thus completing the instance segmentation.
[0054] On the other hand, the present invention provides an image recognition-based seed screening system for grassy forage grasses, comprising:
[0055] The region recognition module is used to acquire images of grass seeds to be screened and identify seed adhesion regions, where the seed adhesion regions contain at least two grass seeds in contact with each other.
[0056] The region construction module is used to construct the central axis topology map of the seed adhesion region and simultaneously construct the energy distribution map based on image gradient within the seed adhesion region;
[0057] The region analysis module is used to identify conflict nodes in the central axis topology map that represent the intersection of multiple seed skeletons, and to find the minimum energy path connecting the region boundary to the conflict node in the energy distribution map.
[0058] The primary identification module is used to select the minimum energy path from the minimum energy paths of each conflict node whose path direction is orthogonal to the direction of the central axis branch at the conflict node, and use its endpoint as the primary contact point.
[0059] The final identification module is used to simulate the inward evolution of the contour of the seed adhesion region guided by the primary contact point, and to determine the critical point where the contour topology splits during the inward evolution of the contour, and to identify the critical point as the final contact point.
[0060] The instance segmentation module is used to generate a dividing line based on the final contact point to separate individual grass seeds in the seed adhesion area, thus completing instance segmentation.
[0061] Compared with the prior art, the present invention has the following beneficial effects:
[0062] 1. By constructing a collaborative analysis mechanism of central axis topology map and energy distribution map, the problem of adhesion and segmentation of gramineous forage seeds caused by their slender shape and blurred boundaries is effectively overcome. First, the central axis topology map is used to accurately locate the conflict nodes where multiple sub-skeletons intersect. Then, the minimum energy path from the boundary to the node is found by combining the energy distribution map. Reliable primary contact points are selected by the orthogonality of the path direction and the skeleton direction. The contact point recognition strategy based on the dual constraints of geometric topology and image energy can significantly improve the accuracy of seed contact area positioning and avoid misjudgment caused by traditional methods that rely on a single feature.
[0063] 2. By simulating the inward evolution of the contour and capturing the critical point of topological splitting, dynamic and precise positioning from primary contact to the final split point is achieved. Combining morphological evolution with monitoring of topological structure changes ensures that the split line is generated at the narrowest real contact area between seeds, thus preserving the morphological characteristics of individual seeds while separating adhered seeds. The segmentation strategy effectively prevents over-segmentation or under-segmentation, providing a reliable instance segmentation basis for subsequent seed morphology analysis and accurate classification. Attached Figure Description
[0064] Figure 1 This is a flowchart of the image recognition-based method for screening grass seeds according to the present invention;
[0065] Figure 2 This is a schematic diagram of the image recognition-based seed screening system for grasses according to the present invention. Detailed Implementation
[0066] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0067] Example 1: Figure 1 The present invention provides a method for screening grass seeds based on image recognition, comprising:
[0068] S1. Obtain images of grass seeds to be screened and identify seed adhesion areas, wherein the seed adhesion areas contain at least two grass seeds in contact with each other.
[0069] S2. Construct the central axis topology map of the seed adhesion region, and simultaneously construct the energy distribution map based on image gradient within the seed adhesion region;
[0070] S3. Identify the conflict nodes in the central axis topology graph that represent the intersection of multiple seed skeletons, and find the minimum energy path from the boundary of the connecting region to the conflict node in the energy distribution graph.
[0071] S4. Select the minimum energy path from the minimum energy paths of each conflict node whose path direction is orthogonal to the direction of the central axis branch at the conflict node, and use its endpoint as the primary contact point.
[0072] S5. Using the primary contact point as a guide, simulate the inward evolution of the contour of the seed adhesion region, and determine the critical point where the contour topology splits during the inward evolution process. The critical point is then identified as the final contact point.
[0073] S6. Generate a dividing line based on the final contact point to separate the individual grass seeds in the seed adhesion area, thus completing the instance segmentation.
[0074] To implement the image recognition-based method for screening gramineous forage seeds, the specific implementation of step S1—acquiring images of the gramineous forage seeds to be screened and identifying seed adhesion areas—is as follows:
[0075] First, an industrial color digital camera, positioned within a selected illumination box, photographs a sample of grass seeds placed vertically against a solid-color background to obtain raw images of the grass seeds. To ensure image quality, the illumination box provides a uniform and stable diffused light source to avoid high-intensity reflections or shadows on the seed surface. The acquired raw images are RGB color images, which are then converted to grayscale images. This conversion process employs a weighted average method, specifically assigning weights of 0.299, 0.587, and 0.114 to the red, green, and blue channel components of each pixel, respectively, and summing the results to calculate the grayscale value of that pixel, thus forming a grayscale image containing only brightness information. This weighting combination conforms to the human eye's perception of different color brightness characteristics, more accurately reflecting the light and dark details of the image.
[0076] Next, the converted grayscale image is preprocessed to enhance the contrast between the seed region and the background. The preprocessing primarily involves a contrast-limited adaptive histogram equalization method. This method first divides the image into multiple non-overlapping or partially overlapping blocks, for example, blocks of 8 pixels × 8 pixels. Within each block, its local histogram is calculated, and histogram equalization is performed to enhance the contrast of that region. To avoid over-enhancement due to noise amplification in uniform regions, a contrast-limiting threshold is set, for example, a threshold of 0.03. This threshold represents a cropping limit on the bin values in the histogram, and the cropped pixels are then evenly redistributed across the entire histogram. Finally, the processing results of all blocks are combined using bilinear interpolation to eliminate block artifacts, resulting in a preprocessed image that is globally natural and locally enhanced in contrast.
[0077] Then, based on the preprocessed image, a semantic segmentation model is used to extract the overall mask of all seed regions. The semantic segmentation model employs a U-Net network structure, which includes an encoder path and downsampling operations to capture contextual information, and a decoder path and upsampling operations to achieve precise localization. During training, the model uses a dataset consisting of a large number of precisely labeled images of grass seeds. By minimizing the cross-entropy loss function between the predicted segmentation map and the ground truth annotations, and optimizing the network weight parameters using backpropagation, the model learns to distinguish between seed pixels and background pixels. In the application phase, the preprocessed grayscale image is input into the trained semantic segmentation model. The model outputs a binary image of the same size as the input image, i.e., the overall mask. Pixels identified by the model as belonging to seed regions are assigned a foreground value of 255, while pixels identified as background are assigned a background value of 0.
[0078] Subsequently, a morphological opening operation is performed on the overall mask output by the semantic segmentation model to separate weakly connected non-seed regions. The morphological opening operation is a combination of erosion and dilation. The erosion operation uses a structuring element of a preset size and shape, such as a square structuring element with a side length of 5 pixels or a circular structuring element with a radius of 3 pixels. The erosion process involves iterating through every foreground pixel of the overall mask from the origin of the structuring element; the central pixel is retained as foreground in the eroded image only if all pixels covered by the structuring element are foreground pixels. Dilation is then performed using the same structuring element, iterating through the foreground pixels of the eroded image from the origin of the structuring element; if at least one pixel covered by the structuring element is foreground, the central pixel is set as foreground in the dilated image. The morphological opening operation effectively removes tiny noise points and breaks extremely fine connections consisting of only a few pixels, while roughly preserving the area and shape of the original seed region.
[0079] After obtaining the overall mask processed by morphological opening operations, candidate connected regions composed of multiple pixel connected components are identified from the mask. This process is implemented by applying a connected component labeling algorithm based on the 8-connectivity rule. This algorithm scans the entire mask image, and when it encounters an unvisited foreground pixel, it is used as a seed point for a new connected component. Then, it recursively or iteratively searches for all its 8-neighboring foreground pixels (top, bottom, left, right, and four diagonal directions) and labels these pixels as belonging to the same connected component. After completing the scanning and labeling of the entire image, each independent seed region or potential connected region is assigned a unique label, and the total number of pixels contained in the connected component corresponding to each label, i.e., its area, is calculated.
[0080] Finally, candidate adhered regions with an area greater than a preset area threshold for a single seed are selected as the final seed adhered regions. The preset area threshold for a single seed is set based on area statistics of a large number of known single, morphologically intact gramineous forage seed samples. Specifically, from a representative sample set, for example, 200 isolated single seeds are randomly selected, and the area of their corresponding connected components in the image is calculated. Then, the average and standard deviation of the connected component area values are calculated. The preset area threshold can be set as the average plus twice the standard deviation. For example, if the calculated average area is 1500 pixels and the standard deviation is 250 pixels, then the preset area threshold can be set as 1500 + 2 × 250 = 2000 pixels. This threshold is designed to cover the normal area variation range of most single seeds. Connected components with an area greater than this preset area threshold in all candidate adhered regions are ultimately determined as seed adhered regions. These regions, because their area significantly exceeds the area of a typical single seed, are judged to contain at least two gramineous forage seeds in contact, for subsequent fine segmentation.
[0081] The specific implementation method for constructing the central axis topology map of the seed adhesion region and simultaneously constructing the energy distribution map in step S2 is as follows:
[0082] The distance transformation map is calculated based on the binary mask of the seed adhesion region determined in step S1. In this binary mask, the pixel value of the seed region is 255, and the pixel value of the background is 0. The distance transformation is calculated with the foreground pixels as the reference, calculating the Euclidean distance from each background pixel in the mask to the nearest foreground pixel. In specific implementation, a two-pass scanning algorithm can be used. The first scan starts from the upper left corner of the image and proceeds to the lower right corner. The distance value of each background pixel is updated according to the distance values of its upper and left adjacent pixels, and the minimum value is added to the unit distance cost. The second scan starts from the lower right corner of the image and proceeds to the upper left corner. The distance value of each background pixel is updated according to the distance values of its lower and right adjacent pixels, and the minimum value is taken again. The final distance transformation map is a floating-point matrix with the same size as the binary mask. Each background pixel position stores the calculated distance value to the boundary of the nearest seed region, while the distance value of pixels inside the seed region is usually set to 0. This distance transformation map quantifies the relative position depth of each pixel in the adhesion region.
[0083] Local maxima detection (LoM) is performed on the calculated distance transformation map to extract the central axis point. LoM detection is performed within a neighborhood window of a preset size, such as a 3-pixel square window. For each pixel in the distance transformation map, its distance value is compared with the distance values of all other pixels within the window. If the pixel's distance value is greater than the distance values of all other pixels within the window, the pixel is identified as a local maximum point, i.e., a candidate central axis point. Local maxima points constitute the set of points within the seed region that maintain the maximum approximate equidistance from the boundary. To enhance robustness, a minimum distance threshold can be set, for example, the distance value must be greater than 2 pixels. Only local maxima points with distance values exceeding this threshold are retained to exclude spurious maxima points near the boundary caused by noise, ensuring that the extracted central axis point effectively reflects the macroscopic skeletal structure of the region.
[0084] The initial skeleton is formed by connecting the central axis points and then pruned to remove short branches caused by edge noise, thus obtaining the central axis topology. The connection process can employ a morphological thinning algorithm to iteratively erode a binary version of the distance transform map, for example, treating regions with distance values greater than 0 as foreground, until the skeleton width is a single pixel, while maintaining the connectivity of the regions. The resulting initial skeleton may contain many short branches caused by minor irregularities at the boundaries. The pruning process is achieved by analyzing the topology of the skeleton. First, all endpoints in the skeleton are identified, i.e., points with only one adjacent skeleton pixel; and branch points, i.e., points with three or more adjacent skeleton pixels. Then, the skeleton path length from each endpoint to its nearest branch point or another endpoint is calculated, in pixels. A branch length threshold is set, which can be based on prior knowledge, such as one-third of the estimated minimum length of a single seed; branches shorter than this threshold are considered spurious branches caused by noise. Short branches are then removed from the initial skeleton. The resulting concise skeleton network after pruning is the central axis topology, which more clearly reveals the main morphology of the seeds and possible contact relationships.
[0085] Simultaneously, the gradient magnitude is calculated based on the original grayscale image corresponding to the seed adhesion region. Here, the original grayscale image refers to the grayscale image obtained after preprocessing in step S1, but the calculation scope is limited to the image region corresponding to the currently processed seed adhesion region. The gradient magnitude calculation uses the Sobel operator. Convolution operations are performed with the grayscale image using horizontal and vertical Sobel convolution kernels respectively. For example, the template values of the horizontal convolution kernel are negative in the left column, zero in the middle column, and positive in the right column; the template values of the vertical convolution kernel are, for example, negative in the top row, zero in the middle row, and positive in the bottom row. After convolution, the gradient component Gx in the horizontal direction and the gradient component Gy in the vertical direction are obtained for each pixel. Then, the gradient intensity of each pixel is calculated according to the formula: gradient magnitude equals the square root of the sum of the squares of Gx and Gy. The gradient magnitude image highlights edge regions in the image where grayscale changes drastically.
[0086] The gradient magnitudes are non-linearly inverted and normalized, so that weak edges correspond to high energy values and strong edges correspond to low energy values, generating an energy distribution map. The purpose of non-linear inversion is to assign high energy values to low gradient regions and low energy values to high gradient regions. One implementation method is to use an inversion function, such as subtracting the actual gradient magnitude of each pixel from a preset maximum possible gradient magnitude estimate. Then, the inverted data is linearly normalized, scaling it to the interval between 0 and 1, so that the inverted minimum value maps to 0 and the maximum value maps to 1. The final matrix is the energy distribution map, in which the energy value represents the probability that a pixel is located on a weak edge between seeds; higher energy indicates that the point is more likely to be located on a visually blurred, low-contrast potential contact boundary. This energy distribution map will be used in conjunction with the central axis topology map for subsequent contact point analysis.
[0087] The specific implementation of step S3, which involves identifying conflict nodes representing the intersection of multiple seed skeletons in the central axis topology graph and finding the minimum energy path from the boundary of the connecting region to the conflict node in the energy distribution graph, is as follows:
[0088] In the central axis topology obtained in step S2, all skeleton branch points are identified. A skeleton branch point is defined as a node connecting three or more skeleton branches. The identification process is achieved by analyzing the eight-neighbor connectivity of each skeleton pixel in the central axis topology. Specifically, each skeleton pixel in the central axis topology is traversed, and the number of pixels belonging to the skeleton in its eight neighboring pixel positions is counted. These eight neighboring pixels include pixels in the top, bottom, left, right, and four diagonal directions. If the counted number of neighboring skeleton pixels is greater than or equal to three, the central skeleton pixel is identified as a skeleton branch point. Skeleton branch points are usually located in the area where multiple seed skeletons intersect, and are potential contact point locations.
[0089] All identified skeleton branch points are used as candidate conflict nodes. These candidate conflict nodes form the basis of the subsequent analysis. However, it should be recognized that they may contain some pseudo-branch points that do not truly represent seed intersections due to minor skeleton fluctuations or noise. Therefore, further screening is required to separate the pseudo-branch points from the true ones.
[0090] The complexity of the skeleton orientation within a predefined neighborhood around each candidate conflict node is calculated. First, all skeleton pixels within a predefined neighborhood radius are extracted, centered on the candidate conflict node. The radius of this neighborhood needs to balance two aspects: it must be large enough to cover representative skeleton structures around the conflict node, but not so large that it includes irrelevant skeleton parts, diluting the local orientation features. For example, the radius can be set to 5 pixels. Next, principal component analysis (PCA) is used to calculate the dominant orientation of the skeleton pixel set. Specifically, the x and y coordinates of all skeleton pixels in the neighborhood are used to construct a two-dimensional point set. The covariance matrix of this point set is calculated, and then the eigenvalues and eigenvectors of the covariance matrix are solved. The eigenvector direction corresponding to the largest eigenvalue is the dominant orientation, reflecting the main spatial extension trend of the local skeleton point set. Then, the dispersion of the skeleton orientation within the neighborhood relative to this dominant orientation needs to be statistically analyzed. A local orientation vector can be calculated for each skeleton pixel, for example, by calculating the vector difference between the point and its nearest neighbor. The degree of dispersion can be quantified by calculating the standard deviation of the sine of the angle between all local direction vectors and the obtained dominant direction vector. The larger the sine of the angle, the greater the deviation between the local direction and the dominant direction. This calculated standard deviation is ultimately defined as the skeleton orientation complexity at the candidate conflict node. Higher skeleton orientation complexity indicates greater inconsistency in the skeleton orientations around the point, making it more likely to represent a true intersection point of multiple different orientation seeds.
[0091] Candidate conflict nodes with skeleton directional complexity exceeding a preset threshold are classified as valid conflict nodes. The preset threshold is determined based on the analysis and statistics of a large number of typical adhesion samples. For example, the mean and standard deviation of the skeleton directional complexity of all detected candidate conflict nodes can be calculated from a training or validation set containing various adhesion scenarios. The preset threshold is then set to the mean plus one standard deviation. This threshold setting effectively filters out nodes with directional complexity significantly higher than the average level; these nodes exhibit more pronounced directional disorder characteristics and are therefore considered more reliable valid conflict nodes. Valid conflict nodes are considered key locations where multiple seed skeletons truly intersect, serving as targets for subsequent path search and analysis.
[0092] In the energy distribution map corresponding to the seed adhesion region generated in step S2, the pixel boundaries of the seed adhesion region are used as the path starting point set. The pixel boundaries of the seed adhesion region can be obtained by performing edge detection on the binary mask of the seed adhesion region finally determined in step S1, for example, by using a boundary tracking algorithm to obtain the coordinate set of all outer boundary pixels. The boundary points constitute the starting point set of the path search. At the same time, each valid conflict node identified in the previous step is used as the target endpoint of the path search.
[0093] Based on the energy values of each pixel in the energy distribution map, a shortest path search algorithm is used to calculate the minimum cumulative energy path from each point in the path origin set to each valid conflict node. The shortest path search algorithm used here is Dijkstra's algorithm. This algorithm treats the energy distribution map as a graph structure, where each pixel is a node, and the connections between nodes are typically eight-neighbor connections, meaning each pixel node is connected to its eight neighboring pixel nodes. The weight or cost of each edge in the graph needs to be defined, and can usually be set as the average energy value of the two pixel nodes connected by the edge. The search process is as follows: for each valid conflict node, the algorithm starts from all origin pixels in the path origin set and systematically explores all possible paths to that valid conflict node. The algorithm maintains a list recording the current minimum cumulative cost from the origin to each node and updates this list iteratively. Finally, the algorithm selects the path with the minimum cumulative cost as the minimum cumulative energy path connecting the origin to this valid conflict node. This path represents the channel with the minimum energy cost from the boundary to the conflict node on the energy distribution map, usually corresponding to the potential segmentation path with the weakest visual contrast and the smoothest grayscale change between seeds.
[0094] The specific implementation method for selecting the minimum energy path from the minimum energy paths of each conflict node whose path direction is orthogonal to the direction of the central axis branch at the conflict node, and using the path endpoint as the primary contact point, is as follows:
[0095] For each valid conflict node identified in step S3, it is first necessary to extract all minimum cumulative energy paths connected to that specific valid conflict node. These paths are calculated in step S3 using Dijkstra's algorithm; they originate from the pixel boundaries of the seed-adhesive region and terminate uniquely at the valid conflict node. A valid conflict node may be connected to multiple such minimum cumulative energy paths, each representing a channel with the minimum energy accumulation cost from the region boundary to the conflict node. The extraction process involves categorizing the path calculation results stored in step S3 according to their endpoints, grouping all paths ending at the current valid conflict node together.
[0096] Next, it is necessary to calculate the path direction vector of each minimum cumulative energy path terminating at the effective conflict node. Specifically, this is done by extracting the last path segment of the minimum cumulative energy path closest to the effective conflict node. The length of this last path segment needs to be reasonably set to capture the local orientation of the path near the endpoint, avoiding interference from possible bends in the path that could affect the endpoint orientation. For example, the line segment consisting of the last five consecutive pixels on the path can be extracted as the last path segment. After selecting the point set, linear regression is performed on the planar coordinates of the pixels. The purpose of linear regression is to find a straight line that minimizes the sum of the squares of the perpendicular distances from this line to all selected points. This best-fit line mathematically reflects the main distribution direction of the points in space. Then, the direction vector of this line is calculated. The direction vector can be obtained by taking the difference between the coordinates of two representative points on the line, for example, taking the two intersections of the line and the perpendicular line passing through the center of the point set. This calculated vector is then normalized to obtain the unit direction vector. Finally, this unit direction vector is defined as the path direction vector of the minimum cumulative energy path terminating at the effective conflict node. This vector represents the precise direction of the path from the outer region to the last segment of the conflict node.
[0097] Simultaneously, the direction vectors of all central axis branches connected to the valid conflict node are extracted. A central axis branch refers to a skeleton line segment extending outward from the valid conflict node in the central axis topology graph. For each central axis branch directly connected to the node, a small segment of skeleton pixels extending from the node to the branch needs to be extracted, for example, the first 5 pixels on the branch. Similarly, linear regression is performed on the coordinates of the pixels to obtain a best-fit line, and the unit direction vector of this line is calculated. This direction vector is the local extension direction of the central axis branch at the conflict node. A valid conflict node typically connects to multiple central axis branches, each branch representing a possible seed body extension direction; therefore, multiple central axis branch direction vectors are obtained for a single valid conflict node.
[0098] Next, it is necessary to quantitatively evaluate the directional relationship between each path direction vector and each central branch direction vector. This is achieved by calculating the cosine of the angle between each pair of vectors. The cosine of the angle between two vectors is equal to the dot product of the two vectors divided by the product of their magnitudes. Since the vectors have been normalized to unit vectors with a magnitude of 1, the dot product result is the cosine of the angle. The absolute value of the cosine directly reflects the similarity between the directions of the two vectors. When the two vectors are in the same direction, the cosine is 1. When the two vectors are in opposite directions, the cosine is -1. When the two vectors are perpendicular (or orthogonal), the cosine is 0. Therefore, the closer the absolute value of the cosine is to 0, the closer the path direction is to the orthogonal relationship with the central branch direction.
[0099] Subsequently, a selection process is performed based on the calculated cosine of the included angle. The goal of this selection is to find the minimum energy paths whose paths are approximately orthogonal to any of the central axis branch directions. The criterion for determining approximate orthogonality is to set a preset orthogonality threshold. This threshold is a positive number close to 0, and its setting needs to balance strictness and robustness. Too close to 0 might prevent any paths from being selected due to noise, while too large a threshold might misclassify non-orthogonal paths as orthogonal. For example, the preset orthogonality threshold can be set to 0.2. This means that for a given path's direction vector, if there exists any central axis branch direction vector such that the absolute value of the cosine of the included angle between them is less than 0.2, then the path's direction is considered approximately orthogonal to that central axis branch direction. All minimum cumulative energy paths corresponding to path direction vectors that satisfy this condition will be selected. Geometrically, these paths point almost perpendicularly from the boundary to the side of the seed skeleton, which aligns with the geometric characteristic that the seed contact boundary is usually perpendicular to the seed's long axis.
[0100] Finally, the endpoint of the minimum cumulative energy path satisfying the orthogonality condition, located at an effective conflict node, is marked as the primary contact point. Primary contact points have a clear physical meaning. They are located in the intersection region of multiple seed skeletons and arrive at the intersection point from the outer boundary of the seed along the channel with the weakest image grayscale change, approximately perpendicular to the seed principal axis. Therefore, the point is highly likely to be located on the true contact line between seeds. Each marked primary contact point is precisely associated with a specific effective conflict node and a specific minimum cumulative energy path. Primary contact points provide crucial spatial guidance and starting positions for simulating contour evolution and accurately locating the final segmentation point in subsequent step S5. All marked primary contact points together constitute a preliminary estimate of the potential segmentation points in the seed adhesion region.
[0101] The specific implementation method for step S5, which involves simulating the inward evolution of the seed adhesion region's contour guided by the primary contact point and determining the final contact point, is as follows:
[0102] The simulated evolution process uses the overall mask of the seed adhesion region finally determined in step S1 as the initial contour. This overall mask is a binary image, where the pixel value belonging to the seed region is 255, representing the foreground, and the pixel value of the background region is 0. This initial contour defines the initial outer boundary of the seed adhesion region, and its shape encompasses all the contacting seeds. At the beginning of each contour inward evolution iteration, a current contour image is generated, representing the boundary state of the seed region at that iteration step.
[0103] In each iteration of the contour inward evolution, a morphological erosion operation needs to be applied to the current contour image. The core of the erosion operation is to use a structuring element of a preset size and shape. The structuring element is a template that defines the shape and size of the local neighborhood, used to probe and modify the image shape. Typically, a small and symmetrical structuring element is chosen, such as a 3-pixel by 3-pixel square structuring element, with its origin defined at the position of its center pixel. This size is chosen based on a trade-off between seed boundary smoothness and computational efficiency; an excessively large structuring element will cause boundary details to be lost too quickly, while an excessively small one may make the iteration process too slow. The specific execution process of the erosion operation is to align the origin of the structuring element sequentially with every foreground pixel in the current contour image. For each alignment position, the system checks whether all pixel positions covered by the structuring element are marked as foreground pixels in the current contour image. This is a strict logical AND judgment. Only when all pixels within the coverage area of the structuring element are foreground pixels is the center pixel of the currently aligned position retained as a foreground pixel in the new image generated after this erosion operation. Conversely, if even one pixel within the structuring element's coverage area is not in the foreground, the center pixel will be set as a background pixel in the new image. Through this pixel-by-pixel logical judgment, the overall effect of the erosion operation is to uniformly shrink the boundary of the foreground region inward by approximately one pixel, equivalent to the entire contour evolving inward one step along its approximate normal direction. Each time such a complete erosion operation is performed on the current contour image, it signifies the completion of one inward evolution iteration of the contour.
[0104] After each erosion operation, it is essential to immediately check whether the number of connected components in the newly generated contour image has changed compared to the contour image before the iteration. This is achieved by applying a connected component labeling algorithm to comprehensively analyze the eroded binary image. This algorithm systematically scans the entire image, labeling interconnected foreground pixels as the same connected component based on pixel connectivity. The connectivity rule typically uses the 8-connectivity rule, meaning a pixel is considered connected to its upper, lower, left, right, and four diagonal neighbors. The algorithm counts the total number of independent connected components in the image. In the early stages of the simulated evolution, the interconnected seed regions are typically still morphologically a single connected component. As the contour shrinks inward through successive erosion operations, the contour gradually becomes narrower in the contact depressions between the seeds indicated by the primary contact points determined in step S4.
[0105] A key detection event during the evolution process is the increase in the number of connected components. After each iteration, the system compares the current number of connected components with the number after the previous iteration. When an increase in the number of connected components is detected compared to the previous iteration—for example, from one connected component to two—this specific iteration step is determined as a critical point where the contour topology splits. The discovery of this critical point has significant physical implications; it indicates that the current erosion operation has broken the contour at the weakest and narrowest point of connection between seeds, thus dividing a previously connected region into two or more parts. This reflects the location of the actual seed contact boundary.
[0106] Finally, the bottom position of the contour depression corresponding to the critical point, guided by the primary contact point, needs to be determined as the final contact point. Specifically, the system needs to backtrack to the contour image before the erosion operation corresponding to the iteration that was determined to be the critical point, that is, the contour state that is about to split but has not yet split. On this contour, find the contour depression region pointed to by the primary contact point determined in step S4. Typically, the contour will be concave inward near the primary contact point. The final contact point is located at the deepest part of this depression, that is, the position where the contour curvature is the maximum or the depression is the deepest. This can be determined by calculating the direction of the line connecting the point on the contour line to the primary contact point and finding the innermost point of the contour in that direction. The final contact point accurately identifies the deepest part of the slit where the seeds actually contact, providing crucial, geometrically evolution-based positioning information for the final generation of accurate dividing lines in step S6. Each final contact point is associated with a specific primary contact point and a contour splitting event.
[0107] The specific implementation method for generating a dividing line based on the final contact point to separate the individual grass seeds in the seed adhesion area and complete the instance segmentation in step S6 is as follows:
[0108] First, multiple final contact points generated by the same contour splitting event need to be properly paired. During the contour evolution process in step S5, when the critical point of contour topology splitting is identified, two or more final contact points are usually generated simultaneously. These final contact points collectively mark the precise break location of the adhesion contact area between seeds. The pairing process requires established rules to ensure accuracy. The system records each contour splitting event and all the final contact points it generates. For the point set generated by a single splitting event, the primary principle of pairing is based on spatial proximity. Specifically, the Euclidean distance between every two points in the point set is calculated. In the typical case of two seeds adhering together, a split will generate two final contact points, which naturally form a pair. In more complex cases where multiple seeds intersect, a split may generate three or more points, requiring a nearest neighbor pairing strategy. For example, the mutual distance of all point pairs can be calculated, and the two points with the shortest distance can be paired first. Then, the shortest point pairs can be found again among the remaining points for pairing, until all points are paired. This pairing method ensures that each segment connects to the two spatially closest points at the break, conforming to the geometric characteristics of the contact area.
[0109] Then, for each pair of successfully paired final contact points, a segmenting line segment is generated by connecting the two points on the overall mask of the seed adhesion region obtained in step S1. The connection process requires a precise digital image drawing algorithm to ensure the line segment is continuous and accurate. The Bressenham line algorithm is a commonly used implementation method. This algorithm efficiently determines the pixel positions to be activated for connecting the start and end points using integer operations by calculating the pixel path between the two points, generating a continuous straight line with a pixel width. Geometrically, this segmenting line segment represents the optimal segmentation path determined based on the contour evolution critical point; it spans the narrow contact region between the seeds and connects the two final contact points.
[0110] Next, all the segmentation lines generated for different contact areas need to be superimposed onto the overall mask of the original seed adhesion area. The superposition operation is a logical update process of image pixel values. In practice, a blank image of the same size as the original overall mask can be created as a segmentation line layer. All generated segmentation lines are drawn on this layer, with the segment pixel values set to a specific marker value, such as 128. Then, this segmentation line layer is merged with the original overall mask image. In the merged image, the original foreground seed area retains a pixel value of 255, the background retains 0, and the pixels at the segmentation line positions are marked as 128. The advantage of this method is that it clearly preserves the visual information of the segmentation lines and facilitates subsequent processing. Another direct approach is to directly set the segmentation line pixels to a background value of 0 on the original mask, which is equivalent to "etching" the boundary lines in the foreground area.
[0111] Next, based on the overall mask after overlaying the segmentation lines, the previously connected pixel regions are divided into multiple independent connected regions. This step requires applying the connected component labeling algorithm again, but with adaptive adjustments to the algorithm's rules. The algorithm scans the entire fused image. When a special label value of 128 is used to represent the segmentation line, the algorithm treats pixels with a value of 128 as impassable boundaries when labeling connected regions, thus preventing the crossing of connected regions. When the segmentation line is set to a background value of 0, these pixels naturally become gullies in the foreground region, also serving an isolation function. The algorithm identifies all independent connected regions separated by segmentation lines or the background, consisting of pixel values of 255. Each such region corresponds to a seed separated from a clumped region.
[0112] Finally, each independent pixel connected component is labeled as an independent grass seed region, completing instance segmentation. The system assigns a unique integer label to each detected independent connected component, for example, sequentially numbered starting from 1. This segmentation result image with a unique label is the final instance segmentation image. In this image, each seed that was originally stuck together is now accurately divided into an independent, uniquely identified region. This result image can be directly output for subsequent automated processing, such as accurate seed counting, morphological parameter measurement of each seed (e.g., area, major axis, minor axis calculation), and further quality analysis, ultimately achieving efficient and accurate screening of grass seeds. The entire process achieves the transition from overall identification of stuck seed clumps to precise segmentation of individual seed instances.
[0113] Example 2: Figure 2 A schematic diagram of the image recognition-based gramineous forage seed screening system of the present invention is provided. The image recognition-based gramineous forage seed screening system includes:
[0114] The region recognition module is used to acquire images of grass seeds to be screened and identify seed adhesion regions, where the seed adhesion regions contain at least two grass seeds in contact with each other.
[0115] The region construction module is used to construct the central axis topology map of the seed adhesion region and simultaneously construct the energy distribution map based on image gradient within the seed adhesion region;
[0116] The region analysis module is used to identify conflict nodes in the central axis topology map that represent the intersection of multiple seed skeletons, and to find the minimum energy path connecting the region boundary to the conflict node in the energy distribution map.
[0117] The primary identification module is used to select the minimum energy path from the minimum energy paths of each conflict node whose path direction is orthogonal to the direction of the central axis branch at the conflict node, and use its endpoint as the primary contact point.
[0118] The final identification module is used to simulate the inward evolution of the contour of the seed adhesion region guided by the primary contact point, and to determine the critical point where the contour topology splits during the inward evolution of the contour, and to identify the critical point as the final contact point.
[0119] The instance segmentation module is used to generate a dividing line based on the final contact point to separate individual grass seeds in the seed adhesion area, thus completing instance segmentation.
[0120] All calculations involved in the embodiments are dimensionless numerical calculations, and the preset parameters and thresholds in the calculations are set by those skilled in the art according to the actual situation.
[0121] It should be noted that this invention can be deployed on the device itself to realize embedded applications, or it can run on a PC or other terminal with a user interface, thereby meeting various hardware environments and usage requirements.
[0122] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wireless or wired transmission; wired transmission methods include optical fiber, twisted pair, coaxial cable, etc.; wireless transmission includes infrared, microwave, etc. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center containing one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.
[0123] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0124] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0125] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0126] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0127] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0128] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0129] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for screening Gramineae forage seeds based on image recognition, characterized in that, include: S1. Obtain images of grass seeds to be screened and identify seed adhesion areas, wherein the seed adhesion areas contain at least two grass seeds in contact with each other. S2. Construct the central axis topology map of the seed adhesion region, and simultaneously construct the energy distribution map based on image gradient within the seed adhesion region; S3. Identify the conflict nodes in the central axis topology graph that represent the intersection of multiple seed skeletons, and find the minimum energy path from the boundary of the connecting region to the conflict node in the energy distribution graph. S4. Select the minimum energy path from the minimum energy paths of each conflict node whose path direction is orthogonal to the direction of the central axis branch at the conflict node, and use its endpoint as the primary contact point, including: For each valid conflict node, extract all minimum cumulative energy paths connecting to the corresponding valid conflict node; Calculate the path direction vector of each minimum cumulative energy path terminating at a valid conflict node; Extract the direction vectors of all central axis branches connected at valid conflict nodes; Calculate the cosine of the angle between each path direction vector and the direction vector of each central branch; The path with the minimum cumulative energy is selected from the path direction vectors whose absolute value of the cosine of the angle with any central axis branch direction vector is less than a preset orthogonality threshold. The endpoints of the selected minimum cumulative energy paths located at effective conflict nodes are marked as primary contact points; S5. Using the primary contact point as a guide, simulate the inward evolution of the contour of the seed adhesion region, and determine the critical point where the contour topology splits during the inward evolution. The critical point is then identified as the final contact point, including: The overall mask of the seed adhesion area is used as the initial outline; In each iteration of contour inward evolution, a morphological erosion operation is applied to the current contour: a structuring element of a preset size and shape is used; the origin of the structuring element is aligned with each foreground pixel of the current contour; the center pixel is retained as a foreground pixel in the eroded image only when all pixels covered by the structuring element belong to the foreground; this operation causes the current contour to shrink inward by one pixel width along its normal direction, completing one evolution iteration. After each erosion operation, check whether the number of pixel connected components in the current contour has increased; When the number of connected pixel regions is first detected to increase, the current iteration step is determined to be the critical point where the contour topology splits. The bottom position of the contour depression corresponding to the critical point, which is guided by the primary contact point, is determined as the final contact point; S6. Generate a dividing line based on the final contact point to separate the individual grass seeds in the seed adhesion area, thus completing the instance segmentation.
2. The method for screening Gramineae forage seeds based on image recognition according to claim 1, characterized in that, Acquire images of the grass seeds to be screened and identify seed-adhesive regions, where each seed-adhesive region contains at least two grass seeds in contact with each other, including: Acquire images of grass seeds and convert them to grayscale images; The grayscale image is preprocessed to enhance the contrast between the seed region and the background; Based on the preprocessed image, the overall mask of all seed regions is extracted using a semantic segmentation model. Perform morphological opening operations on the overall mask to separate weakly connected non-seed regions; Identify candidate contiguous regions composed of multiple pixel connected regions from the overall mask; Candidate adhesion regions with an area greater than the preset area threshold for a single seed are selected as the final seed adhesion regions.
3. The method for screening Gramineae forage seeds based on image recognition according to claim 1, characterized in that, Construct a central topological map of the seed adhesion region and simultaneously construct an energy distribution map based on image gradients within the seed adhesion region, including: Calculate the distance transformation map based on the binary mask of the seed adhesion region; Local maxima detection is performed on the distance-transformed graph to extract the central axis point; Connect the central axis points to form an initial skeleton and trim the initial skeleton to remove short branches caused by edge noise, thereby obtaining the central axis topology map; Simultaneously, the gradient magnitude is calculated based on the original grayscale image corresponding to the seed adhesion region; The gradient magnitude is nonlinearly inverted and normalized so that weak edges correspond to high energy values and strong edges correspond to low energy values, thus generating an energy distribution map.
4. The method for screening Gramineae forage seeds based on image recognition according to claim 1, characterized in that, Identify conflict nodes representing the intersection of multiple seed skeletons in the central axis topology graph, and find the minimum energy path connecting the region boundary to the conflict node in the energy distribution graph, including: Identify all skeleton branch points in the central axis topology graph. A skeleton branch point is a node that connects three or more skeleton branches. Use the skeleton branch points as candidate conflict nodes; Calculate the skeleton orientation complexity within a preset neighborhood around each candidate conflict node; Candidate conflict nodes whose skeleton orientation complexity exceeds a preset threshold are identified as valid conflict nodes. In the energy distribution map, the pixel boundaries of the seed adhesion region are used as the path starting point set, and the effective conflict nodes are used as the path ending point. Based on the energy value of each pixel in the energy distribution map, the shortest path search algorithm is used to calculate the minimum cumulative energy path from each point in the path starting point set to each effective conflict node.
5. The method for screening Gramineae forage seeds based on image recognition according to claim 4, characterized in that, The calculation of the skeleton orientation complexity within a preset neighborhood around each candidate conflict node includes: extracting all skeleton pixels within the preset neighborhood radius centered on the candidate conflict node; calculating the dominant orientation of the skeleton pixels using principal component analysis; and statistically analyzing the dispersion of the skeleton orientation relative to the dominant orientation within the neighborhood. The dispersion is quantified by calculating the standard deviation of the orientation vector, and the quantified value is defined as the skeleton orientation complexity.
6. The method for screening Gramineae forage seeds based on image recognition according to claim 1, characterized in that, Calculating the path direction vector of each minimum cumulative energy path terminating at a valid conflict node includes: extracting the last path segment of the minimum cumulative energy path closest to the valid conflict node; performing linear regression fitting on the pixel coordinates of the last path segment to obtain a straight line; calculating the direction vector of the straight line, and defining this direction vector as the path direction vector of the minimum cumulative energy path terminating at a valid conflict node.
7. The method for screening Gramineae forage seeds based on image recognition according to claim 1, characterized in that, Based on the final contact point, a dividing line is generated to separate individual grass seeds in the seed-adhesive region, completing the instance segmentation, including: Pair up multiple final contact points that belong to the same contour splitting event; For each pair of final contact points, connect the two points on the overall mask of the seed adhesion area to generate a dividing line segment. Overlay all generated segmentation lines onto the overall mask of the seed adhesion region; Based on the overall mask after superimposing segmented line segments, the originally connected pixel region is divided into multiple independent pixel connected regions. Each independent pixel connected region obtained from the segmentation is labeled as an independent grass seed region, thus completing the instance segmentation.
8. A seed screening system for gramineous forage grasses based on image recognition, used to implement the seed screening method for gramineous forage grasses based on image recognition as described in any one of claims 1-7, characterized in that, include: The region recognition module is used to acquire images of grass seeds to be screened and identify seed adhesion regions, where the seed adhesion regions contain at least two grass seeds in contact with each other. The region construction module is used to construct the central axis topology map of the seed adhesion region and simultaneously construct the energy distribution map based on image gradient within the seed adhesion region; The region analysis module is used to identify conflict nodes in the central axis topology map that represent the intersection of multiple seed skeletons, and to find the minimum energy path connecting the region boundary to the conflict node in the energy distribution map. The primary identification module is used to select the minimum energy path from the minimum energy paths of each conflict node whose path direction is orthogonal to the direction of the central axis branch at the conflict node, and use its endpoint as the primary contact point. The final identification module is used to simulate the inward evolution of the contour of the seed adhesion region guided by the primary contact point, and to determine the critical point where the contour topology splits during the inward evolution of the contour, and to identify the critical point as the final contact point. The instance segmentation module is used to generate a dividing line based on the final contact point to separate individual grass seeds in the seed adhesion area, thus completing instance segmentation.
Citation Information
Patent Citations
Method, medium and device for segmenting visible components of microscopic image
CN118552572A
Image recognition-based pulmonary embolism focus segmentation method and system, and storage medium
CN121330728A