Machine vision-based screening method and device for similar varieties of highland barley seeds and storage medium
Through a machine vision-based method, the multi-dimensional characteristics of barley seeds are extracted and the variety classification index is generated, and the variety classification index is determined in combination with deep learning models. The problems of inaccurate and inefficient variety screening in the existing technology are solved, and efficient and accurate variety screening effect is achieved.
Patent Information
- Application Number
- CN202510138320.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-08
- Publication Date
- 2025-05-30
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing highland barley seed variety screening technology has problems such as small differences in appearance characteristics, inaccurate classification, inefficient, subjective influence, and difficulty in dealing with the needs of large-scale high-precision screening.
Using a machine vision-based method, noise is removed and seed images are segmented through Gaussian filtering and Canny edge detection, data augmentation means are used to expand the data set, color, texture and shape features are extracted, variety classification index is generated, and species discriminant model is constructed based on deep learning for training.
It has achieved efficient and accurate screening of barley seed varieties, significantly improved classification accuracy and efficiency, reduced the impact of human intervention, and adapted to the classification needs of large-scale varieties.
Smart Images

Figure CN120071334A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of seed variety discrimination, and particularly to a screening method, device and storage medium for approximate varieties of highland barley seeds based on machine vision. Background Art
[0002] Highland barley is an important food crop in alpine regions, and the selection of its varieties is of great significance for improving agricultural production efficiency and food production safety. However, at present, the variety screening of highland barley seeds mostly relies on manual observation and traditional measurement methods, mainly classifying by the appearance characteristics of seeds, such as color, size, shape, etc. This method has certain limitations because the seeds of different varieties of highland barley may have small differences in appearance and it is difficult to accurately distinguish them by the naked eye. At the same time, manual screening is not only inefficient, consuming a large amount of manpower and time, but also easily affected by subjective experience, and the stability and reliability of the results cannot be guaranteed. In addition, with the rapid increase in the number of highland barley seed varieties, the manual method is unable to cope with the large-scale and high-precision screening requirements. This makes the development of more intelligent and automated seed screening technologies an urgent technical problem to be solved.
[0003] In recent years, the technology of classifying crop seeds based on machine vision has gradually received attention. Through image processing and feature extraction methods, this technology can improve the classification accuracy and efficiency to a certain extent. However, the existing machine vision screening methods still have some deficiencies. First of all, most of these technologies only focus on single features of seeds, such as color or texture, lacking comprehensive analysis of multi-dimensional features of seeds, resulting in inaccurate and incomplete classification results. Secondly, the existing methods have poor robustness in image noise processing, seed segmentation and feature extraction, etc., and are easily interfered by external factors such as light and background, thus affecting the accuracy of seed classification. In addition, some existing methods perform poorly when the dataset scale is small and cannot fully meet the complex actual needs in the classification of highland barley seed varieties. Therefore, there is an urgent need for a more comprehensive and efficient screening method for highland barley seed varieties to overcome the limitations of the existing technology and improve the classification accuracy and practicality.
[0004] The above information disclosed in the background art section is only used to strengthen the understanding of the background of the present disclosure, so it may include information that does not constitute the prior art known to those of ordinary skill in the art. Summary of the Invention
[0005] The purpose of the present invention is to provide a screening method, device and storage medium for approximate varieties of highland barley seeds based on machine vision to solve the problems raised in the above background art.
[0006] To achieve the above purpose, the present invention provides the following technical solutions:
[0007] A screening method for approximate varieties of highland barley seeds based on machine vision, the specific steps include:
[0008] Step 1: Collect images of highland barley seeds of different varieties, remove image noise through Gaussian filtering, segment single-seed images using Canny edge detection, and use data augmentation means to expand the image dataset to form a standard dataset with clear variety labels;
[0009] Step 2: Extract key features from the seed images. The key features include color features, texture features, and shape features, which together constitute a comprehensive seed feature vector; generate a color stability index, a texture complexity index, and a shape difference index for the seeds through the key features;
[0010] Step 3: Generate a variety classification index based on the color stability index, the texture complexity index, and the shape difference index, construct a species discrimination model based on deep learning, use the variety classification index as the input, and use the variety of highland barley seeds as the label to train the model to obtain a trained species discrimination model;
[0011] Step 4: Use the variety classification index of the highland barley seeds to be identified as the input feature, input it into the species discrimination model, and output the specific variety to which the highland barley seeds to be identified belong through the model.
[0012] Further, use a high-resolution camera to collect images of highland barley seeds of different varieties under standardized lighting conditions, and the number of images collected for each variety is 2000;
[0013] Apply Gaussian filtering to each image to remove noise, and at the same time use OpenCV to implement the filtering process;
[0014] The formula based on which Gaussian filtering is applied is as follows:
[0015]
[0016] In the formula, G(x,y) is the value of the Gaussian function at (x,y) in the image, representing the effect of this point after applying Gaussian filtering, (x,y) is the pixel coordinate, ε is the standard deviation of the Gaussian function, ε = 0.5, and e is the natural constant;
[0017] Use Canny edge detection to segment single-seed images, and the formula based on which is as follows:
[0018] Edges = Canny(Image, lower threshold , upper threshold )
[0019] Where Edges represents the output binary edge image, with pixel values at the edge positions being white and those at non-edge positions being black, Image represents the input grayscale image, lower threshold and upper threshold are the thresholds used for edge detection in the Canny algorithm, representing the low threshold and the high threshold respectively;
[0020] The data augmentation method is specifically as follows: randomly adjust the brightness of the image: randomly increase or decrease the image brightness within the range of [-30, 30]; randomly rotate: perform a random rotation of [-15, 15] degrees on the image; add salt-and-pepper noise: randomly add noise pixels to the image;
[0021] After the above operations, add the corresponding variety labels to each preprocessed and data-augmented seed image to form a standard dataset containing images of different varieties of highland barley seeds.
[0022] Furthermore, extract key features from the seed images, and the specific logic is as follows:
[0023] Use the Lab color space to describe the color characteristics of the seeds, and define the color features as:
[0024] C = [μ l , σ l , μ a , σ a , μ b , σ b
[0025] Among them, μ L , μ a , μ b respectively represent the means of the seed graphics on the L, a, and b channels,
[0026] σ L , σ a , σ b are the standard deviations of the L, a, and b channels respectively, representing the degree of dispersion of the color distribution;
[0027] Extract texture attributes based on the gray-level co-occurrence matrix, and the texture attributes include contrast, entropy, and energy:
[0028]
[0029] Among them, Contrast is the contrast, used to measure the local variation of the image, P(i, j) is the probability of the gray values i and j appearing in the gray-level co-occurrence matrix, i ∈ [0, 255], j ∈ [0, 255];
[0030]
[0031] Among them, Entropy is entropy, which is used to measure the randomness of image information;
[0032]
[0033] Among them, Energy is energy, which is used to represent the texture smoothness of the image;
[0034] Extract the shape features of the seeds. The shape features include the aspect ratio, area, perimeter, and Hu moments of the seeds. Specifically:
[0035]
[0036] In the formula, AR is the aspect ratio of the seed, Width is the width, and Height is the height;
[0037]
[0038] In the formula, Area is the area, which represents the number of pixels in the seed region. B(x, y) is the binary mask of the seed region. When B(x, y) = 1, it means that the pixel at the coordinate (x, y) belongs to the seed region. When B(x, y) = 0, it means that the pixel at the coordinate (x, y) belongs to the background outside the seed region;
[0039] The perimeter of the seed refers to the number of pixels in the seed contour, denoted as Perimeter;
[0040] Use OpenCV to extract the Hu moments of the seeds.
[0041] Furthermore, calculate the color stability index through the following formula:
[0042]
[0043] In the formula, CSI is the color stability index, σ L 、σ a 、σ b are the standard deviations of the L, a, and b channels respectively, and skew L 、skew a and skew b are the skewness of the color distributions of the L, a, and b channels respectively;
[0044] skew L The calculation formula based on is:
[0045]
[0046] In the formula, N is the total number of pixels in the seed region, I k,L is the L-channel value of the kth pixel in the pixel, k is the index of the pixel in the seed region, and k ∈ [1, N], σL is the standard deviation of the L channel, and μ L is the mean of the L channel; if skew L > 0, it indicates that the distribution is skewed to the right, meaning that the color values are shifted towards larger values. If skew L < 0, it indicates that the distribution is skewed to the left, meaning that the color values are shifted towards smaller values. If skew L = 0, it indicates that the distribution is completely symmetric; skew a and skew b can be obtained in the same way;
[0047] The texture complexity index is calculated by the following formula:
[0048] TCI = Contrast + ln(1 + Entropy) - Energy
[0049] In the formula, TCI is the texture complexity index, Contrast is the contrast, Entropy is the entropy, and Energy is the energy;
[0050] The shape difference index is calculated by the following formula:
[0051]
[0052] In the formula, SDI is the shape difference index, is the ratio of the area to the perimeter, Hu m represents the m-th Hu moment, m is the index of the number of Hu moments, AR is the aspect ratio of the seed, and AR min is the minimum aspect ratio in the current seed set, and AR max is the maximum aspect ratio in the current seed set.
[0053] Furthermore, a variety classification index is generated based on the color stability index, texture complexity index, and shape difference index. The formula is as follows:
[0054]
[0055] In the formula, VCI is the variety classification index, CSI is the color stability index, TCI is the texture complexity index, SDI is the shape difference index, α, β, and γ are preset proportionality coefficients, β > α = γ > 0, and α + β + γ = 1;
[0056] A species discrimination model is constructed based on deep learning. Taking the variety classification index as the input and the variety of the highland barley seeds as the label, the model is trained to obtain a trained species discrimination model. Taking the variety classification index of the highland barley seeds to be recognized as the input feature, it is input into the species discrimination model, and the specific variety to which the highland barley seeds to be recognized belong is output through the model.
[0057] The present invention further provides a screening device for approximate varieties of highland barley seeds based on machine vision. The screening device for approximate varieties of highland barley seeds based on machine vision is used to execute the above-mentioned screening method for approximate varieties of highland barley seeds based on machine vision, and includes:
[0058] A data set construction module, which is used to collect images of highland barley seeds of different varieties, remove image noise through Gaussian filtering, segment single-seed images by using Canny edge detection, and use data augmentation means to expand the image data set to form a standard data set with clear variety labels;
[0059] A feature extraction module, which is used to extract key features from the seed images. The key features include color features, texture features, and shape features, which together constitute a comprehensive seed feature vector; generate a color stability index, a texture complexity index, and a shape difference index of the seeds through the key features;
[0060] A model construction module, which is used to generate a variety classification index based on the color stability index, the texture complexity index, and the shape difference index, construct a species discrimination model based on deep learning, use the variety classification index as the input, and use the variety of highland barley seeds as the label to train the model to obtain a trained species discrimination model;
[0061] A variety discrimination module, which is used to use the variety classification index of the highland barley seeds to be identified as the input feature, input it into the species discrimination model, and output the specific variety to which the highland barley seeds to be identified belong through the model.
[0062] The present invention further includes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it can implement the above-mentioned screening method for approximate varieties of highland barley seeds based on machine vision.
[0063] Compared with the prior art, the beneficial effects of the present invention are:
[0064] This solution proposes an automated method for efficiently screening highland barley seed varieties through technical means based on machine vision, combined with high-resolution imaging, image preprocessing, and feature extraction methods. First, this method ensures the clarity and accuracy of seed images through Gaussian filtering and Canny edge detection, and expands the dataset through data augmentation means to improve the robustness of model training. Second, this solution comprehensively extracts various features such as color, texture, and shape, and generates a color stability index, a texture complexity index, and a shape difference index respectively, so as to comprehensively characterize the multi-dimensional characteristics of seeds. By calculating the variety classification index, the multi-feature information is fused into a single input variable, enabling the variety discrimination model based on deep learning to complete the variety classification task more efficiently. In addition, this method is superior to traditional technologies in terms of accuracy and universality, can significantly reduce the influence of human intervention, improve the efficiency and accuracy of highland barley seed screening, and provide a scientific basis for the intelligent development of agricultural seed sorting BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 Schematic diagram of the overall method flow of the present invention;
[0066] Figure 2 Schematic diagram of the device module of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0067] To make the objectives, technical solutions, and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below in conjunction with specific embodiments.
[0068] It should be noted that unless otherwise defined, the technical terms or scientific terms used in the present invention should have the ordinary meaning understood by those of ordinary skill in the field to which the present invention belongs. The "first", "second", and similar terms used in the present invention do not indicate any order, quantity, or importance, but are only used to distinguish different components. The terms such as "including" or "comprising" mean that the elements or objects appearing before the term cover the elements or objects listed after the term and their equivalents, without excluding other elements or objects. The terms such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The terms such as "upper", "lower", "left", "right", etc. are only used to indicate relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.
[0069] Example:
[0070] Please refer to Figure 1 , the present invention provides a technical solution:
[0071] A method for screening approximate varieties of highland barley seeds based on machine vision, the specific steps include:
[0072] Step 1: Collect images of hulless barley seeds of different varieties, remove image noise through Gaussian filtering, segment single-seed images using Canny edge detection, and use data augmentation methods to expand the image dataset to form a standard dataset with clear variety labels.
[0073] In this embodiment, images of hulless barley seeds of different varieties are collected using a high-resolution camera under standardized lighting conditions, and the number of images collected for each variety is 2,000. Generally, it is recommended that the light intensity be stable within the range of 300 - 1,000 lux to ensure that the light source is evenly distributed across the entire shooting area and to avoid obvious high-light or shadow areas.
[0074] Apply Gaussian filtering to each image to remove noise, and at the same time use OpenCV to implement the filtering process.
[0075] The formula for applying Gaussian filtering is as follows:
[0076]
[0077] In the formula, G(x,y) is the value of the Gaussian function at the point (x,y) in the image, representing the effect of this point after applying Gaussian filtering, (x,y) is the pixel coordinate, ε is the standard deviation of the Gaussian function, ε = 0.5, and e is the natural constant.
[0078] Use Canny edge detection to segment single-seed images, and the formula is as follows:
[0079] Edges = Canny(Image, lower threshold , upper threshold )
[0080] In the formula, Edges represents the output binary edge image, the pixel values at the edge positions are white, and the pixel values at non-edge positions are black. Image represents the input grayscale image, lower threshold and upper threshold are the thresholds used for edge detection in the Canny algorithm, representing the low threshold and the high threshold respectively.
[0081] The data augmentation methods are specifically as follows: Randomly adjust the brightness of the image: randomly increase or decrease the image brightness within the range of [-30, 30]; Random rotation: perform a random rotation of [-15, 15] degrees on the image; Salt-and-pepper noise: randomly add noise pixels to the image.
[0082] After the above operations, add the corresponding variety labels to each preprocessed and data-augmented seed image to form a standard dataset containing images of hulless barley seeds of different varieties.
[0083] In Step 1, images are collected by a high-resolution camera under standardized lighting conditions, and Gaussian filtering is combined to remove noise and Canny edge detection is used to segment single-seed images, ensuring the quality and accuracy of the seed images. This process effectively reduces the possible illumination variations and noise interference in the images, laying a foundation for the accuracy of subsequent feature extraction. At the same time, the image dataset is expanded through data augmentation means, improving the model's adaptability to sample diversity and enhancing the generalization performance and robustness of the deep learning model.
[0084] Compared with the prior art, the key improvement in Step 1 lies in its systematic image quality optimization process and data augmentation strategy. In traditional methods, there is often a lack of effective denoising and seed segmentation means, which easily leads to poor image quality and affects subsequent analysis results. In addition, the prior art does not fully utilize data augmentation techniques in dataset expansion, resulting in problems such as overfitting or insufficient classification accuracy during model training. This solution comprehensively uses Gaussian filtering, Canny edge detection, and various data augmentation means to further enhance the diversity of the dataset and the stability of image processing, thus solving the existing problems. Step 1 constructs a high-quality standard dataset for the entire solution, which is the basis for the realization of the solution. By denoising, segmenting, and augmenting the original images, Step 1 not only ensures the accuracy and integrity of the extracted features but also improves the diversity and reliability of the model training data. This link provides accurate input data for subsequent feature extraction and model training, playing a decisive role in improving the performance and practicality of the final classification model.
[0085] Step 2: Extract key features from the seed images. The key features include color features, texture features, and shape features, jointly constituting a comprehensive seed feature vector; generate a color stability index, a texture complexity index, and a shape difference index for the seeds through the key features;
[0086] In this embodiment, the specific logic for extracting key features from the seed images is as follows:
[0087] The Lab color space is used to describe the color characteristics of the seeds, and the color feature is defined as:
[0088] C = [μ L , σ L , μ a , σ a , μ b , σ b
[0089] where μ L , μ a , μ b respectively represent the means of the seed graphics on the L, a, and b channels;
[0090] σ L 、 σ a 、 σ b are the standard deviations of the L, a, and b channels respectively, representing the degree of dispersion of color distribution. Calculating the mean and standard deviation are conventional data processing methods and will not be elaborated here.
[0091] Extract texture attributes based on the gray-level co-occurrence matrix. The texture attributes include contrast, entropy, and energy:
[0092]
[0093] Among them, Contrast is the contrast, used to measure the local variation of the image. P(i, j) is the probability that the gray values i and j appear in the gray-level co-occurrence matrix, where i ∈ [0, 255] and j ∈ [0, 255];
[0094]
[0095] Among them, Entropy is the entropy, used to measure the randomness of image information;
[0096]
[0097] Among them, Energy is the energy, used to represent the texture smoothness of the image;
[0098] Extract the shape features of the seeds. The shape features include the aspect ratio, area, perimeter, and Hu moments of the seeds, specifically:
[0099]
[0100] In the formula, AR is the aspect ratio of the seed, Width is the width, and Height is the height;
[0101]
[0102] In the formula, Area is the area, representing the number of pixels in the seed region. B(x, y) is the binary mask of the seed region. When B(x, y) = 1, it means that the pixel at the coordinate (x, y) belongs to the seed region. When B(x, y) = 0, it means that the pixel at the coordinate (x, y) belongs to the background outside the seed region;
[0103] The perimeter of the seed refers to the number of pixels in the seed contour, denoted as Perimeter;
[0104] Use OpenCV to extract the Hu moments of the seeds.
[0105] Calculate the color stability index through the following formula:
[0106]
[0107] In the formula, CSI is the color stability index, and σ L , σ a , σ b are the standard deviations of the L, a, and b channels respectively, and skew L , skew a and skew b are the skewness of the color distributions of the L, a, and b channels respectively; the color stability index comprehensively describes the discreteness and symmetry of the color distribution on the three channels, reflecting the stability and concentration of the seed color: for varieties with relatively consistent colors, the CSI value will be lower, and for varieties with a more dispersed color distribution, the CSI value will be higher; CSI can be used to analyze the color differences between different seed varieties. If the CSI value of a certain variety is significantly lower than that of other varieties, it indicates that its color characteristics are more stable and may be a reliable basis for classification.
[0108] skew L The calculation formula is as follows:
[0109]
[0110] In the formula, N is the total number of pixels in the seed region, and I k,L is the L-channel value of the k-th pixel in the pixel, k is the index of the pixel in the seed region, and k ∈ [1, N]. σ L is the standard deviation of the L channel, and μ L is the mean of the L channel; if skew L > 0, it means that the distribution is skewed to the right, indicating that the color value shifts towards the larger direction. If skew L < 0, it means that the distribution is skewed to the left, indicating that the color value shifts towards the smaller direction. If skew L = 0, it means that the distribution is completely symmetric; skew a and skew b can be obtained in the same way;
[0111] The texture complexity index is calculated through the following formula:
[0112] TCI = Contrast + ln(1 + Entropy) - Energy
[0113] In the formula, TCI is the texture complexity index, Contrast is the contrast, Entropy is the entropy, and Energy is the energy; the contrast is an index to measure the degree of gray value change between local regions of the texture. The higher the contrast value, the greater the difference in gray values in the local region of the image, and the more complex the texture; the entropy is an important index to measure the randomness and uncertainty of texture information. The higher the entropy value, the more complex the texture information of the image and the more irregular the gray distribution; the energy is a quantitative index of the smoothness or regularity of the texture. The larger the energy value, the smoother and more regular the texture of the image; this formula integrates three texture features: contrast (local gray difference), entropy (randomness), and energy (smoothness), and comprehensively calculates an index for quantifying the complexity of image texture. Contrast is directly positively correlated with TCI, reflecting the amplitude of detail changes in the texture. The part log(1 + Entropy) enhances its ability to distinguish low-complexity textures appropriately by taking the logarithm of the entropy value, while preventing high-complexity textures from having too much influence on the index; Energy is negatively correlated with TCI and is used to constrain the TCI value to avoid overly smooth textures being misrecognized as complex.
[0114] The shape difference index is calculated by the following formula:
[0115]
[0116] In the formula, SDI is the shape difference index, is the ratio of area to perimeter, and Hu m represents the m-th Hu moment, where m is the index of the number of Hu moments. Mathematician Hu defined 7 invariant moments, which are obtained through the combination and algebraic transformation of the normalized central moments of the image and can describe the geometric characteristics of two-dimensional shapes. AR is the aspect ratio of the seed, and AR min is the minimum aspect ratio in the current seed set, and AR max is the maximum aspect ratio in the current seed set. The first part is used to reflect the overall shape characteristics of the seed. If the shape of the seed tends to be circular, the ratio of area to perimeter will be larger; if the shape is more slender or complex, this ratio will be smaller; the second part uses the sum of the absolute values of the Hu moments to capture the shape invariance characteristics of the seed. By accumulating the absolute values of the Hu moments, the complex shape characteristics of the seed can be comprehensively measured. For example, a high value may correspond to the complexity of the seed shape, while a low value may correspond to a simple shape with strong regularity; the third part is the normalization of the aspect ratio, which is used to measure the slenderness of the seed shape. Through normalization, the aspect ratio characteristics of different seeds can be more intuitively compared. If the aspect ratio of the seed is close to the minimum value in the current seed set, its normalized value is close to 0; if it is close to the maximum value, its normalized value is close to 1.
[0117] In step 2, a comprehensive seed feature vector is constructed by extracting color features, texture features, and shape features, covering the multi-dimensional characteristics of highland barley seeds, making seed classification more scientific and accurate. Among them, the color features are based on the Lab color space and can accurately reflect the color distribution of the seeds; the texture features use the gray-level co-occurrence matrix to extract information such as contrast, entropy, and energy, fully reflecting the complexity of the seed surface texture; the shape features comprehensively consider the length-width ratio, area, perimeter, and Hu moments of the seeds, comprehensively characterizing the geometric shape of the seeds. By combining these different features together, this step lays a solid foundation for subsequent classification.
[0118] Compared with the existing technology, the significant improvement in step 2 lies in the comprehensive extraction and fusion of multi-dimensional features. Traditional methods often only focus on a single feature of the seeds and are prone to ignoring other important factors, resulting in limited accuracy of the classification model in differentiating varieties. This solution generates a color stability index, a texture complexity index, and a shape difference index through the systematic extraction and processing of multi-dimensional features, thus achieving a high degree of integration and expression of seed features. In addition, the extraction methods using the Lab color space and the gray-level co-occurrence matrix enhance the robustness of feature expression and reduce the influence of factors such as environmental light and background interference. Step 2 plays a core role of connecting the preceding with the following in the overall solution. By comprehensively extracting seed features, it provides high-quality and complete input data for the subsequent generation of variety classification indices and the training of deep learning models. The multi-dimensional nature of the feature vector ensures a comprehensive understanding of seed attributes by the variety classification model, thereby improving the classification accuracy and robustness. Through this step, this solution can more accurately quantify the subtle differences between seed varieties, significantly enhancing the scientificity and practicality of the overall screening method.
[0119] Step 3: Generate a variety classification index based on the color stability index, texture complexity index, and shape difference index, construct a species discrimination model based on deep learning, use the variety classification index as the input, and the variety of highland barley seeds as the label to train the model to obtain a trained species discrimination model;
[0120] In this embodiment, the formula for generating the variety classification index based on the color stability index, texture complexity index, and shape difference index is as follows:
[0121]
[0122] In the formula, VCI is the variety classification index, CSI is the color stability index, TCI is the texture complexity index, SDI is the shape difference index, α, β, and γ are preset proportionality coefficients, β > α = γ > 0, and α + β + γ = 1. This is because in the variety classification task, the texture complexity of seeds often plays a more crucial role in distinguishing different varieties. Especially for varieties with small appearance differences, the texture can often reflect more subtle individual differences. Therefore, the weight of TCI is set to be the largest. Although color and shape are also important, their contributions to variety classification are generally secondary to texture. The equal weight setting of α = γ indicates that color and shape are equally important in classification. The VCI value decreases as the CSI increases, reflecting that when the color is less stable, its contribution is smaller. This processing method is more in line with real-world logic: when the color changes drastically, its stability is poor, and its reference value for classification is relatively low. The rationality of this formula lies in that it comprehensively considers the importance of the three key features of color, texture, and shape in variety classification through a weighted combination of the color stability index, texture complexity index, and shape difference index. The setting of the weight coefficients α, β, and γ can reflect the different contributions of each feature to the classification task. The formula uses the cube root and natural logarithm functions, making the final variety classification index have numerical smoothness and non-linear characteristics. It can not only avoid a single feature dominating the result but also enhance the coordination between different features, thus more accurately characterizing the comprehensive characteristics of varieties and achieving the scientificity and robustness of classification.
[0123] VCI is a comprehensive index used to evaluate and quantify the overall characteristics of a certain type of seeds to achieve the classification or differentiation of different varieties. By combining the color stability index, texture complexity index, and shape difference index, VCI integrates multi-dimensional information into a single value, reflecting the comprehensive characteristics of a certain type of seeds or crop varieties in these feature dimensions.
[0124] Step 3 generates the variety classification index by comprehensively considering the color stability index, texture complexity index, and shape difference index. This is a highly integrated feature expression method. Compared with directly using a single or overly scattered feature vector, the variety classification index can better capture the differences and similarities among different varieties of hulless barley seeds, simplifying the model input. Then, combined with deep learning to construct a species discrimination model and optimize the model using training data, enabling the model to have strong classification and generalization capabilities, thus effectively improving the accuracy and efficiency of seed variety discrimination.
[0125] In traditional seed classification methods, feature vectors are often directly input into the classifier for training without further fusion and extraction of features. This may lead to insufficient learning ability of the model for key features and affect the classification performance. In this solution, the variety classification index is generated through CSI, TCI, and SDI, which can express features at a higher abstract level, reduce the interference of low-dimensional feature noise, and improve the discrimination ability of features for samples. In addition, a deep learning model is used to replace traditional classification models such as SVM or decision trees, giving full play to the advantages of deep learning in processing complex non-linear features and significantly improving the classification accuracy and reliability. Step 3 is the core logic of the entire solution and plays a crucial role in connecting the preceding with the following. By integrating complex features into the variety classification index, it not only effectively reduces the feature dimension and simplifies the classification process, but also inputs highly optimized feature data into the deep learning model, enabling the model to more efficiently learn the discrimination rules of seed varieties. Finally, this step achieves the accurate classification of seed varieties, effectively improving the practicability and performance of the overall solution and providing an efficient and reliable technical means for screening highland barley seeds.
[0126] Step 4: Use the variety classification index of the highland barley seeds to be identified as the input feature and input it into the variety discrimination model, and output the specific variety to which the highland barley seeds to be identified belong through the model.
[0127] In this embodiment, a variety discrimination model is constructed based on deep learning. Using the variety classification index as the input and the variety of highland barley seeds as the label, the model is trained to obtain a trained variety discrimination model. Then, use the variety classification index of the highland barley seeds to be identified as the input feature and input it into the variety discrimination model, and output the specific variety to which the highland barley seeds to be identified belong through the model.
[0128] By using the variety classification index of the highland barley seeds to be identified as the input feature and inputting it into the trained variety discrimination model in Step 4, the specific variety of the seeds can be output quickly and efficiently. The advantage of this step is to utilize the powerful classification ability of the deep learning model to convert the previous complex feature extraction and classification index generation processes into intuitive and accurate variety recognition results. The non-linear mapping ability of the deep learning model enables it to easily process multi-dimensional feature data and obtain high-precision classification results, significantly simplifying the screening operation of users.
[0129] In the prior art, seed classification methods often rely on traditional machine learning models, such as support vector machines, K-nearest neighbor algorithms, etc. These models have relatively limited performance in dealing with complex and high-dimensional features, resulting in relatively low classification accuracy and efficiency. In step 4 of this solution, through a deep learning model and its powerful learning and reasoning capabilities, the non-linear relationships between multi-dimensional features can be fully explored, significantly improving the classification accuracy and robustness. In addition, the deep learning model has stronger generalization performance and can better adapt to diverse data sets or complex classification tasks. Step 4 is the final link of this solution and the core output of the hulless barley seed variety classification. It converts the variety classification index generated in the previous steps into an intuitive classification result, realizing a closed-loop from data analysis to practical application. Through the role of the deep learning model, this step not only significantly improves the automation and intelligence level of the entire solution, but also enhances the classification efficiency and accuracy, meeting the requirements of rapidity and reliability in the actual hulless barley seed screening process, providing strong support for rapid seed variety screening and agricultural production.
[0130] Please refer to Figure 2 , a screening device for approximate varieties of hulless barley seeds based on machine vision, comprising:
[0131] A data set construction module, used to collect images of hulless barley seeds of different varieties, remove image noise through Gaussian filtering, segment single-seed images using Canny edge detection, and expand the image data set using data augmentation means to form a standard data set with clear variety labels;
[0132] A feature extraction module, used to extract key features from the seed images. The key features include color features, texture features, and shape features, jointly constituting a comprehensive seed feature vector; generate a color stability index, a texture complexity index, and a shape difference index of the seeds through the key features;
[0133] A model construction module, used to generate a variety classification index based on the color stability index, the texture complexity index, and the shape difference index, construct a species discrimination model based on deep learning, use the variety classification index as the input, and the variety of hulless barley seeds as the label to train the model to obtain a trained species discrimination model;
[0134] A variety discrimination module, used to use the variety classification index of the hulless barley seeds to be identified as the input feature, input it into the species discrimination model, and output the specific variety to which the hulless barley seeds to be identified belong through the model.
[0135] The present invention also includes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it can implement the above-mentioned screening method for approximate varieties of hulless barley seeds based on machine vision.
[0136] The above formulas are all dimensionless and take their numerical calculations. The formulas are obtained by collecting a large amount of data for software simulation to get a formula closest to the actual situation. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0137] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. Those skilled in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software methods depends on the specific application and design constraints of the technical solution.
[0138] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units. They can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0139] As described above, only the specific implementation manners of this application are provided, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application, and all of them should be covered by the protection scope of this application.
Claims
1. A method for screening similar varieties of highland barley seeds based on machine vision, characterized in that: The specific steps include: Step 1: Collect images of different varieties of highland barley seeds, remove image noise through Gaussian filtering, segment single seed images using Canny edge detection, and use data enhancement to expand the image dataset to form a standard dataset with clear variety labels; Step 2: extract key features from the seed image, wherein the key features include color features, texture features, and shape features, which together constitute a comprehensive seed feature vector; generate a color stability index, a texture complexity index, and a shape difference index of the seed through the key features; Step 3: Generate a variety classification index based on the color stability index, texture complexity index, and shape difference index, build a variety discrimination model based on deep learning, take the variety classification index as input, take the highland barley seed variety as a label, train the model, and obtain a trained variety discrimination model; Step 4: The variety classification index of the highland barley seeds to be identified is used as an input feature and input into the variety discrimination model, and the specific variety of the highland barley seeds to be identified is output through the model.
2. The method for screening similar varieties of highland barley seeds based on machine vision according to claim 1, characterized in that: A high-resolution camera was used to collect images of different varieties of highland barley seeds under standardized lighting conditions, with 2,000 images collected for each variety. Apply Gaussian filtering to each image to remove noise, and use OpenCV to implement the filtering process; The formula for applying Gaussian filtering is as follows: Where G(x,y) is the value of the Gaussian function at (x,y) in the image, indicating the effect of the point after applying the Gaussian filter, (x,y) is the pixel coordinate, ε is the standard deviation of the Gaussian function, ε = 0.5, and e is a natural constant; The Canny edge detection is used to segment the single seed image, and the formula is as follows: Edges=Canny(Image,lower threshold ,upper threshold ) Where Edges represents the output binary edge image, the pixel values at the edge position are white, and the pixel values at the non-edge position are black, Image represents the input grayscale image, and lower threshold and upper threshold are the thresholds used for edge detection in the Canny algorithm, representing the low threshold and the high threshold respectively; The data enhancement means are specifically: random brightness adjustment of the image: randomly increasing or decreasing the image brightness in the range of [-30, 30]; random rotation: randomly rotating the image by [-15, 15] degrees; salt and pepper noise: randomly adding noise pixels to the image; After the above operations, a corresponding variety label is added to each preprocessed and data-enhanced seed image to form a standard dataset containing images of different varieties of highland barley seeds.
3. The method for screening similar varieties of highland barley seeds based on machine vision according to claim 2, characterized in that: The specific logic for extracting key features from seed images is as follows: The Lab color space is used to describe the color characteristics of the seeds, and the color characteristics are defined as: C=[μ L ,s L ,m a ,s a ,m b ,s b ] Among them, μ L , μ a , μ b Represent the mean of the seed graph on L, a, and b channels respectively. σ L , σ a , σ b are the standard deviations of the L, a, and b channels, respectively, indicating the degree of discreteness of the color distribution; Extract texture attributes based on gray-level co-occurrence matrix, including contrast, entropy and energy: Among them, Contrast is the contrast, which is used to measure the local change of the image, P(i,j) is the probability of gray values i and j appearing in the gray level co-occurrence matrix, i∈[0,255], j∈[0,255]; Among them, Entropy is entropy, which is used to measure the randomness of image information; Among them, Energy is energy, which is used to indicate the texture smoothness of the image; Extract the shape features of the seeds, which include the length-to-width ratio, area, perimeter and Hu moment of the seeds, specifically: In the formula, AR is the aspect ratio of the seed, Width is the width, and Height is the height; Where Area is the area, which indicates the number of pixels in the seed area, B(x,y) is the binary mask of the seed area, when B(x,y)=1, it means that the pixel at the coordinate (x,y) belongs to the seed area, when B(x,y)=0, it means that the pixel at the coordinate (x,y) belongs to the background outside the seed area; The perimeter of a seed refers to the number of pixels of the seed outline, recorded as Perimeter; Extract the Hu moment of the seed using OpenCV.
4. The method for screening similar varieties of highland barley seeds based on machine vision according to claim 1, characterized in that: The color stability index is calculated by the following formula: Where CSI is the color stability index, σ L , σ a , σ b are the standard deviations of L, a, and b channels, respectively, and skew L , skew a and skew b are the skewness of the color distribution of L, a, and b channels respectively; skew L The calculation formula is: Where N is the total number of pixels in the seed area, I k,L is the L channel value of the kth pixel in the pixel, k is the index of the pixel in the seed region, and k∈[1,N], σ L is the standard deviation of the L channel, μ L is the mean of the L channel; if skew L >0, indicating that the distribution is biased to the right, indicating that the color value is shifted in a larger direction. L <0, indicating that the distribution is biased to the left, indicating that the color value is shifted in the smaller direction. L =0, indicating that the distribution is completely symmetrical; skew a and skew b The same logic can be applied; The texture complexity index is calculated by the following formula: TCI=Contrast+ln(1+Entropy)-Energy Where TCI is the texture complexity index, Contrast is the contrast, Entropy is the entropy, and Energy is the energy; The shape difference index was calculated by the following formula: Where SDI is the shape difference index, is the ratio of area to perimeter, Hu m represents the mth Hu moment, m is the index of the number of Hu moments, AR is the aspect ratio of the seed, AR min is the minimum aspect ratio in the current seed set, AR max is the maximum aspect ratio in the current seed set.
5. The method for screening similar varieties of highland barley seeds based on machine vision according to claim 4, characterized in that: The variety classification index is generated based on the color stability index, texture complexity index and shape difference index, and the formula is as follows: Wherein, VCI is the variety classification index, CSI is the color stability index, TCI is the texture complexity index, SDI is the shape difference index, α, β and γ are the preset proportional coefficients, β>α=γ>0, and α+β+γ=1 is satisfied; A species discrimination model is constructed based on deep learning. The variety classification index is used as input and the variety of highland barley seeds is used as a label. The model is trained to obtain a trained species discrimination model. The variety classification index of the highland barley seeds to be identified is used as an input feature and input into the species discrimination model. The model outputs the specific variety of the highland barley seeds to be identified.
6. A device for screening similar varieties of highland barley seeds based on machine vision, characterized in that: The dataset construction module is used to collect images of different varieties of highland barley seeds, remove image noise through Gaussian filtering, segment single seed images using Canny edge detection, and expand the image dataset using data enhancement to form a standard dataset with clear variety labels; A feature extraction module is used to extract key features from the seed image, wherein the key features include color features, texture features and shape features, which together constitute a comprehensive seed feature vector; and to generate a color stability index, a texture complexity index and a shape difference index of the seed through the key features; A model building module is used to generate a variety classification index based on the color stability index, the texture complexity index, and the shape difference index, and to build a variety discrimination model based on deep learning. The variety classification index is used as input, and the variety of highland barley seeds is used as a label to train the model to obtain a trained variety discrimination model. The variety identification module is used to input the variety classification index of the barley seeds to be identified as an input feature into the variety identification model, and output the specific variety of the barley seeds to be identified through the model.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it can implement a method for screening similar varieties of highland barley seeds based on machine vision as described in any one of claims 1 to 5.
Citation Information
Cited By
Multi-stage screening and quality detection method for peaches
CN121354095A
A multi-stage screening and quality detection method for fruit pears
CN121354095B