Machine vision-based kidney bean seed variety intelligent identification and classification method
Through intelligent recognition and classification methods based on machine vision, image preprocessing and feature extraction technology, combined with support vector machine classification model, the problem of identification and classification of bean seed varieties is solved, and the rapid, accurate and lossless recognition effect is achieved, and agricultural modernization has been promoted.
Patent Information
- Application Number
- CN202510074603.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-05-16
AI Technical Summary
The prior art is difficult to quickly, accurately and without loss identifying and classifying seed varieties of beans quickly, accurately and without loss, and cannot meet the needs of beans cultivation, especially in large-scale planting and variety selection.
Using intelligent recognition and classification methods based on machine vision, we use images of bean seeds, image preprocessing and feature extraction, and use support vector machine classification model and other technologies to achieve rapid and accurate identification and classification of bean seed varieties.
It has achieved rapid, accurate, lossless identification and classification of seed varieties of beans, improved the efficiency of identification of beans, promoted the precision of planting management and intelligent upgrade of agricultural production, and promoted the modernization of agricultural development.
Smart Images

Figure CN120014614A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image classification, and more particularly to a method for intelligently identifying and classifying kidney bean seed varieties based on machine vision. Background Art
[0002] Kidney beans have rich nutritional value and a wide range of uses, and the demand for their cultivation continues to grow. In the process of planting kidney beans, choosing the right seed variety is crucial to crop yield and quality. The diversity of climatic conditions, soil environment and planting techniques in different regions determines the specific needs of kidney bean seed selection; moreover, the purity of seed varieties is one of the important factors affecting crop yield and quality. In the process of kidney bean seed production and planting, ensuring the purity of seed varieties is the key to protecting farmers' interests and improving planting efficiency. Identifying and classifying different seed varieties can help farmers and agricultural managers better understand their characteristics and adaptability, and can choose the most suitable seed variety according to the characteristics of the specific planting site, thereby ensuring the production quality of crops.
[0003] Traditional seed variety identification methods mainly include morphological identification and chemical identification. Among them, morphological identification uses human eyes to identify external features of seeds for classification. Although it has certain classification effects, it has disadvantages such as inconsistent classification standards, slow classification speed, high misjudgment rate, and waste of manpower. Chemical identification uses chemical reagent titration to identify seed varieties. Although it can achieve certain identification effects, it also has disadvantages such as long identification time and certain destructiveness to seeds. It cannot meet the needs of large-scale planting and is difficult to be widely promoted and applied. Machine vision (MV) is a technology that processes the intuitive features of the target image. As a fast and non-destructive detection technology, MV has been successfully applied to agricultural product detection, especially in the fields of seed production, quality control, and impurity identification. However, there are relatively few studies on the classification of kidney bean seeds. In order to provide farmers with scientific planting guidance, improve seed purity and planting quality, and promote the sustainable development of kidney bean production, it is necessary to achieve rapid and non-destructive identification of kidney bean seed varieties in the early stage of planting. Summary of the invention
[0004] The purpose of the present invention is to provide a method for intelligent identification and classification of kidney bean seed varieties based on machine vision. By combining multiple technical means such as machine vision technology, image processing and machine learning, rapid, accurate and non-destructive intelligent identification and classification of kidney bean seed varieties are achieved, providing strong support for kidney bean breeding and large-scale planting.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A method for intelligent identification and classification of bean seed varieties based on machine vision comprises the following steps:
[0007] Photograph different varieties of kidney bean seeds to obtain original images of kidney bean seeds;
[0008] The original image is divided into a training set and a test set, and preprocessed, and the appearance features and geometric features of kidney bean seeds are extracted; wherein the training set is a set of training samples of kidney bean seeds of various varieties; the test set is a set of test samples of kidney bean seeds of various varieties;
[0009] The preliminary classification model is trained using the appearance features and geometric features extracted from the training set, and after parameter tuning, a trained classification model is obtained;
[0010] Based on the trained classification model, the bean seeds to be identified and classified are identified and classified.
[0011] Furthermore, the photographing of different varieties of kidney bean seeds includes the following process:
[0012] Constructing a kidney bean seed image acquisition system; wherein the image acquisition system comprises: a high-resolution camera, a ring fill light, a sample stage, a light shielding box and a computer;
[0013] The high-resolution camera is used to photograph the characteristics of kidney bean seeds to obtain an original image;
[0014] The ring fill light is used to provide uniform and sufficient light for the high-resolution camera to ensure that the colors and details on the original image are accurately presented;
[0015] The sample stage is used to place bean seeds to ensure that the bean seeds remain stable during the photographing process;
[0016] The light shielding box is used to create a non-interference shooting environment to prevent external light interference;
[0017] The computer is used to control the high-resolution camera to shoot, process the original image, and perform feature extraction;
[0018] Place a single bean seed on the sample stage, and adjust the focus of the high-resolution camera and the brightness of the ring light to obtain a clear seed image without reflections and shadows;
[0019] The original images of all bean seeds were collected one by one and numbered.
[0020] Furthermore, the training set is a set of training samples of various varieties of kidney bean seeds; the test set is a set of test samples of various varieties of training samples, specifically:
[0021] The holdout method was used to divide different varieties of bean seeds into training samples and test samples in a ratio of 7:3.
[0022] Further, the extracting appearance characteristics of kidney bean seeds includes: extracting color characteristics and pattern characteristics of kidney bean seeds;
[0023] The color characteristics include: the main body color, body color and pattern color of kidney bean seeds;
[0024] The pattern features include: the number of patterns;
[0025] Extracting the main color and pattern color of the kidney bean seeds, including: extracting the average value of the three channels of RGB and the number of patterns for each color, a total of 7 features;
[0026] Extracting the body color and pattern color of the kidney bean seeds, including: extracting the average value of the three channels of RGB for each color, a total of 6 features;
[0027] The geometric characteristics include: aspect ratio and seed size.
[0028] Furthermore, the preliminary classification model is specifically: a support vector machine classification model;
[0029] The construction method of the support vector machine classification model is:
[0030] The appearance features and geometric features extracted from the training set are used as input, and the true variety labels of the seed samples in the training set are used as output. After 5-fold cross-validation, the parameters are tuned, the penalty coefficient is set to 45, and a preliminary classification model is constructed using a linear kernel function.
[0031] Furthermore, the original image is divided into a training set and a test set, preprocessed, and the appearance features and geometric features of the kidney bean seeds are extracted respectively; wherein the preprocessing and the extraction of the appearance features of the kidney bean seeds include the following steps:
[0032] Use Gaussian filter to remove noise points in the original image;
[0033] Set a suitable color threshold to convert the original image into a binary image;
[0034] The edge contour of the pattern in the original image is extracted and saved based on the Canny edge extraction algorithm, and the morphological opening operation is used to smooth the contour line of the pattern, disconnect the narrow space and eliminate the small protrusions;
[0035] Read the number of pixels in each contour, discard the contours with fewer pixels, calculate and count the number of remaining contours to obtain the number of patterns;
[0036] The extracted pattern color is used to create a mask, and the pixel value of the extracted pattern area is set to 0 to generate a mask image. The mask image is then logically ANDed with the original image to obtain the color features of the bean itself.
[0037] Further, the original image is divided into a training set and a test set, preprocessed, and the appearance features and geometric features of the seed samples are extracted; wherein the preprocessing and the extraction of the geometric features of the seed samples include the following steps:
[0038] The original image is binarized using the Otsu algorithm and bilaterally filtered;
[0039] The overall outline of the bean seed is extracted using the contour search and contour extraction algorithm in OpenCV, the number of pixels in the outline is obtained, and the actual area of the bean seed is represented or converted as the size of the seed by a ratio;
[0040] Find the minimum circumscribed rectangle of the bean seed, obtain the length and width of the rectangle, and use the ratio of the length to the width of the rectangle as the aspect ratio of the seed.
[0041] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0042] The machine vision-based intelligent identification and classification method for kidney bean seed varieties provided by the present invention can obtain the color features, pattern features and geometric features of the images by obtaining kidney bean seed images of different varieties, performing image preprocessing and information extraction on the kidney bean seed images, specifically including 9 features including main color (RGB three channels), pattern color (RGB three channels), aspect ratio, size and number of patterns, and divide the data set based on a ratio of 7:3, and then perform classification simulation of kidney bean seed varieties based on the extracted 9 features, thereby realizing the identification of kidney bean seed varieties. Moreover, the test results show that the method of the present invention is also helpful to improve the recognition efficiency of kidney bean varieties, promote the precision of planting management, promote the intelligent upgrading of agricultural production, and then promote the development of agricultural modernization, which has a positive role in promoting the development of the agricultural industry and the income of farmers, and also provides detailed and rich data support for application fields such as kidney bean seed variety detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0044] The following is a further description of the intelligent identification and classification method of kidney bean seed varieties based on machine vision of the present invention in conjunction with the accompanying drawings;
[0045] Figure 1 It is a flow chart of intelligent identification and classification in the method for intelligent identification and classification of kidney bean seed varieties based on machine vision provided by the present invention;
[0046] Figure 2 It is a schematic diagram of an image acquisition system in the method for intelligent identification and classification of kidney bean seed varieties based on machine vision provided by the present invention;
[0047] Figure 3 It is a flow chart of image preprocessing and feature extraction in the method for intelligent identification and classification of kidney bean seed varieties based on machine vision provided by the present invention;
[0048] Figure 4 These are 24 randomly selected sample images of kidney bean seeds in the method for intelligent identification and classification of kidney bean seed varieties based on machine vision provided by the present invention;
[0049] Figure 5 It is the F1 value and accuracy of three types of classification models corresponding to three embodiments in the method for intelligent identification and classification of bean seed varieties based on machine vision provided by the present invention;
[0050] Figure 6 The three classification models corresponding to the three embodiments of the machine vision-based intelligent identification and classification method for kidney bean seeds provided by the present invention accurately classify various varieties of kidney bean seeds. DETAILED DESCRIPTION
[0051] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0052] In order to better understand the purpose, structure and function of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings.
[0053] like Figure 1 As shown, the present invention provides a method for intelligent identification and classification of bean seed varieties based on machine vision, comprising the following steps:
[0054] Photograph different varieties of kidney bean seeds to obtain original images of kidney bean seeds;
[0055] The original image is divided into a training set and a test set, and preprocessed, and the appearance features and geometric features of kidney bean seeds are extracted; wherein the training set is a set of training samples of kidney bean seeds of various varieties; the test set is a set of test samples of kidney bean seeds of various varieties;
[0056] The preliminary classification model is trained using the appearance features and geometric features extracted from the training set, and after parameter tuning, a trained classification model is obtained;
[0057] Based on the trained classification model, the bean seeds to be identified and classified are identified and classified.
[0058] The photographing of different varieties of kidney bean seeds includes the following processes:
[0059] Constructing a kidney bean seed image acquisition system; wherein the image acquisition system comprises: a high-resolution camera, a ring fill light, a sample stage, a light shielding box and a computer;
[0060] The high-resolution camera is used to photograph the characteristics of kidney bean seeds to obtain an original image;
[0061] The ring fill light is used to provide uniform and sufficient light for the high-resolution camera to ensure that the colors and details on the original image are accurately presented;
[0062] The sample stage is used to place bean seeds to ensure that the bean seeds remain stable during the photographing process;
[0063] The light shielding box is used to create a non-interference shooting environment to prevent external light interference;
[0064] The computer is used to control the high-resolution camera to shoot, process the original image, and perform feature extraction;
[0065] Place a single bean seed on the sample stage, and adjust the focus of the high-resolution camera and the brightness of the ring light to obtain a clear seed image without reflections and shadows;
[0066] The original images of all bean seeds were collected one by one and numbered.
[0067] The training set is a set of training samples of various varieties of kidney bean seeds; the test set is a set of test samples of various varieties of training samples, specifically:
[0068] The holdout method was used to divide different varieties of bean seeds into training samples and test samples in a ratio of 7:3.
[0069] The method of extracting the appearance characteristics of kidney bean seeds includes: extracting the color characteristics and pattern characteristics of kidney bean seeds;
[0070] The color characteristics include: the main body color, body color and pattern color of kidney bean seeds;
[0071] The pattern features include: the number of patterns;
[0072] Extracting the main color and pattern color of the kidney bean seeds, including: extracting the average value of the three channels of RGB and the number of patterns for each color, a total of 7 features;
[0073] Extracting the body color and pattern color of the kidney bean seeds, including: extracting the average value of the three channels of RGB for each color, a total of 6 features;
[0074] The geometric characteristics include: aspect ratio and seed size.
[0075] It should be noted that color feature is the most widely used visual feature in MV. Color is a major and intuitive feature that distinguishes most bean seeds, and it is also the most basic feature in MV processing. Compared with other visual features, color features are less dependent on the size, direction and image acquisition viewing angle of the seeds themselves, so they have higher robustness and are important feature parameters that can reflect the category of bean seeds. The color feature mainly extracts 6 features in three channels: the color of the bean body and the RGB color of the pattern. The pattern feature can reflect the external physical characteristics of the seeds. The patterns of different varieties of bean seeds have different colors and numbers. Color features and pattern features can be subdivided into three channels: the main color of the seeds and the RGB color of the pattern, as well as the number of patterns, for a total of 7 features;
[0076] The geometric characteristics of seeds are not affected by color and pattern, and can be directly reflected by the size of the seeds and the aspect ratio of the appearance. The seed size is the area of the bean seed image. This feature varies greatly due to different seed development and can only be used as a reference feature. The aspect ratio is the ratio of the length of the long axis to the short axis of the seed, which can better reflect the difference between varieties than seed size. Geometric characteristics can be subdivided into aspect ratio and seed size, a total of 2 characteristics.
[0077] The preliminary classification model is specifically: a support vector machine classification model;
[0078] The construction method of the support vector machine classification model is:
[0079] The appearance features and geometric features extracted from the training set are used as input, and the true variety labels of the seed samples in the training set are used as output. After 5-fold cross-validation, the parameters are tuned, the penalty coefficient is set to 45, and a preliminary classification model is constructed using a linear kernel function.
[0080] The original image is divided into a training set and a test set, preprocessed, and the appearance features and geometric features of the kidney bean seeds are extracted respectively; wherein the preprocessing and the extraction of the appearance features of the kidney bean seeds include the following steps:
[0081] Use Gaussian filter to remove noise points in the original image;
[0082] Set a suitable color threshold to convert the original image into a binary image;
[0083] The edge contour of the pattern in the original image is extracted and saved based on the Canny edge extraction algorithm, and the morphological opening operation is used to smooth the contour line of the pattern, disconnect the narrow space and eliminate the small protrusions;
[0084] Read the number of pixels in each contour, discard the contours with fewer pixels, calculate and count the number of remaining contours to obtain the number of patterns;
[0085] The extracted pattern color is used to create a mask, and the pixel value of the extracted pattern area is set to 0 to generate a mask image. The mask image is then logically ANDed with the original image to obtain the color features of the bean itself.
[0086] The original image is divided into a training set and a test set, and preprocessed, and the appearance features and geometric features of the seed sample are extracted; wherein the preprocessing and the extraction of the geometric features of the seed sample include the following steps:
[0087] The original image is binarized using the Otsu algorithm and bilaterally filtered;
[0088] The overall outline of the bean seed is extracted using the contour search and contour extraction algorithm in OpenCV, the number of pixels in the outline is obtained, and the actual area of the bean seed is represented or converted as the size of the seed by a ratio;
[0089] Find the minimum circumscribed rectangle of the bean seed, obtain the length and width of the rectangle, and use the ratio of the length to the width of the rectangle as the aspect ratio of the seed.
[0090] The present invention also provides the following specific embodiments:
[0091] Example 1
[0092] 1. Sample preparation. Figure 4 As shown in the figure, the beans samples in this example come from six types of beans seeds, namely, Fengguan, Qingguan, Xiaguan, Baiguan, Yuguan and Shengguan, produced by Heilongjiang Quanfu Planting Co., Ltd. In order to ensure that the selected samples are widely representative, 2751 seeds were randomly selected from seeds of each variety, including 302 seeds of Fengguan, 620 seeds of Qingguan, 303 seeds of Xiaguan, 703 seeds of Baiguan, 441 seeds of Yuguan and 382 seeds of Shengguan.
[0093] 2. Collect sample images; build a kidney bean seed sample image collection system. Figure 2 As shown in the figure, the system consists of a high-resolution camera, a ring fill light, a sample stage, a light shielding box and a computer, as follows:
[0094] (1) High-resolution camera: Daheng MER-1070-14U3C-L color industrial camera with a resolution of 3840×2840 is selected;
[0095] (2) Ring light: Installed between the high-resolution camera and the bean seeds, the ring light is irradiated vertically on the bean seeds. The brightness of the ring light is adjusted to reduce the adverse effects of light source brightness and shadows on the experimental results.
[0096] (3) Sample stage: Using a white PVB light-absorbing background plate can effectively reduce the impact of reflection and background color on the quality of the captured image;
[0097] (4) Light shielding box: It can shield external light interference, ensure the stability and consistency of the shooting environment, and thus improve the quality and stability of the image;
[0098] (5) Computer: The high-resolution camera is connected to the computer via a USB 3.0 interface, and the collected images can be transferred to the computer for storage and processing. Pycharm is used in the computer to complete the processing of image data, including image preprocessing, extraction of characteristic information of kidney bean seeds, and model establishment.
[0099] After the acquisition system is built, image acquisition is performed; the specific process is as follows:
[0100] (1) Place a single bean seed on a stage;
[0101] (2) Adjust the camera focal length and fill light brightness to obtain the most appropriate seed image, that is, to ensure that the seed image is clearly visible and has no reflections or shadows;
[0102] (3) Collect all seed images one by one and number the image samples according to the variety category. Among them, "Fengguan", "Qingguan", "Xiaguan", "Baiguan", "Yuguan" and "Shengguan" correspond to 1 to 6 respectively.
[0103] 3. Divide the data set; collect image samples of each variety, and use the holdout method to divide the image samples of each variety into training samples and test samples in a ratio of 7:3. All training samples are combined to form a training set, and all test samples are combined to form a test set. At this time, there are 1925 kidney bean samples in the training set and 826 kidney bean samples in the test set. The sample distribution of kidney bean seeds is shown in Table 1.
[0104] Table 1 Sample distribution of kidney bean seeds
[0105]
[0106]
[0107] 4. Perform image preprocessing on the data set samples and extract the color features and pattern features of the seed samples. Figure 3 This is a flowchart of image preprocessing and feature extraction. There are three categories of image features extracted, including color features, pattern features and geometric features, including the main color, pattern color, aspect ratio, size and number of patterns of kidney bean seeds, a total of 9 features as the main characteristic parameters for identifying kidney bean seed varieties. First, the main color, pattern color and number of patterns of kidney bean seeds are extracted, and the Gaussian filter is used to remove the noise points in the image to retain the important details and features in the original image; the original image is converted into a binary image according to the pattern color threshold, the background is set to black, and the seed pattern part is highlighted in turn, and then the Canny edge extraction algorithm is used to extract the pattern contour and save it, and the "open" operation is used to smooth the pattern contour, disconnect the narrow space and eliminate the small protrusions, so as to extract a relatively complete pattern part; finally, the number of pixels in each pattern contour is read, the contours with fewer pixels are discarded, and the number of remaining contours is calculated, that is, the number of patterns is obtained. In the above process, the color threshold and the threshold of the outline with fewer pixels need to be determined through testing and adjustment. This process is also applicable to bean seeds without patterns, that is, if the number of patterns returned after testing is "0", it can be determined that the seeds have no patterns.
[0108] As for the extraction of the main color of kidney beans, the kidney bean image is first masked using the previously extracted pattern color, that is, the extracted pattern pixel color is set to 0 to obtain a mask image, which is then ANDed with the original image to obtain the main color features of the kidney bean.
[0109] 5. Perform image preprocessing on the samples of the data set and extract the geometric features of the seed samples. The geometric features of the appearance of the kidney bean seeds are extracted, mainly the entire seed part. First, the original image is binarized using the Otsu algorithm, and the original image is processed by bilateral filtering; then the overall contour of the kidney bean seed is extracted using the contour search and contour extraction algorithm in OpenCV, and the number of pixels in the contour is obtained. The actual area of the kidney bean seed is represented or converted as the size of the kidney bean seed by a ratio; finally, the minimum circumscribed rectangle of the kidney bean seed is obtained, and the length and width of the rectangle are obtained, and the ratio of the two is used as the aspect ratio of the kidney bean seed.
[0110] According to the above feature extraction process, the present invention randomly selects 4 seeds from 6 varieties of kidney bean seeds as sample images. Figure 4 The 24 seed images are shown above. By visually analyzing the six varieties of kidney bean seeds, it can be found that Fengguan and Shengguan seeds have more patterns, Qingguan and Yuguan have two types of colors, and Xiaguan and Baiguan have no variegated colors. In addition, the sizes and colors of kidney bean seeds of different varieties are also different, which also shows that the present invention has a high feasibility in classifying kidney bean seeds by using images.
[0111] In order to be more convincing, the present invention also extracts 9 types of features of the above 24 seeds respectively, and introduces the minimum, maximum, mean and variance of each feature, see Table 2. From the perspective of data variance, when comparing seeds of the same variety, the color data variance is larger, that is, the color difference of seeds of the same variety is also larger; the aspect ratio and seed area data variance are very small, which can reflect that the seed size is relatively uniform. Comparing seeds of different varieties, it can be found that the color of seeds of different varieties is quite different. Analysis of color, pattern and other characteristics shows that the color of seeds of various varieties is arranged from light to dark as follows: Baiguan, Yuguan, Fengguan, Qingguan, Xiaguan, Shengguan; among them, Fengguan and Xiaguan seeds are larger, Baiguan seeds are the smallest, and Qingguan, Yuguan and Shengguan seeds are of medium size; Baiguan has no pattern, Yuguan, Qingguan and Xiaguan have a small number of patterns, and only Fengguan and Shengguan have a large number of patterns, which can be seen as obvious differences from other varieties of seeds.
[0112] Table 2 Statistical distribution of bean seed characteristics
[0113]
[0114]
[0115] 6. Training the classification model. The original image features extracted from the training set are used as the input of the model, and the variety labels of the predicted training set seed samples are used as the output to preliminarily establish a support vector machine (SVM) classification model. The established SVM model is optimized using the grid search method, and four kernel functions, namely the linear kernel function, the polynomial kernel function, the Gaussian kernel function, and the Sigmoid kernel function, are selected for testing. The results show that after 5-fold cross validation, the highest classification accuracy of the linear kernel function is 0.976998, and the penalty coefficient c is 45.
[0116] 7. Test the classification model and obtain the recognition results. The trained SVM model is tested using the test set samples, and the classification accuracy of the SVM classification model is 0.9770, the F1 value is 0.9770, and the confusion matrix is shown in Table 3.
[0117] Table 3 Confusion matrix of SVM classification model
[0118]
[0119] Example 2
[0120] 1. Steps 1-5 are the same as steps 1-5 in Example 1.
[0121] 2. Use the training set samples to build a K-nearest neighbor (KNN) model, and tune the model parameters through 5-fold cross validation in the training data, and finally determine that the number of nearest neighbor samples k is 7.
[0122] 3. If Figure 5 As shown in Table 4, the trained KNN model is tested using the test set samples, and the accuracy is 0.9406, the F1 value is 0.9407, and the confusion matrix is shown in Table 4.
[0123] Table 4 Confusion matrix of KNN classification model
[0124]
[0125] Example 3
[0126] 1. Steps 1-5 are the same as steps 1-5 in Example 1.
[0127] 2. A random forest (RF) model was established using the training set samples. The model parameters were tuned through 5-fold cross validation in the training data. Finally, the number of trees in the model was determined to be 60, the number of features considered for each node split was 6, the depth of the tree was 17, the minimum number of samples in the leaf node was 2, and the minimum number of leaves in the tree was 1.
[0128] 3. The trained RF model is tested using the test set samples, and the accuracy is 0.96, the F1 value is 0.96, and the confusion matrix is shown in Table 5.
[0129] Table 5 Confusion matrix of RF classification model
[0130]
[0131] Comprehensive examples 1-3, get Figure 5 From the results shown, we can find that the classification effect of the SVM model is significantly better than other models, and the accuracy and F1 value of SVM are both optimal. Figure 6 It is the classification accuracy of the three types of models on the six types of seeds in the test set. Figure 6 From Tables 3 to 5, it can be seen that the classification effect of the SVM model on the six varieties is above 95%, and the classification accuracy of the Baiguan and Shengguan varieties is 100%, while the misclassification rate of KNN and RF for each variety is relatively high. After comparative analysis and comprehensive consideration of the actual application, the classification performance of the SVM model established in Example 1 is the best, and it can accurately and quickly realize the classification of kidney bean seeds.
[0132] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for intelligent identification and classification of bean seed varieties based on machine vision, characterized in that: The following steps are involved: Photograph different varieties of kidney bean seeds to obtain original images of kidney bean seeds; The original image is divided into a training set and a test set, and preprocessed, and the appearance features and geometric features of kidney bean seeds are extracted; wherein the training set is a set of training samples of kidney bean seeds of various varieties; the test set is a set of test samples of kidney bean seeds of various varieties; The preliminary classification model is trained using the appearance features and geometric features extracted from the training set, and after parameter tuning, a trained classification model is obtained; Based on the trained classification model, the bean seeds to be identified and classified are identified and classified.
2. The method for intelligent identification and classification of bean seed varieties based on machine vision according to claim 1, characterized in that: The photographing of different varieties of kidney bean seeds includes the following processes: Constructing a kidney bean seed image acquisition system; wherein the image acquisition system comprises: a high-resolution camera, a ring fill light, a sample stage, a light shielding box and a computer; The high-resolution camera is used to photograph the characteristics of kidney bean seeds to obtain an original image; The ring fill light is used to provide uniform and sufficient light for the high-resolution camera to ensure that the colors and details on the original image are accurately presented; The sample stage is used to place bean seeds to ensure that the bean seeds remain stable during the photographing process; The light shielding box is used to create a non-interference shooting environment to prevent external light interference; The computer is used to control the high-resolution camera to shoot, process the original image, and perform feature extraction; Place a single bean seed on the sample stage, and adjust the focus of the high-resolution camera and the brightness of the ring light to obtain a clear seed image without reflections and shadows; The original images of all bean seeds were collected one by one and numbered.
3. The method for intelligent identification and classification of bean seed varieties based on machine vision according to claim 1, characterized in that: The training set is a set of training samples of various varieties of kidney bean seeds; the test set is a set of test samples of various varieties of training samples, specifically: The holdout method was used to divide different varieties of bean seeds into training samples and test samples in a ratio of 7:
3.
4. The method for intelligent identification and classification of bean seed varieties based on machine vision according to claim 1, characterized in that: The method of extracting the appearance characteristics of kidney bean seeds includes: extracting the color characteristics and pattern characteristics of kidney bean seeds; The color characteristics include: the main body color, body color and pattern color of kidney bean seeds; The pattern features include: the number of patterns; Extracting the main color and pattern color of the kidney bean seeds, including: extracting the average value of the three channels of RGB and the number of patterns for each color, a total of 7 features; Extracting the body color and pattern color of the kidney bean seeds, including: extracting the average value of the three channels of RGB for each color, a total of 6 features; The geometric characteristics include: aspect ratio and seed size.
5. The method for intelligent identification and classification of bean seed varieties based on machine vision according to claim 1, characterized in that: The preliminary classification model is specifically: a support vector machine classification model; The construction method of the support vector machine classification model is: The appearance features and geometric features extracted from the training set are used as input, and the true variety labels of the seed samples in the training set are used as output. After 5-fold cross-validation, the parameters are tuned, the penalty coefficient is set to 45, and a preliminary classification model is constructed using a linear kernel function.
6. The method for intelligent identification and classification of bean seed varieties based on machine vision according to claim 4, characterized in that: The original image is divided into a training set and a test set, preprocessed, and the appearance features and geometric features of the kidney bean seeds are extracted respectively; wherein the preprocessing and the extraction of the appearance features of the kidney bean seeds include the following steps: Use Gaussian filter to remove noise points in the original image; Set a suitable color threshold to convert the original image into a binary image; The edge contour of the pattern in the original image is extracted and saved based on the Canny edge extraction algorithm, and the morphological opening operation is used to smooth the contour line of the pattern, disconnect the narrow space and eliminate the small protrusions; Read the number of pixels in each contour, discard the contours with fewer pixels, calculate and count the number of remaining contours to obtain the number of patterns; The extracted pattern color is used to create a mask, and the pixel value of the extracted pattern area is set to 0 to generate a mask image. The mask image is then logically ANDed with the original image to obtain the color features of the bean itself.
7. The method for intelligent identification and classification of bean seed varieties based on machine vision according to claim 4, characterized in that: The original image is divided into a training set and a test set, and preprocessed, and the appearance features and geometric features of the seed sample are extracted; wherein the preprocessing and the extraction of the geometric features of the seed sample include the following steps: The original image is binarized using the Otsu algorithm and bilaterally filtered; The overall outline of the bean seed is extracted using the contour search and contour extraction algorithm in OpenCV, the number of pixels in the outline is obtained, and the actual area of the bean seed is represented or converted as the size of the seed by a ratio; Find the minimum circumscribed rectangle of the bean seed, obtain the length and width of the rectangle, and use the ratio of the length to the width of the rectangle as the aspect ratio of the seed.