Rice seed precision sorting method and device based on grain type and color feature fusion analysis
By integrating analysis methods of grain shape and color characteristics, utilizing arc length parameterized contours and local illuminance normalization in the CIELAB color space, and combining a lightweight fusion model to dynamically set thresholds, the problem of identifying compound defects in rice seed sorting was solved, achieving high-precision, low-error intelligent sorting.
Patent Information
- Application Number
- CN202610394889.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-29
- Publication Date
- 2026-07-10
AI Technical Summary
Existing rice seed sorting technologies cannot effectively identify complex defects that include both deformation and color changes, and their generalization ability is poor when different varieties, light conditions, or equipment conditions change, resulting in a high rate of false rejection or missed detection.
A method based on the fusion analysis of grain shape and color features is adopted. The grain shape anomaly index is constructed by combining arc length parameterized contour with local curvature and directed cumulative area. Local illuminance is normalized in CIELAB color space, and a comprehensive quality score is generated using a lightweight fusion model. The rejection threshold is dynamically set.
It achieves highly sensitive detection of complex defects, significantly reduces false rejection and false negative rates, and improves the robustness and generalization ability of the system under multiple varieties and working conditions, meeting the needs of modern agriculture for high-throughput, high-precision, and intelligent sorting.
Smart Images

Figure CN122368580A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of rice seed sorting, and in particular to a method and apparatus for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics. Background Technology
[0002] Rice seed quality sorting is a crucial step in ensuring the quality of agricultural production. Traditional sorting mainly relies on manual visual inspection or mechanical sieving based on single physical parameters such as particle size and weight. This method suffers from problems such as low efficiency, high subjectivity, and difficulty in identifying minute internal or surface defects, and can no longer meet the demands of modern agriculture for high-throughput and high-precision sorting.
[0003] With the development of machine vision technology, existing automatic sorting systems mostly use image analysis methods to extract the grain shape characteristics (such as roundness and aspect ratio) and color characteristics (such as b in Lab space) of rice seeds. The method uses a preset fixed threshold to determine whether a particle shape or color is acceptable. However, this type of method usually separates particle shape and color information, and cannot effectively identify composite defects that include both deformation and color change (such as cracks accompanied by mold). Furthermore, the fixed threshold has poor generalization ability when faced with different varieties, lighting conditions, or equipment status changes, which can easily lead to false rejection or missed detection.
[0004] Therefore, there is an urgent need for a rice seed sorting method that can deeply integrate multi-dimensional features of grain shape and color and has adaptive discrimination capabilities, in order to solve the core defects of isolated analysis of multi-modal features and lack of robustness of static threshold in existing technologies, and achieve accurate, stable and intelligent quality sorting. Summary of the Invention
[0005] This application provides a method and apparatus for precise sorting of rice seeds based on the fusion analysis of grain shape and color characteristics, which solves the technical problem that the existing technology usually processes rice seed grain shape and color information separately, and cannot effectively identify composite defects that contain both deformation and color changes.
[0006] To achieve the above objectives, this application adopts the following technical solution: Firstly, a precise rice seed sorting method based on the fusion analysis of grain shape and color characteristics is provided, including: Acquire color images of rice seeds to be sorted, and perform single-grain segmentation on the rice seeds to be sorted, extracting the contour of each single grain and its corresponding surface pixel region; Based on the contour, the grain shape anomaly index of each individual rice seed is calculated. The grain shape anomaly index is obtained by coupling the local curvature change of the contour with the cumulative area distribution along the contour, which characterizes the structural defect status of the rice seed. Based on the surface pixel region, local illuminance normalization is performed on the brightness channel in CIELAB space, and based on the statistical characteristics of the normalized brightness and chromaticity channels, the color abnormality index of each single rice seed is calculated; the color abnormality index is used to characterize the color abnormality of the rice seed surface. The grain shape abnormality index and the color abnormality index are input into the pre-trained lightweight fusion model, and the comprehensive quality score of each single grain of rice is output. The overall quality score is compared with a set score threshold. If the overall quality score is less than the score threshold, the corresponding single grain of rice is determined to be an unqualified variety, and the execution mechanism is triggered to remove it from the normal flow path.
[0007] Based on the above technical solutions, in the rice seed sorting method based on the fusion analysis of grain shape and color characteristics provided in this application, traditional methods in rice seed sorting usually rely only on a single geometric or color index and use a fixed threshold for discrimination, which makes it difficult to accurately identify composite defects with simultaneous deformation and color changes (such as cracks accompanied by mold). Furthermore, these methods have poor stability under different varieties, lighting conditions, or equipment environments, easily leading to false rejection or missed detection. This application effectively overcomes the above problems by constructing a multimodal fusion discrimination system: based on arc-length parameterized contours, a position-aware weight distribution is constructed by combining local curvature and directed cumulative area, and its Shannon entropy is used to quantify grain shape irregularity; local illuminance normalization is performed on the brightness channel in the CIELAB color space, and then the normalized brightness is used in conjunction with... The standard deviation of the channel characterizes color anomalies; the two types of indicators are input into a pre-trained lightweight fusion model, which outputs a physically meaningful comprehensive quality score; the rejection threshold is dynamically set based on the score distribution of qualified samples in the current batch. This technical approach not only improves the sensitivity to subtle and complex defects, but also significantly enhances the system's robustness and generalization ability under multiple varieties and operating conditions through an adaptive mechanism, achieving high-precision, low-error rejection, and engineering-deployable intelligent sorting.
[0008] In conjunction with the first aspect above, in one possible implementation, the single-grain segmentation of the rice seeds to be sorted includes: The color image is input into a pre-trained lightweight instance segmentation network to generate multiple initial rice seed masks; each initial rice seed mask corresponds to a potential rice seed region. Fit the minimum bounding ellipse for each initial rice seed mask and calculate its ellipticity and area; If the area of any of the initial rice seed masks is greater than the preset upper limit of single grain area and its ellipticity is less than the first threshold, then the mask is determined to correspond to the adhered rice seed, and based on the geometric constraints of the contour concave point position and the minimum circumscribed ellipse, the mask is split into two or more sub-masks. If the area of any of the initial rice seed masks is less than the preset lower limit of single seed area and there are no adjacent masks, it is considered noise and is removed. All masks retained after splitting and noise removal are considered as single-particle segmentation results.
[0009] In conjunction with the first aspect above, in one possible implementation, the extraction of the contour of each individual rice seed and its corresponding surface pixel region includes: For each individual segmentation mask, perform morphological closing operations sequentially to eliminate internal holes; Based on the processed mask, a sub-pixel edge localization method is used to extract a closed contour point sequence as the geometric contour of the rice seed. Define the surface pixel region of the rice seed by the set of all pixels with a value of 1 in the mask; Establish a unique correspondence between the geometric contour and the surface pixel region.
[0010] In conjunction with the first aspect above, in one possible implementation, the calculation of the grain shape anomaly index for each individual rice seed includes: The rice grain outline is parameterized using arc length. The independent variable is a plane curve, and samples are uniformly taken from this curve. One point; For each sampling point Calculate its local curvature and from the starting point of the outline to The directed cumulative area enclosed Where i is the index of the sampling point, i=1,2,…n; A normalized weight distribution is constructed based on the product of the curvature and the cumulative area: ; in, and ; Calculate the Shannon entropy of this distribution as an indicator of grain size anomalies. : .
[0011] In conjunction with the first aspect described above, in one possible implementation, the local curvature is calculated. ,include: With sampling points Centered on the arc-length parameterized profile, select the areas before and after it. A set of 3 neighboring points constitutes a local point set; The local point set is aligned in coordinate system: the direction of the principal axis of the smallest circumscribed ellipse of the rice outline is used as the reference direction, and the local point set is rotated to make its principal direction horizontal; In the aligned local coordinate system, a quadratic polynomial curve is fitted using the least squares method. Where (x,y) are the coordinates of a local point, and a, b, and c are the coefficients of the curve fitting. Calculate sampling points based on the fitting coefficients. Directed curvature at: .
[0012] In conjunction with the first aspect above, in one possible implementation, the directed cumulative area is calculated. ,include: The outline of the rice grains is oriented to be corrected so that it traverses in a counterclockwise direction; The starting point of the contour is repositioned to the right endpoint of the major axis of the least circumscribed ellipse, based on the repositioned sequence of contour points. Calculate from the starting point of the contour to the first... The directed cumulative area of each sampling point : ; in, The sampling point number is... , Let K be the coordinates of the kth sampling point. The coordinates of the (k+1)th sampling point.
[0013] In conjunction with the first aspect above, in one possible implementation, the calculation of the color abnormality index for each individual rice grain includes: The surface pixel area is converted to the CIELAB color space to obtain the brightness channel. and chroma channels ; Large-scale Gaussian filtering is used for the above Perform local illuminance estimation, and adjust the luminance channel based on the estimation results. Perform illuminance normalization to obtain normalized luminance. ; Calculate the normalized brightness The standard deviation and the chromaticity channel Standard deviation; Normalize brightness Standard deviation and color channels The standard deviations are linearly combined according to preset weights to obtain the color abnormality index. : ; in, , The weighting coefficients are set according to the rice variety.
[0014] In conjunction with the first aspect above, in one possible implementation, the method for constructing the pre-trained lightweight fusion model includes: Multiple varieties of rice samples were collected, and based on the expert visual grading results, each sample was assigned a corresponding comprehensive quality label, which is a continuous value or a binary category between 0 and 1. Calculate the grain shape and color abnormality indices corresponding to each rice variety sample to form training sample pairs; wherein, the input features are the two abnormality indices and the supervision signal is the comprehensive quality label. The training sample pairs are divided into a training set and a validation set, and a lightweight regression model is trained using the training set so that the model outputs the comprehensive quality label. The lightweight regression model after training convergence is the lightweight fusion model, which is used to fuse the abnormal grain shape and color indicators of new rice samples and output the corresponding comprehensive quality score.
[0015] In conjunction with the first aspect above, in one possible implementation, the method for obtaining the score threshold includes: Obtain the overall quality score of the qualified samples in the current batch to get the score set; Calculate the mean of the score set. and standard deviation ; Through formula Calculate the score threshold ;in, This is the preset confidence coefficient.
[0016] Secondly, this application provides a precise rice sorting device based on the fusion analysis of grain shape and color features, comprising: a segmentation unit, a quality assessment unit, and a discrimination unit; wherein, the segmentation unit is used to acquire a color image of the rice seeds to be sorted, and to perform single-grain segmentation of the rice seeds to be sorted, extracting the contour of each single grain and its corresponding surface pixel region; the quality assessment unit is used to calculate the grain shape anomaly index of each single grain based on the contour; to perform local illuminance normalization in the brightness channel in CIELAB space based on the surface pixel region, and to calculate the color anomaly index of each single grain based on the statistical characteristics of the normalized brightness and color channels; to input the grain shape anomaly index and the color anomaly index into a pre-trained lightweight fusion model, and to output the comprehensive quality score of each single grain; the discrimination unit is used to compare the comprehensive quality score with a set score threshold, and if the comprehensive quality score is less than the score threshold, the corresponding single grain is determined to be an unqualified variety, and the execution mechanism is triggered to remove it from the normal flow path.
[0017] This application provides a method and apparatus for precise rice seed sorting based on the fusion analysis of grain shape and color features, which can effectively solve the core problems of traditional sorting technology, such as feature fragmentation, rigid criteria, and environmental sensitivity. This method performs high-precision segmentation of individual rice seeds, extracting their contours and surface pixel regions separately. Based on this, it constructs a Shannon entropy index by parameterizing the contour through arc length and combining local curvature and directed cumulative area, achieving highly sensitive quantification of grain shape anomalies such as cracks, depressions, and deformities. Simultaneously, it performs local illuminance normalization on the brightness channel in the CIELAB color space to eliminate interference from uneven illumination, and utilizes the normalized brightness and b... The standard deviation of the color channels is jointly used to characterize color abnormalities such as mold, yellowing, and aging. Furthermore, these two types of heterogeneous features are input into a pre-trained lightweight fusion model to generate a comprehensive quality score with physical interpretability, balancing discriminative performance and computational efficiency. Crucially, the system dynamically sets the rejection threshold based on the score distribution of qualified samples in the current batch, achieving adaptive calibration and significantly improving generalization ability and stability under different varieties and operating conditions. The overall solution achieves collaborative perception and intelligent decision-making for complex defects (such as deformation + color change), greatly reducing false rejection and false negative rates, meeting the urgent needs of modern agriculture for high-throughput, high-precision, and intelligent rice seed sorting.
[0018] It should be understood that the descriptions of technical features, technical solutions, beneficial effects, or similar language in this application do not imply that all features and advantages can be achieved in any single embodiment. Rather, it is understood that the description of a feature or beneficial effect means that a specific technical feature, technical solution, or beneficial effect is included in at least one embodiment. Therefore, the descriptions of technical features, technical solutions, or beneficial effects in this specification do not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions, and beneficial effects described in this embodiment can be combined in any suitable manner. Those skilled in the art will understand that embodiments can be implemented without one or more specific technical features, technical solutions, or beneficial effects of a particular embodiment. In other embodiments, additional technical features and beneficial effects may be identified in specific embodiments that do not embody all embodiments. Attached Figure Description
[0019] Figure 1 A system architecture diagram of a precise rice seed sorting method based on the fusion analysis of grain shape and color characteristics provided in this application embodiment; Figure 2 A flowchart illustrating a method for obtaining particle shape anomaly indicators provided in an embodiment of this application; Figure 3 A flowchart illustrating a method for obtaining color abnormality indicators provided in an embodiment of this application; Figure 4A schematic diagram of the structure of a rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics provided in this application embodiment; Figure 5 This is a schematic diagram of the hardware structure of a rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics, provided in an embodiment of this application. Detailed Implementation
[0020] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. 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.
[0021] The rice seed precision sorting method based on the fusion analysis of grain shape and color characteristics provided in this application embodiment can be applied to a rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics. The system includes: a quality assessment unit, and a segmentation unit and a discrimination unit connected thereto. The segmentation unit is used to acquire a color image of the rice seeds to be sorted, and to perform single-grain segmentation on the rice seeds to be sorted, extracting the contour of each single grain and its corresponding surface pixel region. The quality assessment unit is used to calculate the grain shape anomaly index for each individual rice variety based on its profile. Based on the surface pixel region, local illuminance normalization is performed on the brightness channel in CIELAB space, and the color abnormality index of each single rice grain is calculated based on the statistical characteristics of the normalized brightness and color channels. The abnormal grain shape index and abnormal color index are input into the pre-trained lightweight fusion model, and the comprehensive quality score of each single grain of rice is output. The discrimination unit is used to compare the overall quality score with the set score threshold. If the overall quality score is less than the score threshold, the corresponding single rice grain is determined to be an unqualified variety, and the execution mechanism is triggered to remove it from the normal flow path.
[0022] To address the technical problem that existing technologies typically process grain shape and color information separately, failing to effectively identify composite defects involving both deformation and color changes, this application provides a precise rice seed sorting method based on the fusion analysis of grain shape and color features. This method includes: acquiring a color image of the rice seeds to be sorted, performing single-grain segmentation on each seed, and extracting the contour of each single grain and its corresponding surface pixel region; calculating grain shape anomaly indices for each single grain based on the contours; and performing local illuminance normalization in the brightness channel of the CIELAB color space based on the surface pixel region. Based on the statistical characteristics of normalized brightness and chroma channels, the color anomaly index of each individual rice grain is calculated. The grain shape anomaly index and color anomaly index are input into a pre-trained lightweight fusion model, and the comprehensive quality score of each individual rice grain is output. The comprehensive quality score is compared with a set score threshold. If the comprehensive quality score is less than the score threshold, the corresponding individual rice grain is determined to be an unqualified variety, and the execution mechanism is triggered to remove it from the normal flow path. Based on this, this application significantly improves the accuracy and robustness of rice seed sorting through multimodal feature fusion and adaptive discrimination mechanism. The contour-based grain shape anomaly index utilizes arc length parameterization, local curvature, and directed cumulative area to construct an information entropy model, which can sensitively capture structural defects such as cracks and deformities. By performing local illuminance normalization on the CIELAB brightness channel and combining normalized brightness with... The standard deviation of the channel is used to calculate color anomalies, effectively suppressing light interference and accurately identifying color changes such as mold and aging. These two factors are then fused into a lightweight model to generate a comprehensive quality score, balancing computational efficiency and discriminative power. Simultaneously, the scoring threshold is dynamically set based on the current batch of qualified samples, avoiding the failure of fixed thresholds in different varieties or environments. The overall solution achieves highly sensitive detection of complex defects, strong cross-scenario generalization ability, and the feasibility of embedded deployment, solving the core pain points of traditional methods such as high false rejection rates and poor adaptability caused by isolated features and rigid criteria.
[0023] like Figure 1 As shown in the embodiments of this application, the precise rice seed sorting method based on the fusion analysis of grain shape and color characteristics includes: S201. Obtain a color image of the rice seeds to be sorted, and perform single-grain segmentation on the rice seeds to be sorted, extracting the outline of each single grain and its corresponding surface pixel area.
[0024] Among them, single grain segmentation is achieved by combining a lightweight instance segmentation network with prior constraints on rice seed morphology. Adhesive particles are separated by a concave point splitting algorithm guided by the minimum circumscribed ellipse, ensuring that each rice seed corresponds to an independent mask. It should be noted that the contour and the surface pixel region originate from the same segmentation mask and maintain a strict one-to-one correspondence in subsequent processing. The contour is used for grain geometric feature analysis, and the surface pixel region is used for color feature extraction. The two are completely aligned in space to avoid inaccurate multimodal feature fusion due to segmentation drift or region mismatch.
[0025] S202. Based on the profile, calculate the grain shape anomaly index for each individual rice variety.
[0026] Among them, the grain shape anomaly index is obtained based on the local curvature change of the coupled contour and the area distribution accumulated along the contour, which characterizes the structural defects of rice.
[0027] It should be noted that this indicator is not a simple linear combination of geometric parameters (such as roundness or aspect ratio), but rather quantifies the "uncertainty" of the contour shape through information entropy. Normal rice seeds have smooth and symmetrical contours, with a concentrated distribution of curvature and area coupling, resulting in low entropy values. In contrast, rice seeds with depressions, cracks, or deformities have a dispersed distribution due to local deformation, leading to significantly higher entropy values. This allows for highly sensitive discrimination of fine structural defects.
[0028] S203. Based on the surface pixel region, perform local illuminance normalization in the brightness channel in CIELAB space, and calculate the color abnormality index of each single rice grain based on the statistical characteristics of the normalized brightness and color channels.
[0029] Among them, the color abnormality index is used to characterize the color abnormality of the rice seed surface.
[0030] It should be noted that this method does not directly use the original Lab value or simple mean to judge color anomalies, but rather restores the true reflectance characteristics of the rice seed surface through illuminance normalization, and utilizes... The unevenness reflects aging or localized dark spots. The discrete sensitivity of the material can detect mold or browning, and the fusion of the two can effectively distinguish between light interference and true color defects, significantly improving the robustness of discrimination under complex working conditions.
[0031] S204. Input the abnormal grain shape index and abnormal color index into the pre-trained lightweight fusion model, and output the comprehensive quality score of each individual rice grain.
[0032] In some implementations, multiple varieties of rice samples are collected, and each sample is assigned a corresponding comprehensive quality label based on expert visual grading results. The comprehensive quality label is a continuous value between 0 and 1 or a binary category. Calculate the grain shape and color abnormality indices corresponding to each rice variety sample to form training sample pairs; the input features are the two abnormality indices and the supervision signal is the comprehensive quality label. The training sample pairs are divided into training set and validation set, and a lightweight regression model is trained using the training set so that the model outputs a comprehensive quality label. The lightweight regression model after training convergence is a lightweight fusion model used to fuse the abnormal grain shape and color indicators of new rice varieties and output the corresponding comprehensive quality score.
[0033] It should be noted that the pre-trained lightweight fusion model does not use fixed weighting (such as manually setting weights) or simple threshold judgment. Instead, it learns the nonlinear coupling relationship between grain shape and color features under different defect types (such as crack-dominated vs. mold-dominated) by pre-training on samples of multiple rice varieties, thereby achieving adaptive discrimination. For example, when color abnormality is significantly higher than grain shape abnormality, the model automatically increases the color weight to prioritize responding to mold risk, and conversely, it focuses on grain shape defects, which significantly improves the discrimination accuracy of composite defects and edge samples.
[0034] S205. Obtain the overall quality score of the qualified samples in the current batch to obtain the score set; calculate the mean of the score set. and standard deviation ; through formula Calculate the score threshold ;in, The preset confidence coefficient; The overall quality score is compared with the set score threshold. If the overall quality score is less than the score threshold, the corresponding single grain of rice is determined to be an unqualified variety, and the execution mechanism is triggered to remove it from the normal flow path.
[0035] It should be noted that by dynamically calculating thresholds, the system can automatically adapt to natural variations in grain shape and color among different batches of rice seeds, avoiding the failure of fixed thresholds due to variety changes, changes in ambient light, or equipment aging. Specifically, when the overall quality score of a single rice seed is lower than the threshold, it indicates that its quality significantly deviates from the distribution center of the current batch of qualified samples, belonging to a statistically significant "abnormally low value," and is highly likely to contain structural defects such as cracks, mold, and aging; while samples above the threshold are considered to be within the normal range and do not need to be rejected. This data-driven self-calibration mechanism not only improves the robustness and versatility of the sorting system, but also effectively reduces the false rejection rate and the missed detection rate.
[0036] Based on the above technical solutions, the rice seed sorting method based on the fusion analysis of grain shape and color features provided in this application addresses the shortcomings of traditional methods in rice seed sorting. Traditional methods rely on single geometric or color parameters and fixed thresholds, making it difficult to effectively identify complex defects such as cracks and mold. Furthermore, these methods are easily affected by varietal differences and changes in light intensity, leading to high false rejection rates and poor generalization ability. This solution proposes an intelligent discrimination mechanism that integrates multi-dimensional features of grain shape and color: it quantifies grain shape anomalies by parametrically defining the contour using arc length and coupling entropy with directed curvature-cumulative area, and utilizes the brightness and b² values after CIELAB spatial illuminance normalization. Channel standard deviation characterizes color abnormalities, and a lightweight model dynamically fuses these two factors to generate a comprehensive quality score. Simultaneously, a rejection threshold is adaptively set based on the statistical distribution of qualified samples. This scheme not only achieves highly sensitive detection of combined defects of "deformation + color change," but also significantly improves robustness across varieties and batches through a data-driven threshold mechanism, balancing accuracy and real-time performance. It solves the discrimination failure problem caused by feature fragmentation and static criteria in existing technologies, providing a reliable and deployable intelligent solution for precise rice seed sorting.
[0037] In one possible implementation of this application embodiment, the above-mentioned S201 can be specifically implemented by the following S301-S304, which will be described in detail below: S301. Input the color image into the pre-trained lightweight instance segmentation network to generate multiple initial rice seed masks; each initial rice seed mask corresponds to a potential rice seed region.
[0038] Among them, the lightweight instance segmentation network is built on an improved MobileNetV3 backbone and a simplified Mask R-CNN head structure, and is specifically optimized for rice seed morphology features. It can achieve real-time inference on embedded vision processors.
[0039] In some implementations, the instance segmentation network uses a synthetic-real hybrid dataset during the training phase: it generates a large number of labeled, contiguous samples using standard high-quality rice seed images through geometric transformations and illumination perturbations, and trains them together with a small number of manually labeled real scene images, thereby significantly improving the model's robustness to complex arrangements and background interference.
[0040] It should be noted that, since rice seeds often exhibit slight adhesion or stacking during transmission, a single initial mask may correspond to multiple physical rice grains. Therefore, this step only outputs the "potential" rice seed region. Subsequently, it is necessary to combine morphological priors (such as area and ellipticity) to perform adhesion splitting and noise filtering to ensure that the final segmentation result meets the single-grain-level accuracy requirements.
[0041] S302. Fit the minimum bounding ellipse for each initial rice seed mask and calculate its ellipticity and area.
[0042] The minimum bounding ellipse is solved by an ellipse fitting algorithm based on the second-order central moment, ensuring that the geometrically optimal bounding ellipse is obtained while maintaining computational efficiency. Ellipticity is defined as the ratio of the length of the minor axis to the length of the major axis of the ellipse, with a value range of (0,1]. The closer the value is to 1, the closer the shape is to a perfect circle. The ellipticity of typical healthy rice varieties is usually concentrated in the range of 0.35–0.55. The area is determined by the total number of non-zero pixels in the mask.
[0043] In some implementations, the ellipticity threshold and area upper and lower limits are automatically adjusted according to the current rice variety: the system loads the morphological parameter template of the corresponding variety before sorting, or estimates the statistical benchmark online through a small number of qualified samples, thereby adapting to different grain shape characteristics such as japonica rice, indica rice, and hybrid rice, and avoiding misjudgment caused by fixed thresholds.
[0044] It should be noted that this step is not only used for geometric description, but also serves as a key basis for subsequent adhesion judgment and noise filtering. For example, when the area of a mask is significantly larger than the upper limit of the area of a single rice seed and the ellipticity is lower than the preset threshold, it indicates that it is very likely caused by the adhesion of two or more rice seeds, and a splitting operation needs to be triggered. Conversely, if the area is too small and exists in isolation, it is regarded as imaging noise and is removed.
[0045] S303. If the area of any initial rice seed mask is greater than the preset upper limit of single grain area and its ellipticity is less than the first threshold, then the mask is determined to be an adhered rice seed, and based on the geometric constraints of the contour concave point position and the minimum circumscribed ellipse, the mask is split into two or more sub-masks. If the area of any initial rice seed mask is less than the preset lower limit of single seed area and there are no adjacent masks, it is considered noise and is removed.
[0046] Specifically, the concave points of the contour are located by calculating the minimum value of the contour curvature, i.e. the local negative curvature peak, and combined with the principal axis direction of the minimum circumscribed ellipse to screen effective splitting candidate points. Only concave points located near the minor axis of the ellipse and whose depth exceeds the height of the contour bounding box are retained as effective splitting criteria. The splitting operation performs region segmentation along the direction of the line connecting the concave point and the center of the ellipse to generate independent sub-masks.
[0047] It should be noted that this splitting strategy is not simply a matter of cutting along a fixed direction, but rather integrates morphological priors (major axis / minor axis of the ellipse) with local geometric features (depth and direction of concave points), effectively avoiding missplitting of naturally curved contours (such as the tail of a rice seed) while ensuring that adhered areas are accurately separated. In addition, noise removal not only relies on the area threshold, but also introduces the "nearby mask" criterion; if there are other masks within a certain distance around a small area mask, they are regarded as fragments or edge debris and are retained, and only isolated small areas are judged as imaging noise.
[0048] S304. All masks retained after splitting and noise removal are single-particle segmentation results.
[0049] Based on the above technical solutions, during the rice seed sorting process, due to the natural stacking, slight adhesion, or imaging occlusion of rice grains on the conveyor belt, the initial segmentation results often exhibit problems such as "multi-grain merging" or "noise artifacts," leading to inaccurate subsequent grain shape and color analysis and severely reducing sorting accuracy. Without effective processing, single-grain-level feature extraction will fail, significantly increasing the false rejection and false negative rates. This technical solution generates an initial mask through a pre-trained lightweight instance segmentation network, identifies adhered regions using both ellipticity and area criteria, and achieves precise splitting based on the contour concave point position and minimum bounding ellipse geometric constraints. Simultaneously, noise is filtered out from isolated small regions, thus achieving a reliable conversion from "potential regions" to "single grain entities." This method not only avoids the problems of traditional threshold segmentation being sensitive to illumination and having blurred boundaries, but also utilizes morphological priors (such as ellipticity) and local geometric structures (concave points) for collaborative decision-making, significantly improving the accuracy and robustness of adhesion separation. Compared to manually setting rules or simple binarization, this solution has stronger generalization ability and automation level, and can adapt to complex scenarios with different varieties and different arrangement densities. It provides high-quality input for subsequent multimodal feature fusion, and fundamentally solves the key bottleneck that restricts the performance of intelligent sorting systems: "inaccurate single-particle segmentation".
[0050] In one possible implementation, after S304, this embodiment of the application also provides a method for extracting the contour of each individual rice seed and its corresponding surface pixel region, including the following S401 to S404: S401. Perform morphological closing operations on each single-particle segmentation mask sequentially to eliminate internal holes; S402. Based on the processed mask, the sub-pixel edge localization method is used to extract the closed contour point sequence as the geometric contour of the rice seed. S403. Define the surface pixel region of the rice seed by the set of all pixels with a value of 1 in the mask; S404. Establish a unique correspondence between geometric contours and surface pixel regions.
[0051] Among them, the morphological closing operation adopts a circular structuring element, whose radius is adaptively set according to the average grain size of the current rice variety (usually 2 to 5 pixels). It first expands and then erodes to fill the internal voids caused by imaging noise or slight occlusion, while maintaining the overall shape. The sub-pixel edge localization method is based on Zernike moments or gradient interpolation, which further improves the contour accuracy to the 1 / 10 pixel level on the basis of pixel-level edges. The surface pixel region is the set of all foreground pixels in the binary mask, which is used for subsequent color analysis.
[0052] It should be noted that although the geometric contour and the surface pixel region originate from the same mask, they may be spatially offset or inconsistent due to edge extraction algorithms or post-processing operations in the image processing flow. If the two are not strictly aligned, the grain shape features and color features will come from different physical regions, resulting in inaccurate multimodal fusion. Therefore, this solution generates the contour and surface region separately by sharing the same mask processed by the closing operation, and binds their IDs at the data structure level to ensure that the two are strictly one-to-one in space and semantics.
[0053] In some implementations, subpixel contour points can be back-projected into the mask coordinate system to verify whether they enclose all surface pixels; if leakage or anomalies are found, a mask re-segmentation or contour correction mechanism is triggered to further ensure geometric-appearance consistency.
[0054] Based on the above technical solutions, in intelligent rice seed sorting, the masks after single-grain segmentation often have internal holes due to imaging noise, local occlusion, or surface depressions. If directly used for contour extraction and color analysis, this will introduce geometric distortion and color deviation, affecting the accuracy of grain shape and color features. Furthermore, traditional pixel-level contour extraction methods have limited resolution, making it difficult to meet the high-precision identification requirements for defects such as micro-cracks and depressions. This technical solution eliminates internal holes by sequentially performing morphological closing operations, ensuring mask integrity; it employs a sub-pixel edge localization method to extract high-precision contour point sequences, improving contour resolution to the sub-pixel level and significantly enhancing sensitivity to fine structural defects. Simultaneously, it defines the set of all pixels with a value of 1 in the mask as the surface pixel region, achieving a unified spatial expression of geometric contours and appearance information, and establishing a unique correspondence between the two, ensuring semantic consistency in subsequent fusion of grain shape and color features. This solution effectively addresses core issues such as "incomplete mask", "insufficient contour accuracy", and "multimodal data mismatch", improving the robustness and reliability of feature extraction, providing a high-quality input foundation for high-precision quality judgment, and possessing good engineering feasibility and generalization ability.
[0055] In one possible implementation of the embodiments of this application, such as Figure 2 As shown, the above S202 can be specifically implemented through the following S501-S504, which are explained in detail below: S501, parameterize the rice grain outline as an arc length parameter. The independent variable is a plane curve, and samples are uniformly taken from this curve. One point.
[0056] Among them, arc length This is the accumulated path length along the boundary from the starting point of the contour, measured in pixels. It is used to ensure a constant curve speed during parameterization and to avoid uneven sampling density due to local contour curvature. The parameterization process calculates the accumulated arc length through numerical integration. Uniform sampling means... Selecting at equal intervals within the interval ( , ), to obtain the corresponding sampling points .
[0057] In some implementations, the number of sampling points Based on the total length of the outline Adaptive adjustment: when Pixel time take ,when Time to take ,when Time to take This ensures both computational accuracy and the real-time requirements of embedded devices.
[0058] It should be noted that this parameterization method does not simply traverse the contour by pixel index, but rather constructs a smooth, differentiable mathematical representation based on the principle of geometric consistency, which provides a basis for subsequent accurate calculation of local curvature. and directed cumulative area It provides a theoretical basis, and can effectively suppress noise interference, especially when dealing with slight adhesion or edge jitter.
[0059] S502, For each sampling point Calculate its local curvature and from the starting point of the outline to The directed cumulative area enclosed Where i is the sampling point number, i=1,2,…n.
[0060] S503. Construct a normalized weight distribution based on the product of curvature and cumulative area: ; in, and ; S504. Calculate the Shannon entropy of this distribution as an indicator of grain size anomalies. : ; in, The larger the value, the more irregular the local deformation of the rice grain outline and the more significant the structural defects.
[0061] It should be noted that the particle shape anomaly index is constructed by fusing local geometric deformation of the contour with spatial location information. Specifically, the absolute value of local curvature at each sampling point is calculated. To characterize bending strength, and combined with the directed cumulative area from the profile origin to that point. It reflects its relative position in the overall form; the product of the two, after normalization, forms a probability distribution. Furthermore, based on its Shannon entropy This serves as an indicator of final grain shape abnormalities. The design principle is based on the fact that normal rice seeds have a smooth and symmetrical outline, and defect energy is concentrated. Sharp distribution and low entropy value; while rice seeds with cracks, dents, or deformities are due to multiple localized deformations. The dispersion leads to a significant increase in entropy. Therefore, this index can effectively quantify the irregularity of the contour shape, and has high sensitivity and strong robustness to fine structural defects, overcoming the limitation of traditional methods based on a single geometric parameter (such as roundness and aspect ratio) in identifying local anomalies.
[0062] Based on the above technical solution, in rice seed quality sorting, traditional grain shape discrimination methods mostly rely on single geometric parameters (such as roundness and aspect ratio), which are difficult to effectively identify structural defects such as local micro-depressions, cracks, or asymmetric deformities, and lack sensitivity to morphological changes. Furthermore, different rice varieties have significant differences in grain shape, and using a fixed threshold can easily lead to misjudgment. This technical solution parameterizes the contour into arc length... The independent variable is a planar curve, and uniform sampling is used. Each point, combined with local curvature With directed cumulative area Constructing a normalized weight distribution Using Shannon entropy This design quantifies the "uncertainty" of the overall morphology. It not only integrates local deformation intensity and spatial location information but also reflects the global irregularity of the contour: normal rice grains have smooth and symmetrical contours, concentrated weight distribution, and low entropy; while in the presence of defects, abrupt changes in local curvature and area variations lead to a dispersed distribution and a significantly increased entropy. Compared to traditional methods, this scheme exhibits stronger defect sensitivity and robustness, accurately captures complex deformation characteristics, and eliminates the need for manually setting complex rules. It is suitable for intelligent sorting under multiple varieties and working conditions, effectively improving the accuracy and generalization ability of grain shape anomaly detection.
[0063] One possible implementation, following S502, includes the following: Calculate local curvature This includes the following steps: With sampling points Centered on the arc-length parameterized profile, select the areas before and after it. A set of 3 neighboring points constitutes a local point set; Align the local point set with the coordinate system: take the direction of the principal axis of the smallest circumscribed ellipse of the rice outline as the reference direction, and rotate the local point set to make its principal direction horizontal; In the aligned local coordinate system, a quadratic polynomial curve is fitted using the least squares method. Where (x,y) are the coordinates of a local point, and a, b, and c are the coefficients of the curve fitting. Calculate sampling points based on the fitting coefficients. Directed curvature at: ; Among them, when When, it indicates that there is an inward depression at that location, such as a crack or indentation; when When the location is convex outward or partially flat, it indicates that the location is a normal bulge, a naturally curved tail, or a smooth transition area. The size of the local point set is determined by Decide, The value is typically set to 3 or 5 to balance fitting accuracy and noise resistance; the minimum circumscribed ellipse is obtained by calculating the second central moment of the contour, and its principal axis represents the overall orientation of the rice grains; rotation ensures that the local contour is in a standard posture before fitting, avoiding misjudgment of curvature sign due to tilt; fitting coefficients From the system of linear equations The solution is obtained; where, To design the matrix, .
[0064] It should be noted that this method does not simply apply a general curvature formula, but rather constructs a posture-robust local curvature estimation framework by combining the geometric prior of rice seeds (approximately ellipse). By aligning the principal axis directions, the rotational influence of the contour under different postures is eliminated, making the curvature response of the same type of defect comparable in different samples. At the same time, preserving the curvature sign enables the system to clearly distinguish between "protrusions" and "depressions", significantly improving the accuracy of identifying structural defects such as cracks and depressions.
[0065] Based on the above technical solutions, in rice seed quality testing, traditional methods for calculating local curvature often employ simple difference or fixed window fitting, which are susceptible to noise interference and sensitive to contour posture, leading to inconsistent curvature responses for the same defect in different directions, affecting discrimination stability. Furthermore, rice grain contours exhibit natural curvature and local depressions, requiring high-precision differentiation between "normal morphology" and "structural defects." This technical solution addresses this by using sampling points... Centered on the arc-length parametric profile, select the front and rear sides. A local point set is formed by neighboring points, and the coordinate system is aligned based on the principal axis of the least circumscribed ellipse to make the principal direction of the local contour horizontal and eliminate the influence of attitude. A quadratic curve is fitted in the aligned coordinate system using the least squares method, and its coefficients are used to... Calculate directed curvature This method not only improves the noise resistance and geometric consistency of curvature estimation, but also achieves directional robustness by introducing rice seed morphology priors (elliptical principal axes), ensuring that the same type of defect has comparable curvature characteristics in different samples. Simultaneously, negative curvature directly corresponds to inward concavity, providing a clear criterion for defects such as cracks and indentations. Compared to traditional methods, this scheme significantly improves the accuracy and reliability of local deformation detection and is suitable for high-precision particle shape analysis under complex working conditions.
[0066] Calculate the directed cumulative area This includes the following steps: The outline of the rice grains is oriented to be corrected so that it traverses in a counterclockwise direction; The starting point of the contour is repositioned to the right endpoint of the major axis of the least circumscribed ellipse, based on the repositioned sequence of contour points. Calculate from the starting point of the contour to the first... The directed cumulative area of each sampling point : ; in, The sampling point number is... , Let K be the coordinates of the kth sampling point. The coordinates of the (k+1)th sampling point.
[0067] Direction correction is achieved by determining the sign of the overall area enclosed by the contour: if the original traversal direction results in a negative total area, the flipped point sequence is in a counter-clockwise direction; the repositioning of the starting point involves taking the right endpoint of the minor circumscribed ellipse's major axis as the new starting point and rearranging the contour point sequence to ensure all samples have a unified starting phase; each term of this formula... Indicates by the first The point and the first The area of the directed triangle formed by the line segment consisting of the points and the origin.
[0068] In some implementations, the right endpoint of the minor circumscribed ellipse's major axis can be obtained by calculating the second-order central moment of the profile, and then an affine transformation can be used to map this point to the vicinity of the coordinate system origin to improve numerical stability; furthermore, when When, define To avoid the summation term being empty.
[0069] It should be noted that this scheme introduces a direction correction and starting point normalization mechanism, which solves the incomparability problem caused by inconsistent contour traversal directions or random starting points in traditional cumulative area calculations; for example, when sampling the same rice variety from different points, The sequence may be completely reversed; however, this solution, by forcing counter-clockwise traversal and fixing the starting point, makes... This becomes a repeatable and comparable morphological code, thus effectively supporting the construction of subsequent granular anomaly indicators.
[0070] Based on the above technical solution, in rice grain shape analysis, traditional cumulative area calculation often results in incomparable values due to inconsistent contour traversal directions or random starting points, affecting the stability and consistency of subsequent feature extraction. For example, if the same rice grain contour is sampled from different points, its cumulative area sequence may be completely opposite, making it difficult to quantify morphological anomalies. This technical solution corrects the direction so that the contour traverses in a counterclockwise direction and repositions the starting point to the right endpoint of the least circumscribed ellipse's major axis, ensuring that all samples have a uniform starting phase and traversal order. Based on this, the shoelace formula is used to calculate the cumulative area from the starting point to the... The directed cumulative area of each sampling point This value not only reflects local geometric changes but also possesses a clear spatial order. By standardizing the starting point and direction, this method achieves repeatable and comparable cumulative area, effectively supporting subsequent coupled analysis with features such as curvature. Compared to traditional methods, this scheme significantly improves the consistency and robustness of morphological encoding, avoids errors introduced by differences in initial conditions, and provides a reliable foundation for constructing high-precision grain shape anomaly indicators. It is suitable for automated sorting systems of multiple varieties and batches of rice.
[0071] In one possible implementation of the embodiments of this application, such as Figure 3 As shown, the above S203 can be specifically implemented through the following S601-S604, which are explained in detail below: S601. Convert the surface pixel area to the CIELAB color space to obtain the brightness channel. and chroma channels .
[0072] The CIELAB color space is a device-independent color model that approximates the uniformity of human visual perception, and its lightness channel... The chroma channel represents the brightness of a pixel (its value typically ranges from 0 to 100). Characterizing the color shift along the yellow-blue axis (positive values indicate a yellowish tint, negative values indicate a bluish tint); the conversion process involves first performing a standard sRGB inverse transform on the RGB image to obtain linear XYZ tristimulus values, and then calculating them according to the CIE 1976 standard formula. , , Three components.
[0073] In some implementations, to improve conversion efficiency, lookup table (LUT) or lightweight neural networks can be used to approximate the RGB-to-Lab mapping, avoiding real-time calls to complex nonlinear functions. Furthermore, in low-light or high-reflectivity scenes, white balance correction can be performed on the original RGB image before color space conversion to further suppress the influence of ambient light color temperature. Interference in the channel.
[0074] It should be noted that this selection is not based on arbitrary selection of color components, but rather on the typical manifestations of color defects in rice seeds: normal rice is light yellow or off-white, while deterioration such as mold, aging, or heat damage usually manifests as localized darkening. Decreased and uneven) or noticeably yellowed ( (significantly increased), in contrast, the red-green axis The variations in most rice varieties are weak and the information redundancy is high, so they are discarded to reduce computational overhead and focus on key discriminative features.
[0075] S602, Using large-scale Gaussian filtering Perform local illuminance estimation, and based on the estimation results... Perform illuminance normalization to obtain normalized luminance. .
[0076] Among them, the kernel standard deviation of large-scale Gaussian filtering Set the resolution to 1.5 to 2.0 times the length of a rice grain (typically 30 to 50 pixels) for extraction. The low-frequency component in the channel characterizes the local illuminance field caused by uneven ambient lighting, conveyor belt reflections, or lens vignetting. Normalization is achieved through pixel-by-pixel division. ; in, To prevent division by zero of small constants (such as...) This ensures numerical stability.
[0077] In some implementations, the size of the Gaussian kernel can be automatically adjusted according to the current rice variety: after the system loads the average grain length parameter corresponding to the variety, it is dynamically calculated. ( This is the proportionality coefficient. (meaning average particle length); in addition, to improve computational efficiency, split Gaussian filtering (horizontal first, then vertical) or approximate box filtering can be used instead to adapt to the real-time requirements of embedded vision processors.
[0078] It should be noted that this normalization is not a simple global brightness stretching, but a local reflectance restoration based on Retinex theory. Its core idea is to restore the observed brightness. It is decomposed into "illuminance × reflectance", and the true color of rice seeds is determined by surface reflectance, which is independent of external light; by suppressing the illuminance component, It can more realistically reflect the material and aging state of the rice surface, and significantly reduce misjudgments caused by light interference (for example, misjudging shadow areas as mold spots).
[0079] S603, Calculate normalized brightness Standard deviation and color channels The standard deviation.
[0080] S604, will Standard deviation and The standard deviations are linearly combined according to preset weights to obtain the color abnormality index. : ; in, , The weighting coefficients are set according to the rice variety.
[0081] It should be noted that this scheme is based on the fact that color defects in rice typically manifest in two main characteristics: uneven local light and dark areas (such as spots caused by aging or mold) and color shifts (such as yellowing or browning). Normalized lightness This reflects the spatial uniformity of surface reflectivity; a larger standard deviation indicates the presence of obvious dark spots or localized blackened areas. The standard deviation of the channel characterizes the dispersion of hue changes. When rice becomes moldy or suffers heat damage, it often exhibits localized yellowing or abnormal yellow-blue transitions, leading to... Significantly increased. This was achieved by introducing variety-related weighting coefficients. and The system can dynamically adjust its discrimination focus based on the differences in the sensitivity of different rice varieties to brightness and color (e.g., indica rice is more prone to yellowing, while japonica rice is more prone to darkening with age), achieving high-precision and multi-variety compatible color anomaly detection. This method avoids the limitations of single-parameter judgment, takes into account both the "uneven brightness" and "color abnormality" defects, and improves the robustness and adaptability of the sorting system.
[0082] Based on the above technical solutions, in rice seed sorting, traditional colorimetric analysis often directly uses the mean value of RGB or HSV color space for discrimination. This is easily affected by uneven ambient lighting, conveyor belt reflections, or lens vignetting, leading to normal shaded areas being misjudged as mold or aging, severely impacting sorting accuracy. Furthermore, a single color parameter cannot fully reflect the complexity of color anomalies; for example, localized darkening and yellowing often coexist, requiring combined characterization. This technical solution converts the surface pixel area to the CIELAB color space, leveraging its device independence and perceptual uniformity to extract the lightness channel. With chroma channels Large-scale Gaussian filtering is used for... Perform local illuminance estimation and illuminance normalization to obtain... Effectively eliminates light interference and restores true reflectivity information; calculates... and The standard deviations of these values represent the degree of unevenness in brightness and hue shift, respectively, and are weighted by preset parameters. , Linear combination generates color anomaly index This method not only achieves the collaborative detection of "spots and dark spots" and "localized yellowing," but also improves the discrimination accuracy through variety-adaptive weight adjustment. Compared with traditional methods, this scheme significantly enhances the sensitivity and anti-interference ability to complex color change defects, and is suitable for intelligent sorting systems with multiple scenarios and varieties, effectively reducing the false rejection rate and the missed detection rate.
[0083] The above mainly describes the solutions of the embodiments of this application from the perspective of device implementation. It is understood that each device, such as a rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics, includes at least one of the hardware structures and software modules corresponding to each function in order to achieve the above-mentioned functions. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0084] This application embodiment can divide the rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics into functional units according to the above method example. For example, each function can be divided into different functional units, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or software functional units. It should be noted that the unit division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0085] When using integrated units, Figure 4 The diagram shows a possible structural schematic of the rice seed precision sorting device (referred to as sorting device 50) based on the fusion analysis of grain shape and color characteristics involved in the above embodiments. The sorting device 50 includes a processing unit 502 and a communication unit 501, and may also include a storage unit 503. Figure 4The schematic diagram shown can be used to illustrate the structure of the rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics involved in the above embodiments.
[0086] when Figure 4 The schematic diagram shown illustrates the structure of the rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics involved in the above embodiments. The processing unit 502 is used to control and manage the operation of the rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics. The communication unit 501 is used for the rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics to communicate with other devices. The storage unit 503 is used to store the program code and data of the rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics.
[0087] For example, the communication unit 501 is used to acquire a color image of the rice seeds to be sorted, and to perform single-grain segmentation of the rice seeds to be sorted, extracting the outline of each single grain and its corresponding surface pixel area. Processing unit 502 is used to calculate the grain shape anomaly index of each individual rice seed based on the contour. Based on the surface pixel region, local illuminance normalization is performed on the brightness channel in CIELAB space, and based on the statistical characteristics of the normalized brightness and chromaticity channels, the color abnormality index of each single rice grain is calculated. The grain shape abnormality index and the color abnormality index are input into a pre-trained lightweight fusion model, and the comprehensive quality score of each individual rice grain is output.
[0088] In one possible implementation, the processing unit 502 is further configured to input the grain shape anomaly index and the color anomaly index into a pre-trained lightweight fusion model and output the comprehensive quality score of each individual rice grain.
[0089] The processing unit 502 can be a processor or a controller, and the communication unit 501 can be a communication interface, transceiver, transceiver circuit, transceiver device, etc. The term "communication interface" is a general term and may include one or more interfaces. The storage unit 503 can be a memory. When the sorting device 50 is a chip, the processing unit 502 can be a processor or a controller, and the communication unit 501 can be an input interface and / or an output interface, pins, or circuits, etc. The storage unit 503 can be a storage unit within the chip (e.g., a register, cache, etc.) or a storage unit located outside the chip (e.g., read-only memory (ROM), random access memory (RAM, etc.).
[0090] The communication unit can also be called a transceiver unit. The antenna and control circuit with transceiver functions in the sorting device 50 can be considered as the communication unit 501 of the sorting device 50, and the processor with processing functions can be considered as the processing unit 502 of the sorting device 50. Optionally, the device in the communication unit 501 that implements the receiving function can be considered as the communication unit. The communication unit is used to execute the receiving steps in the embodiments of this application, and the communication unit can be a receiver, a receiver circuit, etc. The device in the communication unit 501 that implements the transmitting function can be considered as the transmitting unit. The transmitting unit is used to execute the transmitting steps in the embodiments of this application, and the transmitting unit can be a transmitter, a transmitter, a transmitting circuit, etc.
[0091] Figure 4 If the integrated units in the process 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 solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, 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.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. Storage media for storing computer software products include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.
[0092] Figure 4 The units in the process can also be called modules; for example, a processing unit can be called a processing module.
[0093] This application also provides a hardware structure diagram of a rice seed precision sorting device (denoted as sorting device 60) based on the fusion analysis of grain shape and color characteristics, see [link to relevant documentation]. Figure 5 The sorting device 60 includes a processor 601, and optionally, a memory 602 connected to the processor 601.
[0094] In the first possible implementation, see Figure 5 The sorting device 60 also includes a transceiver 603. The processor 601, memory 602, and transceiver 603 are connected via a bus. The transceiver 603 is used to communicate with other devices or communication networks. Optionally, the transceiver 603 may include a transmitter and a receiver. The device in the transceiver 603 that implements the receiving function can be considered as a receiver, which is used to perform the receiving steps in the embodiments of this application. The device in the transceiver 603 that implements the transmitting function can be considered as a transmitter, which is used to perform the transmitting steps in the embodiments of this application.
[0095] Based on the first possible implementation method Figure 5 The schematic diagram shown can be used to illustrate the structure of the rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics involved in the above embodiments.
[0096] in, Figure 5 The diagram also illustrates the system chip in a rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics. In this case, the actions performed by the aforementioned rice seed precision sorting device based on the fusion analysis of grain shape and color characteristics can be implemented by this system chip. The specific actions performed are described above and will not be repeated here.
[0097] Some of the data in the above formula are calculated by removing dimensions and taking their numerical values. The formula is the closest to the real situation obtained by software simulation of a large amount of collected data. The preset parameters and preset thresholds in the formula are set by those skilled in the art according to the actual situation or obtained through simulation of a large amount of data.
Claims
1. A precise rice seed sorting method based on the fusion analysis of grain shape and color characteristics, characterized in that, include: Acquire color images of rice seeds to be sorted, and perform single-grain segmentation on the rice seeds to be sorted, extracting the contour of each single grain and its corresponding surface pixel region; Based on the contour, the grain shape anomaly index of each individual rice seed is calculated. The grain shape anomaly index is obtained by coupling the local curvature change of the contour with the cumulative area distribution along the contour, which characterizes the structural defect status of the rice seed. Based on the surface pixel region, local illuminance normalization is performed on the brightness channel in CIELAB space, and based on the statistical characteristics of the normalized brightness and chromaticity channels, the color abnormality index of each single rice seed is calculated; the color abnormality index is used to characterize the color abnormality of the rice seed surface. The grain shape abnormality index and the color abnormality index are input into the pre-trained lightweight fusion model, and the comprehensive quality score of each single grain of rice is output. The overall quality score is compared with a set score threshold. If the overall quality score is less than the score threshold, the corresponding single grain of rice is determined to be an unqualified variety, and the execution mechanism is triggered to remove it from the normal flow path.
2. The method for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics according to claim 1, characterized in that, The process of single-grain separation of the rice seeds to be sorted includes: The color image is input into a pre-trained lightweight instance segmentation network to generate multiple initial rice seed masks; each initial rice seed mask corresponds to a potential rice seed region. Fit the minimum bounding ellipse for each initial rice seed mask and calculate its ellipticity and area; If the area of any of the initial rice seed masks is greater than the preset upper limit of single grain area and its ellipticity is less than the first threshold, then the mask is determined to correspond to the adhered rice seed, and based on the geometric constraints of the contour concave point position and the minimum circumscribed ellipse, the mask is split into two or more sub-masks. If the area of any of the initial rice seed masks is less than the preset lower limit of single seed area and there are no adjacent masks, it is considered noise and is removed. All masks retained after splitting and noise removal are considered as single-particle segmentation results.
3. The method for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics according to claim 2, characterized in that, The extraction of the contour of each individual rice seed and its corresponding surface pixel region includes: For each individual segmentation mask, perform morphological closing operations sequentially to eliminate internal holes; Based on the processed mask, a sub-pixel edge localization method is used to extract a closed contour point sequence as the geometric contour of the rice seed. Define the surface pixel region of the rice seed by the set of all pixels with a value of 1 in the mask; Establish a unique correspondence between the geometric contour and the surface pixel region.
4. The method for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics according to claim 1, characterized in that, The calculation of grain shape anomaly indicators for each individual rice seed includes: The rice grain outline is parameterized using arc length. The independent variable is a plane curve, and samples are uniformly taken from this curve. One point; For each sampling point Calculate its local curvature and from the starting point of the outline to The directed cumulative area enclosed Where i is the index of the sampling point, i=1,2,…n; A normalized weight distribution is constructed based on the product of the curvature and the cumulative area: ; in, and ; Calculate the Shannon entropy of this distribution as an indicator of grain size anomalies. : 。 5. The method for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics according to claim 4, characterized in that, The local curvature ,include: With sampling points Centered on the arc-length parameterized profile, select the areas before and after it. A set of 3 neighboring points constitutes a local point set; The local point set is aligned in coordinate system: the direction of the principal axis of the smallest circumscribed ellipse of the rice outline is used as the reference direction, and the local point set is rotated to make its principal direction horizontal; In the aligned local coordinate system, a quadratic polynomial curve is fitted using the least squares method. Where (x,y) are the coordinates of a local point, and a, b, and c are the coefficients of the curve fitting. Calculate sampling points based on the fitting coefficients. Directed curvature at: 。 6. The method for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics according to claim 4, characterized in that, The directed cumulative area ,include: The outline of the rice grains is oriented to be corrected so that it traverses in a counterclockwise direction; The starting point of the contour is repositioned to the right endpoint of the major axis of the least circumscribed ellipse, based on the repositioned sequence of contour points. Calculate from the starting point of the contour to the first... The directed cumulative area of each sampling point : ; in, The sampling point number is... , Let K be the coordinates of the kth sampling point. The coordinates of the (k+1)th sampling point.
7. The method for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics according to claim 1, characterized in that, The calculation of color abnormality indicators for each individual rice grain includes: The surface pixel area is converted to the CIELAB color space to obtain the brightness channel. and chroma channels ; Large-scale Gaussian filtering is used for the above Perform local illuminance estimation, and adjust the luminance channel based on the estimation results. Perform illuminance normalization to obtain normalized luminance. ; Calculate the normalized brightness The standard deviation and the chromaticity channel Standard deviation; Normalize brightness Standard deviation and color channels The standard deviations are linearly combined according to preset weights to obtain the color abnormality index. : ; in, , The weighting coefficients are set according to the rice variety.
8. The method for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics according to claim 1, characterized in that, The method for constructing the pre-trained lightweight fusion model includes: Multiple varieties of rice samples were collected, and based on the expert visual grading results, each sample was assigned a corresponding comprehensive quality label, which is a continuous value or a binary category between 0 and 1. Calculate the grain shape and color abnormality indices corresponding to each rice variety sample to form training sample pairs; wherein, the input features are the two abnormality indices and the supervision signal is the comprehensive quality label. The training sample pairs are divided into a training set and a validation set, and a lightweight regression model is trained using the training set so that the model outputs the comprehensive quality label. The lightweight regression model after training convergence is the lightweight fusion model, which is used to fuse the abnormal grain shape and color indicators of new rice samples and output the corresponding comprehensive quality score.
9. The method for precise rice seed sorting based on the fusion analysis of grain shape and color characteristics according to claim 1, characterized in that, The method for obtaining the score threshold includes: Obtain the overall quality score of the qualified samples in the current batch to get the score set; Calculate the mean of the score set. and standard deviation ; Through formula Calculate the score threshold ;in, This is the preset confidence coefficient.
10. A precise rice seed sorting device based on the fusion analysis of grain shape and color characteristics, operating based on the precise rice seed sorting method based on the fusion analysis of grain shape and color characteristics as described in any one of claims 1-9, characterized in that, It includes a quality assessment unit, as well as segmentation and discrimination units connected to it; The segmentation unit is used to acquire a color image of the rice seeds to be sorted, and to perform single-grain segmentation on the rice seeds to be sorted, extracting the outline of each single grain and its corresponding surface pixel area. The quality assessment unit is used to calculate the grain shape abnormality index of each individual rice variety based on the outline. Based on the surface pixel region, local illuminance normalization is performed on the brightness channel in CIELAB space, and based on the statistical characteristics of the normalized brightness and chromaticity channels, the color abnormality index of each single rice grain is calculated. The grain shape abnormality index and the color abnormality index are input into the pre-trained lightweight fusion model, and the comprehensive quality score of each single grain of rice is output. The discrimination unit is used to compare the comprehensive quality score with a set score threshold. If the comprehensive quality score is less than the score threshold, the corresponding single rice seed is determined to be an unqualified variety, and the execution mechanism is triggered to remove it from the normal flow path.