A wheat bulk density detection method and system fusing image features and physical and chemical parameters
By integrating the morphological and textural features and physicochemical parameters of wheat grains, constructing a complementary feature set, and employing a multilayer perceptron model, the problems of cumbersome operation, high sample consumption, and limited accuracy in wheat bulk density detection were solved, achieving efficient and accurate bulk density prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-03-31
AI Technical Summary
Existing wheat bulk density detection technologies are cumbersome to operate, consume large amounts of samples, have limited accuracy, cannot achieve continuous value output, and have weak correlation between image features and the physical mechanism of bulk density, thus limiting prediction accuracy.
By integrating the morphological characteristics (minor axis length, aspect ratio, and spread) and texture characteristics (uniformity and texture entropy) of wheat grains with key physicochemical parameters (moisture content, imperfect grain content, and thousand-grain weight), a complementary fusion feature set is constructed, and bulk density is predicted using a multilayer perceptron model.
It enables rapid, accurate, and non-destructive testing of wheat bulk density, reduces sample consumption, and improves testing efficiency and prediction accuracy, making it suitable for the rapid identification of valuable breeding materials and scientific research samples.
Smart Images

Figure CN121438005B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of grain testing technology, specifically to a method and system for detecting wheat bulk density by integrating image features and physicochemical parameters. Background Technology
[0002] Wheat bulk density is a key indicator for evaluating wheat quality and grading, directly affecting processing quality and storage safety. Traditional wheat bulk density measurement relies primarily on standard bulk density meters (such as the HGT-1000 or GHCS-1000 grain bulk density meters). While widely used, this method has significant limitations in practical application: First, the process is cumbersome, requiring multiple steps such as sieving impurities, mixing samples, installing and adjusting the instrument, and weighing repeatedly, making the entire process time-consuming and labor-intensive. Second, it requires a large sample volume, typically about 1 kg per measurement, which is too costly for valuable breeding materials or small batches of research samples. Furthermore, this method is highly dependent on manual operation; from sample preparation to instrument adjustment and final reading, technical personnel are required, leading to inefficiency and susceptibility to human error, affecting the accuracy and repeatability of the results.
[0003] To overcome the shortcomings of traditional methods, existing technologies attempt to introduce image processing techniques to achieve rapid and non-destructive testing. This involves classifying bulk density grades by analyzing image features of the grains. However, this approach has two significant drawbacks: First, existing technologies can only classify bulk density into high, medium, and low grades, failing to output continuous, specific bulk density values, thus making it difficult to meet the practical needs of modern grain quality inspection for precise quantitative indicators. Second, the image features used in existing technologies are mostly general basic geometric features and texture features representing macroscopic contrasts. These features have weak correlation with the physical mechanisms of wheat bulk density formation, resulting in insufficient specificity and effectiveness of feature representation. Furthermore, existing technologies prioritize speed and non-destructiveness, while the determination of physicochemical parameters requires specialized instruments and destructive sampling. Therefore, they typically rely solely on image features, failing to recognize the potential complementary relationships between key physicochemical parameters such as moisture content, imperfect grain content, and thousand-grain weight and image features. This leads to insufficient dimensionality of the model's input information, limiting the improvement of prediction accuracy.
[0004] In summary, the existing technologies suffer from problems such as cumbersome operation, high sample consumption, limited prediction accuracy, and inability to achieve continuous value output. These issues have become key bottlenecks restricting the improvement of automation levels and the optimization of operational efficiency in wheat quality testing. Therefore, developing an accurate, rapid, low-sample-consumption, non-contact method for determining wheat bulk density has significant practical implications and application value. Summary of the Invention
[0005] This invention aims to solve the problems of cumbersome operation, high sample consumption, and limited accuracy of existing bulk density detection technologies, and proposes a method and system for detecting wheat bulk density that integrates image features and physicochemical parameters.
[0006] The technical solution adopted by the present invention to solve the above-mentioned technical problems is as follows:
[0007] In a first aspect, the present invention provides a method for detecting wheat bulk density by fusing image features and physicochemical parameters, the method comprising:
[0008] Wheat samples were obtained, and their physicochemical parameters and true bulk density were measured. The physicochemical parameters included moisture content, imperfect grain content, and thousand-grain weight. Simultaneously, images of the wheat grains were acquired.
[0009] The grain images are preprocessed to extract the morphological and textural features of each wheat grain, wherein the morphological features include minor axis length, aspect ratio and spread, and the textural features include uniformity and texture entropy.
[0010] The average morphological features of the wheat sample are obtained by calculating the average value of the morphological features corresponding to each wheat grain, and the average texture features of the wheat sample are obtained by calculating the average value of the texture features corresponding to each wheat grain.
[0011] The measured physicochemical parameters are combined with the average morphological features and average texture features to form a fused feature set;
[0012] Using the fused feature set as input and the actual bulk density as output, a bulk density prediction model is constructed and trained.
[0013] The trained bulk density prediction model was used to detect the bulk density of wheat samples to be tested.
[0014] Further, the grain images are preprocessed to extract the morphological and textural features of each wheat grain, including:
[0015] The RGB format seed image is converted to a grayscale image. After Gaussian blurring, the grayscale image is binarized using the OTSU algorithm to obtain a binary image. Morphological opening operation is used to remove small noise regions in the binary image. The largest connected region is extracted from the denoised binary image as the first target seed region, and the corresponding mask image is generated.
[0016] Geometric analysis is performed on the first target grain region to calculate the morphological features of wheat grains; based on the mask image, a second target grain region is determined from the grayscale image; a grayscale co-occurrence matrix is constructed based on the grayscale image of the second target grain region; and the texture features of wheat grains are calculated based on the grayscale co-occurrence matrix.
[0017] Furthermore, the minor axis length is defined as the shortest diameter of the equivalent ellipse having the same second moment as the first target grain region. The minor axis length is calculated as follows:
[0018] ;
[0019] in, Indicates the length of the minor axis. The smallest eigenvalue of the second-order moment matrix representing the equivalent ellipse;
[0020] The aspect ratio is defined as the ratio of the major axis length to the minor axis length, and the major axis length is defined as the longest diameter of the equivalent ellipse. The formula for calculating the aspect ratio is as follows:
[0021] , ;
[0022] in, Indicates the aspect ratio. Indicates the length of the major axis. The largest eigenvalue of the second-order moment matrix representing the equivalent ellipse;
[0023] The extension is defined as the ratio of the area of the first target grain region to the area of its smallest bounding rectangle. The formula for calculating the extension is as follows:
[0024] ;
[0025] in, Indicates the degree of stretch. This represents the area of the first target seed region, which is the total number of pixels within the first target seed region. and These represent the coordinates of the top-left corner and the bottom-right corner of the smallest bounding rectangle, respectively.
[0026] Furthermore, the formula for calculating the uniformity is as follows:
[0027] ;
[0028] in, Indicates uniformity. Indicates the position of the gray-level co-occurrence matrix. The element value on, and Indicates grayscale level;
[0029] The formula for calculating the texture entropy is as follows:
[0030] ;
[0031] in, Represents texture entropy.
[0032] Furthermore, the construction of the bulk density prediction model also includes:
[0033] Using the same fused feature set, support vector regression model, gradient boosting regression tree model and multilayer perceptron model were constructed respectively. The grid search method was used to optimize the parameters of each model, and the optimal parameter combination of each model was determined by cross-validation on the training set. Based on the prediction results on the test set, the model with the smallest root mean square error and the coefficient of determination closest to 1 was selected as the final weight prediction model.
[0034] Furthermore, the bulk density prediction model is a multilayer perceptron model, and the network structure of the multilayer perceptron model is as follows:
[0035] Input layer: Contains 8 neurons, used to receive 8 fused features from the fused feature set;
[0036] Hidden layers: There are two layers. The first hidden layer contains 100 neurons and the second hidden layer contains 50 neurons. Both layers use the ReLU function as the activation function to perform non-linear mapping and high-order feature extraction on the input fusion features.
[0037] Output layer: Contains 1 neuron, using a linear activation function, to output continuous predicted values of wheat bulk density.
[0038] Furthermore, during the training process of the multilayer perceptron model, the LBFGS algorithm is used as the optimizer, and an L2 regularization mechanism is introduced, wherein the regularization coefficient is set to 0.1; the initial learning rate is set to 0.001, the maximum number of iterations is set to 500, and the random seed is set to 42; and an early stopping strategy is adopted to monitor the performance of the validation set. When the validation set loss does not decrease in 20 consecutive iterations, the training is automatically terminated.
[0039] Furthermore, the trained bulk density prediction model is used to detect the bulk density of the wheat samples to be tested, including:
[0040] The physicochemical parameters of the wheat samples to be tested were determined, and images of the grains of the wheat samples to be tested were acquired;
[0041] The images of wheat grains to be tested are preprocessed to extract the morphological and texture features of each wheat grain, and the average morphological and texture features of the wheat samples to be tested are calculated.
[0042] The physicochemical parameters of the wheat sample to be tested are combined with the average morphological features and average texture features to form a fusion feature set of the wheat sample to be tested;
[0043] The fused feature set of the wheat sample to be tested is input into the trained bulk density prediction model to obtain the predicted bulk density value of the wheat sample to be tested.
[0044] Furthermore, obtaining wheat samples includes:
[0045] Wheat samples of different test weight grades were obtained from different wheat-producing areas, and the test weight of the wheat samples covered the entire test weight range from grade one to grade five.
[0046] Secondly, the present invention provides a wheat bulk density detection system that integrates image features and physicochemical parameters, for implementing the wheat bulk density detection method that integrates image features and physicochemical parameters as described in the first aspect, the system comprising:
[0047] The data acquisition module is used to acquire wheat samples and determine the physicochemical parameters and true bulk density of the wheat samples, including moisture content, imperfect grain content, and thousand-grain weight; at the same time, it acquires images of the grains of the wheat samples.
[0048] The feature extraction module is used to preprocess the grain image, extract the morphological and texture features of each wheat grain, wherein the morphological features include minor axis length, aspect ratio and spread, and the texture features include uniformity and texture entropy; calculate the average value of the morphological features corresponding to each wheat grain to obtain the average morphological features of the wheat sample, and calculate the average value of the texture features corresponding to each wheat grain to obtain the average texture features of the wheat sample.
[0049] The feature fusion module is used to merge the measured physicochemical parameters with the average morphological features and average texture features to form a fused feature set;
[0050] The model building module is used to build and train a weight prediction model with the fused feature set as input and the true weight as output.
[0051] The bulk density prediction module is used to detect the bulk density of wheat samples to be tested using a trained bulk density prediction model.
[0052] The beneficial effects of this invention are as follows: By fusing morphological features (minor axis length, aspect ratio, and spread) and texture features (uniformity and texture entropy) closely related to the physical mechanism of bulk density, and performing cross-domain feature fusion with key physicochemical parameters (moisture content, imperfect grain content, and thousand-grain weight), this invention constructs a complementary fusion feature set. This overcomes the technical bottleneck of existing image detection methods, which suffer from limited prediction accuracy due to single feature dimensions and weak correlation with the bulk density formation mechanism. Simultaneously, by calculating the average value of multiple grain feature values, the invention effectively eliminates the random differences of individual grains, significantly improving the representativeness and stability of the feature data. Furthermore, this invention requires only a small number of sample images to complete the detection, greatly reducing sample consumption, making it particularly suitable for the rapid identification of valuable breeding materials and small-scale research samples. The entire detection process does not require complex manual operation or a dedicated bulk density meter, significantly improving detection efficiency and reducing labor costs and dependence on specialized equipment. In addition, this invention achieves continuous prediction of wheat bulk density based on multi-source information fusion, providing an efficient, accurate, and low-cost automated solution for wheat quality detection. Attached Figure Description
[0053] Figure 1 A flowchart illustrating the wheat bulk density detection method that integrates image features and physicochemical parameters, provided in this embodiment;
[0054] Figure 2 A schematic diagram illustrating the extraction process of morphological and texture features provided for this embodiment;
[0055] Figure 3 Histogram of prediction error distribution of the bulk density prediction model provided in the embodiment;
[0056] Figure 4 A scatter plot of the predicted and actual values of the bulk density prediction model provided in the example;
[0057] Figure 5 This is a schematic diagram of the structure of a wheat bulk density detection system that integrates image features and physicochemical parameters, provided as an example. Detailed Implementation
[0058] Existing image detection methods, when applied to bulk density detection, mostly treat bulk density prediction as a classification problem, failing to output specific, continuous bulk density values. Furthermore, the image features used in existing technologies have a weak correlation with the physical mechanism of wheat bulk density formation, resulting in insufficient specificity and effectiveness of feature representation. In addition, existing methods rely solely on image features, leading to incomplete model input information and poor prediction accuracy.
[0059] Based on this, the technical solution of this invention is proposed. In this invention, wheat grain images are collected and morphological features (minor axis length, aspect ratio, and spread) and texture features (uniformity and texture entropy) strongly correlated with the physical mechanism of bulk density are extracted. These features are then fused with key physicochemical parameters such as moisture content, imperfect grain content, and thousand-grain weight to construct a complementary fused feature set. By averaging the features of multiple grains, a stable feature vector representing the overall characteristics of the sample is formed. Finally, a regression model is trained based on this fused feature set, thereby achieving accurate prediction of bulk density from two dimensions: wheat appearance image features and internal physicochemical properties. This effectively solves the technical problems of existing technologies, such as single feature dimension, weak correlation with physical mechanism, and inability to output continuous bulk density values.
[0060] The technical solutions in this embodiment 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.
[0061] Figure 1 A flowchart illustrating a method for detecting wheat bulk density by fusing image features and physicochemical parameters is shown. Please refer to [link / reference]. Figure 1 The method includes the following steps:
[0062] Step 1: Obtain wheat samples and determine the physicochemical parameters and true bulk density of the wheat samples. The physicochemical parameters include moisture content, imperfect grain content, and thousand-grain weight. At the same time, acquire images of the wheat grains.
[0063] In this embodiment, multiple wheat samples with different bulk density grades are obtained from different wheat-producing areas. The bulk density of the wheat samples covers the entire bulk density range from grade one to grade five, ensuring the universality of model training.
[0064] In practical applications, after wheat samples are sieved, their true bulk density is measured using a grain bulk density meter as the training target for the model. Simultaneously, the moisture content of the samples is determined using a grain moisture meter, and the imperfect grain content and grain images are obtained using an imperfect grain detector. Then, based on the sample weight and the number of grains provided by the imperfect grain detector, the thousand-grain weight is calculated using the formula "thousand-grain weight = sample weight ÷ number of grains × 1000", thus completing the determination of three physicochemical parameters: moisture content, imperfect grain content, and thousand-grain weight. At the same time, a representative 50g sample is accurately dispensed using an automatic sampler, and grain images are acquired using an imperfect grain detector.
[0065] The aforementioned physicochemical parameters are physically related to wheat bulk density: 1000-grain weight, as a positive core indicator, directly reflects grain plumpness and material accumulation, and is strongly positively correlated with bulk density; imperfect grain content, as a negative quality indicator, leads to decreased density and increased packing voids, and is significantly negatively correlated with bulk density; moisture content, as a key correction factor, affects grain density and flowability, and is negatively correlated with bulk density. These three parameters together constitute a complete physicochemical parameter system describing the bulk density formation mechanism, providing indispensable intrinsic attribute information for accurate prediction.
[0066] Step 2: Preprocess the grain image to extract the morphological and texture features of each wheat grain. The morphological features include minor axis length, aspect ratio, and spread, and the texture features include uniformity and texture entropy.
[0067] Please see Figure 2 In this embodiment, step 2 specifically includes steps 21 and 22:
[0068] Step 21: Convert the RGB format seed image to a grayscale image, perform Gaussian blur processing on the grayscale image, and then perform binarization processing based on the OTSU algorithm to obtain a binary image; use morphological opening operation to remove small noise regions in the binary image; extract the largest connected region from the denoised binary image as the first target seed region, and generate the corresponding mask image.
[0069] This step progressively improves the signal-to-noise ratio and achieves target segmentation through a multi-stage image processing workflow, laying the foundation for subsequent feature extraction. Specifically, firstly, the RGB image is converted to grayscale and Gaussian blurred to suppress noise. Then, the OTSU algorithm is used to achieve accurate binarization segmentation of the background and seeds. Next, morphological opening operations are performed to eliminate minor noise interference. Finally, the largest connected region is extracted to generate a mask for precise location of individual seeds.
[0070] Step 22: Perform geometric analysis on the first target grain region to calculate the morphological features of wheat grains; determine the second target grain region from the grayscale image based on the mask image; construct a grayscale co-occurrence matrix based on the grayscale image of the second target grain region; and calculate the texture features of wheat grains based on the grayscale co-occurrence matrix.
[0071] Based on the achievement of target segmentation, this step calculates morphological features such as the minor axis length reflecting grain plumpness, the aspect ratio characterizing the shape profile, and the extensibility describing filling efficiency, based on the geometric moment theory.
[0072] The minor axis length is defined as the shortest diameter of the equivalent ellipse with the same second moment as the first target grain region. The minor axis length is calculated as follows:
[0073] ;
[0074] in, Indicates the length of the minor axis. The smallest eigenvalue represents the second-order moment matrix of the equivalent ellipse.
[0075] The aspect ratio is defined as the ratio of the major axis length to the minor axis length, and the major axis length is defined as the longest diameter of the equivalent ellipse. The formula for calculating the aspect ratio is as follows:
[0076] , ;
[0077] in, Indicates the aspect ratio. Indicates the length of the major axis. The largest eigenvalue represents the second-order moment matrix of the equivalent ellipse.
[0078] The extension is defined as the ratio of the area of the first target grain region to the area of its smallest bounding rectangle. The formula for calculating the extension is as follows:
[0079] ;
[0080] in, Indicates the degree of stretch. This represents the area of the first target seed region, which is the total number of pixels within the first target seed region. and These represent the coordinates of the top-left corner and the bottom-right corner of the smallest bounding rectangle, respectively.
[0081] Meanwhile, based on the target segmentation, the second target seed region is extracted from the original grayscale image using a mask, and the uniformity of the grayscale uniformity of the seed surface and the texture entropy reflecting the structural complexity are quantified by the grayscale co-occurrence matrix (GLCM).
[0082] The formula for calculating the uniformity is as follows:
[0083] ;
[0084] in, Indicates uniformity. Indicates the position of the gray-level co-occurrence matrix. The element value on, and Indicates grayscale level.
[0085] The formula for calculating the texture entropy is as follows:
[0086] ;
[0087] in, Represents texture entropy.
[0088] In terms of morphological characteristics, the length of the minor axis is positively correlated with the bulk density. A longer minor axis usually means that the kernels are fuller and more compact, and they can form a denser arrangement during the stacking process. The length-to-width ratio is mostly negatively correlated with the bulk density. Slender kernels with a higher length-to-width ratio are more likely to form more gaps during natural stacking, reducing the filling efficiency per unit volume. The extension is significantly positively correlated with the bulk density. This feature directly reflects the degree to which the kernel fills its smallest bounding rectangle. The higher the extension, the fuller and more regular the kernel shape and the denser the internal structure.
[0089] Among the texture features, uniformity is positively correlated with bulk density, representing the consistency of grain surface texture. Higher uniformity indicates well-developed grains and homogeneous internal structure. Texture entropy is negatively correlated with bulk density. Higher texture entropy values reflect the complexity and disorder of grain surface texture, which is usually related to structural defects such as wrinkling and damage. These defects directly lead to a decrease in grain density.
[0090] The above steps comprehensively capture the physical morphology and surface structure characteristics of the grains through multi-dimensional feature extraction, providing a stable and reliable image feature input for subsequent fusion prediction, and effectively solving the problem of incomplete feature representation in traditional methods.
[0091] Step 3: Calculate the average value of the morphological features corresponding to each wheat grain to obtain the average morphological features of the wheat sample. Calculate the average value of the texture features corresponding to each wheat grain to obtain the average texture features of the wheat sample.
[0092] This step calculates the morphological characteristics (minor axis length, aspect ratio, and spread) and texture characteristics (uniformity and texture entropy) of each wheat grain in the sample. Then, it calculates the arithmetic mean of the same characteristics for all grains within the same sample, thereby obtaining the average morphological characteristics (average minor axis length, average aspect ratio, and average spread) and average texture characteristics (average uniformity and average texture entropy) representing the overall characteristics of the sample. By utilizing the central tendency of the population characteristics, random errors caused by individual variations, pose differences, or accidental imaging factors in individual grains are eliminated, ensuring that the final feature values can stably and reliably represent the overall attributes of the sample, significantly improving the representativeness and robustness of the feature data.
[0093] Step 4: Combine the measured physicochemical parameters with the average morphological features and average texture features to form a fused feature set.
[0094] In practical applications, by using data stitching, the measured physicochemical parameters of moisture content, imperfect grain content, and thousand-grain weight are combined with the calculated morphological features of average minor axis length, average aspect ratio, and average spread, as well as the texture features of average uniformity and average texture entropy, forming a fusion feature set containing eight features. This constructs a multi-dimensional feature space that can simultaneously reflect the external physical morphology, internal structural characteristics, and key material properties of wheat samples, achieving a comprehensive characterization of factors affecting bulk density. This fusion method significantly expands the information dimension of the model, enabling subsequent machine learning models to mine the synergistic influence of morphological features, texture features, and physicochemical parameters on bulk density based on more complete and complementary feature information, fundamentally solving the technical problem of limited prediction accuracy caused by a single data source.
[0095] Step 5: Using the fused feature set as input and the true bulk density as output, construct and train a bulk density prediction model.
[0096] In this embodiment, the construction of the bulk density prediction model also includes:
[0097] Using the same fused feature set, support vector regression model, gradient boosting regression tree model and multilayer perceptron model were constructed respectively. The grid search method was used to optimize the parameters of each model, and the optimal parameter combination of each model was determined by cross-validation on the training set. Based on the prediction results on the test set, the model with the smallest root mean square error and the coefficient of determination closest to 1 was selected as the final weight prediction model.
[0098] This embodiment uses a multi-model comparison and verification and parameter optimization mechanism to ensure that the selected model can fit the complex nonlinear mapping relationship between fusion features and tolerance to the greatest extent.
[0099] In practical applications, three candidate models—Support Vector Regression (SVR), Gradient Boosting Regression Tree (GBDT), and Multilayer Perceptron (MLP)—are first constructed in parallel using the same fused feature set. The hyperparameter space of each model is explored using a grid search method, and the optimal parameter combination for each model is determined by cross-validation on the training set. After the model is constructed based on the optimal parameters and trained on the training set, it is applied to the test set for performance verification. The final comparison results are shown in Table 1.
[0100] Table 1 Comparison of Model Performance Validation Results
[0101]
[0102] Ultimately, based on the prediction performance on the test set, the optimal weight prediction model was selected based on minimizing the root mean square error and having a coefficient of determination closest to 1. In Table 1, the Multilayer Perceptron (MLP) model showed the best prediction performance among the three, with a coefficient of determination closest to 1 on the test set. The value is closest to 1, and the root mean square error (RMSE) is the smallest, indicating that the model can effectively predict the test weight of wheat, and it is used as the final test weight prediction model.
[0103] The above process establishes a scientific and reliable model selection process, effectively avoiding the limitations of selecting a single model, thereby ensuring that the final bulk density prediction model has both optimal prediction accuracy and generalization ability, and providing core algorithm support for achieving accurate and stable wheat bulk density detection.
[0104] In this embodiment, the network structure of the multilayer perceptron model is as follows:
[0105] Input layer: Contains 8 neurons, used to receive 8 fusion features from the fusion feature set (moisture content, imperfect grain content, thousand-grain weight, average minor axis length, average aspect ratio, average stretch, average uniformity, and average texture entropy).
[0106] Hidden layers: There are two layers. The first hidden layer contains 100 neurons and the second hidden layer contains 50 neurons. Both layers use the ReLU function as the activation function to perform non-linear mapping and high-order feature extraction on the input fusion features.
[0107] Output layer: Contains 1 neuron, using a linear activation function, to output continuous predicted values of wheat bulk density.
[0108] The aforementioned multilayer perceptron model leverages the powerful nonlinear mapping capabilities of deep feedforward neural networks. It progressively extracts the complex interaction between fused features and bulk density through two hidden layers. The ReLU function ensures the model effectively learns nonlinear features while mitigating the gradient vanishing problem, while the linear output layer guarantees the final output conforms to the regression requirements of continuous physical quantities. This model accurately captures the synergistic influence mechanism of image features and physicochemical parameters on bulk density, thus exhibiting prediction accuracy close to that of traditional bulk density meters on the test set, achieving efficient and non-destructive intelligent bulk density detection.
[0109] In this embodiment, during the training process of the multilayer perceptron model, the LBFGS algorithm is used as the optimizer, and an L2 regularization mechanism is introduced, wherein the regularization coefficient is set to 0.1; the initial learning rate is set to 0.001, the maximum number of iterations is set to 500, and the random seed is set to 42; and an early stopping strategy is adopted to monitor the performance of the validation set. When the validation set loss does not decrease in 20 consecutive iterations, the training is automatically terminated.
[0110] Specifically, the LBFGS algorithm is used as the optimizer to minimize the prediction error and update the network weights; an L2 regularization mechanism is introduced with a regularization coefficient (alpha) of 0.1 to suppress model overfitting; the initial learning rate is set to 0.001 to control the step size of weight updates; the maximum number of iterations is set to 500 to ensure that the model has sufficient training iteration space; an early stopping strategy is adopted, which automatically terminates training when the validation set performance does not improve in 20 consecutive iterations to further avoid overfitting; and the random seed (random_state) is set to 42 to ensure the repeatability of the model training process.
[0111] Figure 3 This paper presents a histogram showing the prediction error distribution of a bulk density prediction model. Figure 3 As can be seen, the error distribution follows a normal distribution, indicating that the model's predictions are very accurate and stable. Figure 4 A scatter plot of predicted and actual values for a bulk density prediction model is shown. Figure 4 It can be seen that the prediction error of the vast majority of test samples is concentrated in the range of -3 to 3, indicating that the prediction effect is good.
[0112] Step 6: Use the trained bulk density prediction model to detect the bulk density of the wheat sample to be tested.
[0113] In practice, the trained bulk density prediction model is used to detect the bulk density of the wheat sample to be tested, including:
[0114] The physicochemical parameters of the wheat samples to be tested were determined, and images of the grains of the wheat samples to be tested were acquired;
[0115] The images of wheat grains to be tested are preprocessed to extract the morphological and texture features of each wheat grain, and the average morphological and texture features of the wheat samples to be tested are calculated.
[0116] The physicochemical parameters of the wheat sample to be tested are combined with the average morphological features and average texture features to form a fusion feature set of the wheat sample to be tested;
[0117] The fused feature set of the wheat sample to be tested is input into the trained bulk density prediction model to obtain the predicted bulk density value of the wheat sample to be tested.
[0118] Specifically, when testing the bulk density of wheat samples, the process first follows the same procedure as the model training phase, measuring three physicochemical parameters: moisture content, imperfect grain content, and thousand-grain weight, while simultaneously acquiring images of the grains. Then, standardized preprocessing is performed on these images to extract the morphological and textural features of each grain, and the average morphological and textural features representing the overall characteristics of the sample are calculated. Next, these physicochemical parameters are merged with the average image features to construct a fused feature set for the sample, perfectly matching the model's input dimensions. Finally, this feature set is input into the trained multilayer perceptron bulk density prediction model, directly outputting the predicted bulk density value for the unknown sample. This achieves rapid, automated, and non-destructive testing of wheat bulk density, obtaining continuous bulk density values with accuracy comparable to traditional bulk density meters in just a few minutes. It completely solves the technical bottlenecks of traditional methods, such as cumbersome operation, long processing time, and reliance on professional personnel, providing an efficient and reliable solution for grain quality inspection.
[0119] In summary, the wheat bulk density detection method integrating image features and physicochemical parameters provided in this embodiment constructs a complementary fusion feature set by fusing morphological features, texture features, and key physicochemical parameters of wheat grains. An optimized multilayer perceptron model is then used for regression prediction, achieving rapid, accurate, and non-destructive detection of wheat bulk density. This method significantly improves prediction accuracy while maintaining the high efficiency of image detection, requiring only a small number of samples to output continuous bulk density values. It effectively overcomes the technical bottlenecks of traditional methods, such as cumbersome operation, large sample requirements, and the inability of existing image technologies to achieve accurate quantitative prediction, providing an automated solution for wheat quality detection.
[0120] Based on the above technical solution, this embodiment also proposes a wheat bulk density detection system that integrates image features and physicochemical parameters, used to implement the wheat bulk density detection method that integrates image features and physicochemical parameters described in the embodiment. Please refer to [link to relevant documentation]. Figure 5 The system includes:
[0121] The data acquisition module is used to acquire wheat samples and determine the physicochemical parameters and true bulk density of the wheat samples, including moisture content, imperfect grain content, and thousand-grain weight; at the same time, it acquires images of the grains of the wheat samples.
[0122] The feature extraction module is used to preprocess the grain image, extract the morphological and texture features of each wheat grain, wherein the morphological features include minor axis length, aspect ratio and spread, and the texture features include uniformity and texture entropy; calculate the average value of the morphological features corresponding to each wheat grain to obtain the average morphological features of the wheat sample, and calculate the average value of the texture features corresponding to each wheat grain to obtain the average texture features of the wheat sample.
[0123] The feature fusion module is used to merge the measured physicochemical parameters with the average morphological features and average texture features to form a fused feature set;
[0124] The model building module is used to build and train a weight prediction model with the fused feature set as input and the true weight as output.
[0125] The bulk density prediction module is used to detect the bulk density of wheat samples to be tested using a trained bulk density prediction model.
[0126] It is understood that the wheat bulk density detection system that integrates image features and physicochemical parameters described in this embodiment is a system used to implement the wheat bulk density detection method that integrates image features and physicochemical parameters described in the embodiment. As the system disclosed in the embodiment corresponds to the method disclosed in the embodiment, the description is relatively simple. For relevant parts, please refer to the description of the method. It will not be repeated here.
Claims
1. A method for detecting the bulk density of wheat by fusing image features and physicochemical parameters, characterized in that, The method comprises: acquiring a wheat sample and measuring physical and chemical parameters and true bulk density of the wheat sample, the physical and chemical parameters including moisture content, immature grain content and thousand kernel weight; meanwhile, collecting grain images of the wheat sample; preprocessing the grain images, and extracting morphological features and texture features of each wheat kernel, wherein the morphological features include minor axis length, aspect ratio and elongation, and the texture features include uniformity and texture entropy; calculating average values of the morphological features corresponding to each wheat kernel to obtain average morphological features of the wheat sample, and calculating average values of the texture features corresponding to each wheat kernel to obtain average texture features of the wheat sample; merging the measured physical and chemical parameters, average morphological features and average texture features to form a fusion feature set; using the fusion feature set as input and the true bulk density as output, constructing and training a bulk density prediction model; detecting the bulk density of a to-be-detected wheat sample by using the trained bulk density prediction model; preprocessing the grain images, and extracting morphological features and texture features of each wheat kernel, comprising: converting the grain images in RGB format into grayscale images, performing Gaussian blur processing on the grayscale images, and then performing binarization processing based on the OTSU algorithm to obtain a binary image; removing small noise regions in the binary image by morphological opening operation; extracting a maximum connected region from the denoised binary image as a first target kernel region, and generating a corresponding mask image; performing geometric analysis on the first target kernel region to calculate the morphological features of the wheat kernel; determining a second target kernel region from the grayscale image based on the mask image, constructing a gray level co-occurrence matrix based on the grayscale image of the second target kernel region, and calculating the texture features of the wheat kernel according to the gray level co-occurrence matrix; the minor axis length is defined as the shortest diameter of an equivalent ellipse having the same second moment as the first target kernel region, and the minor axis length is calculated as follows: ; wherein, denotes the length of the short axis, denotes the minimum eigenvalue of the second moment matrix of the equivalent ellipse; the aspect ratio is defined as the ratio of the major axis length to the minor axis length, the major axis length is defined as the longest diameter of the equivalent ellipse, and the aspect ratio is calculated as follows: , ; wherein, denotes an aspect ratio, denotes a major axis length, denotes the largest eigenvalue of the second moment matrix of the equivalent ellipse; the elongation is defined as the ratio of the area of the first target kernel region to the area of its minimum circumscribed rectangle, and the elongation is calculated as follows: ; wherein, denotes the stretch, denotes the area of the first target kernel region, i.e. the total number of pixels within the first target kernel region, and denote the top-left corner coordinate and the bottom-right corner coordinate of the minimum bounding rectangle, respectively; the calculation formula of the uniformity is as follows: ; wherein, denotes the uniformity, denotes the element value of the gray level co-occurrence matrix at position , and denotes the gray level; the calculation formula of the texture entropy is as follows: ; wherein, represents the texture entropy.
2. The method for detecting the bulk density of wheat by fusing image features and physical and chemical parameters according to claim 1, characterized in that, when constructing the bulk density prediction model, further comprising: using the same fusion feature set to construct a support vector regression model, a gradient boosting regression tree model and a multilayer perception model respectively; performing parameter optimization on each model by using a grid search method, and determining the best parameter combination of each model by cross-validation on the training set; based on the prediction results on the test set, selecting the model with the smallest root mean square error and the closest coefficient of determination to 1 as the final bulk density prediction model.
3. The method for detecting the bulk density of wheat by fusing image features and physical and chemical parameters according to claim 1, characterized in that, the bulk density prediction model is a multilayer perception model, and the network structure of the multilayer perception model is as follows: input layer: containing 8 neurons for receiving 8 fusion features in the fusion feature set; The hidden layer includes two layers, the first hidden layer contains 100 neurons, the second hidden layer contains 50 neurons, and both layers use the ReLU function as an activation function for non-linear mapping and high-order feature extraction of the input fusion features; The output layer includes 1 neuron, uses a linear activation function, and is used for outputting a continuous prediction value of the wheat bulk density.
4. The method for detecting the bulk density of wheat by fusing image features and physical and chemical parameters according to claim 3, characterized in that, In the training process of the multi-layer perception model, the LBFGS algorithm is used as the optimizer, and the L2 regularization mechanism is introduced, wherein the regularization coefficient is set to 0.1; the initial learning rate is set to 0.001, the maximum number of iterations is set to 500 times, and the random seed is set to 42; and the early stopping strategy is used to monitor the performance of the validation set, and when the validation set loss does not decrease in 20 consecutive iterations, the training is automatically terminated.
5. The method for detecting the bulk density of wheat by fusing image features and physical and chemical parameters according to claim 1, characterized in that, The bulk density prediction model is used to detect the bulk density of the wheat sample to be detected, including: determining the physical and chemical parameters of the wheat sample to be detected, and collecting the grain image of the wheat sample to be detected; preprocessing the grain image of the wheat sample to be detected, extracting the morphological features and texture features of each wheat kernel, and calculating the average morphological features and average texture features of the wheat sample to be detected; combining the physical and chemical parameters, the average morphological features and the average texture features of the wheat sample to be detected to form a fusion feature set of the wheat sample to be detected; inputting the fusion feature set of the wheat sample to be detected into the trained bulk density prediction model to obtain the bulk density prediction value of the wheat sample to be detected.
6. The method for detecting the bulk density of wheat by fusing image features and physical and chemical parameters according to claim 1, characterized in that, The wheat sample includes: obtaining wheat samples of different bulk density grades from different wheat producing areas, and the bulk density of the wheat samples covers all bulk density ranges from first grade to fifth grade.
7. A wheat bulk density detection system fusing image features and physicochemical parameters, characterized in that, The system is used to realize the wheat bulk density detection method of fusing image features and physical and chemical parameters according to any one of claims 1 to 6, and the system includes: a data acquisition module for obtaining a wheat sample, determining the physical and chemical parameters and the true bulk density of the wheat sample, the physical and chemical parameters including moisture content, imperfect kernel content and thousand kernel weight; at the same time, collecting the grain image of the wheat sample; a feature extraction module for preprocessing the grain image, extracting the morphological features and texture features of each wheat kernel, wherein the morphological features include minor axis length, aspect ratio and elongation, and the texture features include uniformity and texture entropy; calculating the average value of the corresponding morphological features of each wheat kernel to obtain the average morphological features of the wheat sample, and calculating the average value of the corresponding texture features of each wheat kernel to obtain the average texture features of the wheat sample; a feature fusion module for merging the determined physical and chemical parameters, the average morphological features and the average texture features to form a fusion feature set; a model construction module for constructing and training a bulk density prediction model by taking the fusion feature set as input and the true bulk density as output; a bulk density prediction module for detecting the bulk density of a wheat sample to be detected by using the trained bulk density prediction model.
Citation Information
Patent Citations
Processed quinoa seed material classification method
CN111896485A
Wheat yield estimation method and device based on unmanned aerial vehicle image
CN116740592A