Vegetable verification method and system based on image recognition
By combining convolutional neural networks, U-Net models, support vector machines, and K-nearest neighbor algorithms, the accuracy problem of identification and evaluation in traditional vegetable verification methods has been solved, achieving efficient and accurate vegetable classification and quality control.
Patent Information
- Application Number
- CN202311799703.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-26
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2043-12-26
AI Technical Summary
Traditional vegetable verification methods are difficult to distinguish accurately when identifying multiple types of vegetables, the quality assessment is not scientific enough, and there is a lack of anomaly detection methods, which leads to misjudgments and inaccurate assessment results.
Convolutional neural networks are used for feature extraction, combined with the U-Net model for image segmentation, support vector machines and K-nearest neighbors are used for classification, random forests or gradient boosters are used for quality assessment, isolated forests or autoencoders are used for anomaly detection, deep learning models are used for maturity and freshness assessment, and image processing algorithms are used for size and shape measurement.
It improves the accuracy and efficiency of vegetable identification, ensures the accuracy of classification results, promptly detects anomalies, and provides comprehensive and accurate quality assessment and measurement reports.
Smart Images

Figure CN117475240B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a vegetable verification method and system based on image recognition. Background Art
[0002] The field of image recognition technology is a rapidly developing area involving computer vision and machine learning, focusing on enabling computers and systems to recognize, interpret, and process image data. In this field, technology generally involves identifying objects, features, shapes, and colors in images. Image recognition technology has applications in a variety of fields, such as security monitoring, industrial automation, medical imaging analysis, traffic control systems, and object identification in industries such as retail and agriculture. With the development of deep learning and neural networks, the accuracy and speed of image recognition have been significantly improved, making this technology more reliable and widely used.
[0003] Among them, the vegetable verification method based on image recognition is a method that uses image recognition technology to identify and verify vegetables. The purpose of this method is to automate and simplify the process of vegetable classification and quality control, and improve efficiency and accuracy. By using image recognition, this method can quickly identify different types of vegetables and detect their characteristics such as freshness, size, shape and color, so as to achieve fast and accurate verification of vegetables. This is particularly important in the fields of retail, warehousing, logistics and agriculture, because it can help to quickly process a large number of vegetables while reducing human errors. The implementation of the vegetable verification method based on image recognition is usually achieved by integrating high-resolution cameras and advanced image processing algorithms. The camera captures images of vegetables, and then these images are fed into the image processing system, which is usually based on deep learning models, such as convolutional neural networks (CNNs), to analyze and identify features in the images. These systems are trained with a large number of vegetable images and are able to learn to identify different types of vegetables and their quality standards. In addition, the system can also improve its recognition ability under different lighting conditions and backgrounds through further algorithm optimization to ensure effectiveness and accuracy in various practical application environments.
[0004] Traditional vegetable verification methods have multiple shortcomings. When there are many types of vegetables with similar appearances, traditional methods are difficult to distinguish accurately and are prone to misjudgment. In addition, traditional quality assessment and defect detection mainly rely on appearance and simple size measurement, which makes it difficult to accurately assess the freshness and health of vegetables. In terms of abnormal pattern detection, traditional methods usually lack effective means, making it difficult to detect and deal with abnormal situations in a timely manner, affecting the overall quality control effect. For the assessment of the maturity and freshness of vegetables, traditional methods lack scientific and systematic assessment methods, and the assessment results are often subjective and inaccurate. Summary of the invention
[0005] The purpose of the present invention is to solve the shortcomings existing in the prior art and to propose a vegetable verification method and system based on image recognition.
[0006] In order to achieve the above object, the present invention adopts the following technical scheme: a vegetable verification method based on image recognition, comprising the following steps:
[0007] S1: Based on vegetable images, a convolutional neural network is used to extract features and generate a vegetable feature set;
[0008] S2: Based on the vegetable feature set, a U-Net model is used to perform image segmentation to generate a segmented vegetable image;
[0009] S3: Based on the vegetable feature set, a support vector machine and a K-nearest neighbor algorithm are used to classify the vegetables to generate a classification result of vegetable types;
[0010] S4: Based on the segmented vegetable images, a random forest or gradient boosting algorithm is used to perform quality assessment and defect detection to generate a vegetable quality and defect report;
[0011] S5: Based on the vegetable quality and defect report, an abnormal pattern detection is performed using an isolation forest or autoencoder algorithm to generate an abnormality detection report;
[0012] S6: Based on the classification results of the vegetable types, a deep learning model is used to evaluate maturity and freshness, and a maturity and freshness evaluation report is generated;
[0013] S7: Based on the segmented vegetable image, using an image processing algorithm to measure the size and shape, and generating a vegetable size and shape measurement report;
[0014] The vegetable feature set includes shape descriptors, color histograms and texture features. The segmented vegetable image is specifically an independent image of each vegetable. The vegetable type classification result includes category labels for multiple vegetables. The vegetable quality and defect report includes freshness grade, size data and color health. The anomaly detection report includes identified surface anomaly patterns. The maturity and freshness assessment report includes the maturity stage and freshness status of multiple vegetables. The vegetable size and shape measurement report includes the length, width and volume information of each vegetable.
[0015] As a further solution of the present invention, based on the vegetable image, a convolutional neural network is used to extract features, and the steps of generating a vegetable feature set are specifically as follows:
[0016] S101: Based on the vegetable image, an image preprocessing technology is used to process the vegetable image to generate a preprocessed vegetable image dataset;
[0017] S102: Based on the preprocessed vegetable image dataset, a convolutional neural network is used to perform feature learning to generate a preliminary feature representation of the vegetable image;
[0018] S103: Based on the preliminary feature representation of the vegetable image, an activation function and batch normalization are used to generate an optimized feature representation of the vegetable image;
[0019] S104: Based on the optimized vegetable image feature representation, a fully connected layer and a softmax classifier are used for classification to generate a vegetable feature set;
[0020] The image preprocessing technology includes image resizing, color space conversion and histogram equalization, the convolutional neural network includes multiple convolutional layers, ReLU activation layers and maximum pooling layers, the batch normalization is specifically standardized processing, and the softmax classifier is used to convert feature vectors into probability distributions.
[0021] As a further solution of the present invention, based on the vegetable feature set, the U-Net model is used to perform image segmentation, and the steps of generating segmented vegetable images are specifically as follows:
[0022] S201: Based on the vegetable feature set, use an encoder of a U-Net model to perform feature downsampling to generate a feature downsampling representation;
[0023] S202: Based on the vegetable feature set, a decoder of a U-Net model is used to perform feature upsampling to generate a feature upsampling representation;
[0024] S203: Based on the feature up-sampling representation and the feature down-sampling representation, a skip connection technique is applied to fuse the features of the encoder and the decoder to generate a fused feature representation;
[0025] S204: Based on the fusion feature representation, a pixel-by-pixel classifier is used to perform pixel-level classification to generate a segmented vegetable image;
[0026] The encoder includes multiple layers of convolutional layers and pooling layers, the decoder includes upsampling layers and convolutional layers, the jump connection technology combines the features of the encoder with the decoder, and the pixel-by-pixel classifier is specifically a pixel-by-pixel softmax.
[0027] As a further solution of the present invention, based on the vegetable feature set, a support vector machine and a K-nearest neighbor algorithm are used to classify vegetables, and the steps of generating vegetable type classification results are specifically as follows:
[0028] S301: Based on the vegetable feature set, using data preprocessing technology, performing feature standardization and dimensionality reduction processing to generate preprocessed vegetable feature data;
[0029] S302: Based on the preprocessed vegetable feature data, a support vector machine algorithm is used to perform nonlinear classification using a radial basis function kernel to generate a support vector machine classification result;
[0030] S303: Based on the support vector machine classification result, a K-nearest neighbor algorithm is used to improve the classification accuracy through weighted distance measurement to generate a K-nearest neighbor classification result;
[0031] S304: Based on the support vector machine classification result and the K-nearest neighbor classification result, model fusion and result optimization are performed to generate a vegetable type classification result;
[0032] The data preprocessing technology is specifically principal component analysis and Z score normalization, the support vector machine algorithm is specifically an SVM classifier using an RBF kernel, the K-nearest neighbor algorithm is specifically a weighted Euclidean distance metric, and the model fusion is specifically a voting method and a confidence weighted method.
[0033] As a further solution of the present invention, based on the segmented vegetable images, a random forest or gradient boosting algorithm is used to perform quality assessment and defect detection, and the steps of generating a vegetable quality and defect report are specifically as follows:
[0034] S401: Based on the segmented vegetable image, feature engineering technology is used to extract key features to generate vegetable image feature data;
[0035] S402: Based on the vegetable image feature data, a random forest algorithm is used to perform quality assessment to generate a random forest quality assessment result;
[0036] S403: Based on the random forest quality assessment result, a gradient boosting algorithm is used to perform defect detection to generate a gradient boosting algorithm defect detection result;
[0037] S404: Based on the random forest quality assessment results and the gradient boosting machine defect detection results, a vegetable quality and defect report is generated using statistical analysis and data visualization methods;
[0038] The feature engineering technology is specifically Gabor filter and gray-level co-occurrence matrix, the random forest algorithm is specifically multi-tree construction based on information gain, and the gradient boosting algorithm is specifically iterative decision tree construction based on negative gradient optimization.
[0039] As a further solution of the present invention, based on the vegetable quality and defect report, an isolation forest or autoencoder algorithm is used to detect abnormal patterns, and the steps of generating an abnormal detection report are specifically as follows:
[0040] S501: Based on the vegetable quality and defect report, an isolation forest algorithm is used to perform preliminary abnormal data identification and generate a preliminary abnormal data identification report;
[0041] S502: Based on the preliminary abnormal data identification report, apply the autoencoder algorithm to perform deep abnormal data analysis to generate a deep abnormal data analysis report;
[0042] S503: Based on the deep abnormal data analysis report, perform data cleaning, remove or correct abnormal data, and generate a cleaned data set;
[0043] S504: applying the isolation forest algorithm to the cleaned data set again to perform abnormal pattern detection and generate a final abnormality detection report;
[0044] The isolation forest algorithm specifically constructs a random forest and uses the path length of the tree structure to identify outliers. The autoencoder algorithm includes an encoding process and a decoding process. The data cleaning includes processing missing values, removing outliers, and normalizing data.
[0045] As a further solution of the present invention, based on the vegetable type classification results, a deep learning model is used to evaluate maturity and freshness, and the steps of generating a maturity and freshness evaluation report are specifically as follows:
[0046] S601: Based on the vegetable type classification result, a convolutional neural network is used to extract vegetable image features to generate a vegetable image feature data set;
[0047] S602: Based on the vegetable image feature dataset, a deep learning classification model is used to perform a preliminary maturity assessment and generate a preliminary maturity assessment report;
[0048] S603: Based on the preliminary maturity assessment report, the long short-term memory network is used to assess the freshness of the vegetables and generate a freshness assessment report;
[0049] S604: synthesizing the preliminary maturity assessment report and the freshness assessment report, and using data fusion technology to generate a maturity and freshness assessment report;
[0050] The convolutional neural network includes a convolutional layer, a pooling layer and a fully connected layer. The deep learning classification model specifically uses a neural network to analyze image features. The long short-term memory network includes processing time series data to capture freshness characteristics that change over time. The data fusion technology specifically extracts comprehensive conclusions through weighted analysis of multi-dimensional evaluation results.
[0051] As a further solution of the present invention, based on the segmented vegetable image, the steps of using an image processing algorithm to measure the size and shape and generate a vegetable size and shape measurement report are specifically as follows:
[0052] S701: Based on the segmented vegetable image, extract the vegetable contour through Canny edge detection to generate vegetable contour data;
[0053] S702: performing geometric shape analysis based on the vegetable contour data to measure the vegetable shape and generate vegetable shape feature data;
[0054] S703: Execute digital image processing technology based on the vegetable shape feature data to measure the vegetable size and generate vegetable size data;
[0055] S704: Execute data fusion technology based on the vegetable shape feature data and the vegetable size data, comprehensively analyze the size and shape of the vegetables, and generate a vegetable size and shape measurement report;
[0056] The Canny edge detection includes applying Gaussian blur to remove noise, calculating gradients, and applying non-maximum suppression and double threshold detection to determine edges. The geometric shape analysis includes the Douglas-Peucker algorithm and calculating shape descriptors. The digital image processing technology includes using pixel ratio conversion to estimate the actual size of an object. The data fusion technology includes multi-source data analysis and weighted averaging.
[0057] A vegetable verification system based on image recognition, the vegetable verification system based on image recognition is used to execute the above-mentioned vegetable verification method based on image recognition, the system includes a vegetable feature extraction module, an image segmentation module, a vegetable classification module, a quality assessment and defect detection module, an abnormal pattern detection module, and a maturity and freshness assessment module.
[0058] As a further solution of the present invention, the vegetable feature extraction module uses a convolutional neural network to extract features based on vegetable images, performs image preprocessing and feature optimization, and generates a vegetable feature set;
[0059] The image segmentation module uses a U-Net model to perform image segmentation based on a vegetable feature set, and performs feature fusion to generate a segmented vegetable image;
[0060] The vegetable classification module generates vegetable type classification results based on the vegetable feature set and applies data preprocessing technology and classification algorithms;
[0061] The quality assessment and defect detection module generates vegetable quality and defect reports based on segmented vegetable images and applying feature engineering techniques and quality assessment algorithms;
[0062] The abnormal pattern detection module uses isolation forest and autoencoder algorithms to identify and analyze abnormal data based on vegetable quality and defect reports, and generates an abnormal detection report;
[0063] The maturity and freshness assessment module uses a deep learning model to perform maturity and freshness assessment based on the vegetable type classification results and generates a maturity and freshness assessment report.
[0064] Compared with the prior art, the advantages and positive effects of the present invention are:
[0065] In the present invention, the image segmentation realized by the U-Net model accurately identifies the independent image of each vegetable, which greatly improves the accuracy and efficiency of image processing. The support vector machine and K-nearest neighbor algorithm are combined to classify vegetables, so that the classification results are more accurate and adaptable to a variety of vegetable types. Random forest or gradient boosting machine algorithms are used for quality assessment and defect detection, which improves the accuracy and reliability of the assessment. The use of isolation forest or autoencoder algorithms shows efficient recognition ability in abnormal pattern detection, and abnormal situations are discovered and handled in a timely manner. The deep learning model evaluation of maturity and freshness ensures the comprehensiveness and depth of the evaluation. The image processing algorithm is used to accurately measure the size and shape of vegetables, providing auxiliary information for the classification and quality assessment of vegetables. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 It is a schematic diagram of the workflow of the present invention;
[0067] Figure 2 This is a detailed flow chart of S1 of the present invention;
[0068] Figure 3 This is a detailed flow chart of S2 of the present invention;
[0069] Figure 4 This is a detailed flow chart of S3 of the present invention;
[0070] Figure 5 This is a detailed flow chart of S4 of the present invention;
[0071] Figure 6 This is a detailed flow chart of S5 of the present invention;
[0072] Figure 7 This is a detailed flow chart of S6 of the present invention;
[0073] Figure 8 This is a detailed flow chart of S7 of the present invention;
[0074] Fig. 9 It is a system flow chart of the present invention. DETAILED DESCRIPTION
[0075] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0076] In the description of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, in the description of the present invention, "multiple" means two or more, unless otherwise clearly and specifically defined.
[0077] Example 1: Please refer to Figure 1 The present invention provides a technical solution: a vegetable verification method based on image recognition, comprising the following steps:
[0078] S1: Based on vegetable images, a convolutional neural network is used to extract features and generate a vegetable feature set;
[0079] S2: Based on the vegetable feature set, the U-Net model is used for image segmentation to generate segmented vegetable images;
[0080] S3: Based on the vegetable feature set, support vector machine and K-nearest neighbor algorithm are used to classify vegetables and generate vegetable type classification results;
[0081] S4: Based on the segmented vegetable images, random forest or gradient boosting machine algorithms are used for quality assessment and defect detection to generate vegetable quality and defect reports;
[0082] S5: Based on the vegetable quality and defect reports, anomaly detection reports are generated by using isolation forest or autoencoder algorithms to detect abnormal patterns;
[0083] S6: Based on the classification results of vegetable types, a deep learning model is used to evaluate maturity and freshness, and a maturity and freshness assessment report is generated;
[0084] S7: Based on the segmented vegetable images, the image processing algorithm is used to measure the size and shape, and a vegetable size and shape measurement report is generated;
[0085] The vegetable feature set includes shape descriptors, color histograms and texture features. The segmented vegetable images are specifically independent images of each vegetable. The vegetable type classification results include category labels for multiple vegetables. The vegetable quality and defect report includes freshness grade, size data and color health. The anomaly detection report includes the identified surface abnormality patterns. The maturity and freshness assessment report includes the maturity stage and freshness status of multiple vegetables. The vegetable size and shape measurement report includes the length, width and volume information of each vegetable.
[0086] First, by using convolutional neural networks (CNN) for feature extraction and combining it with the U-Net model for image segmentation, this method can efficiently and accurately process complex vegetable images. Compared with traditional manual detection or simple machine vision methods, the combination of CNN and U-Net not only improves recognition accuracy, but also can handle more complex image backgrounds and vegetable morphology. This makes the feature set of vegetables richer and more accurate, including multi-dimensional information such as shape, color, and texture, thus providing a solid foundation for subsequent classification and evaluation.
[0087] Secondly, support vector machine and K-nearest neighbor algorithm are used for vegetable classification. This combination makes full use of the advantages of each algorithm and improves the accuracy of classification. Support vector machine performs well in classification problems with clear boundaries, while K-nearest neighbor is suitable for classification scenarios with less obvious boundaries. This dual mechanism ensures efficient and accurate classification of multiple categories of vegetables, which is especially important when dealing with a large number and diverse varieties of vegetables.
[0088] In terms of quality assessment and defect detection, the application of random forest or gradient boosting machine algorithms provides a comprehensive judgment of the freshness, size and color health of vegetables. These algorithms perform well in handling classification and regression problems with multiple features, and can accurately identify the quality of vegetables and any surface defects. This is crucial to ensure the quality of vegetables and food safety, especially in commercial-scale agricultural product sorting and processing.
[0089] The application of isolation forest or autoencoder algorithms for abnormal pattern detection further improves the system's ability to detect abnormal conditions. This is crucial for early detection of potential food safety issues, such as pests, rot or other surface defects. Timely identification and isolation of abnormal vegetables not only protects consumer health, but also reduces food waste.
[0090] In addition, the maturity and freshness assessment based on deep learning models, as well as the size and shape measurement of image processing algorithms, together provide a comprehensive vegetable quality analysis framework. This not only helps with the grading and pricing of agricultural products, but also optimizes supply chain management, such as more accurate inventory management and logistics planning.
[0091] See also Figure 2 ,Based on the vegetable images, the convolutional neural network is used for feature extraction, and the steps of generating the vegetable feature set are as follows:
[0092] S101: Based on the vegetable image, an image preprocessing technology is used to process the vegetable image to generate a preprocessed vegetable image dataset;
[0093] S102: Based on the preprocessed vegetable image dataset, a convolutional neural network is used to perform feature learning to generate a preliminary feature representation of the vegetable image;
[0094] S103: Based on the preliminary feature representation of the vegetable image, an activation function and batch normalization are used to generate an optimized feature representation of the vegetable image;
[0095] S104: Based on the optimized vegetable image feature representation, a fully connected layer and a softmax classifier are used for classification to generate a vegetable feature set;
[0096] Image preprocessing techniques include image resizing, color space conversion, and histogram equalization. The convolutional neural network includes multiple convolutional layers, ReLU activation layers, and maximum pooling layers. Batch normalization is specifically standardized processing. The softmax classifier is used to convert feature vectors into probability distributions.
[0097] In step S101, the vegetable image dataset is processed through image preprocessing techniques to prepare for feature extraction. This includes resizing the image to meet the input requirements of the convolutional neural network, converting the color space to improve the usability of the image data, and applying histogram equalization to enhance the image contrast. These preprocessing steps help reduce noise during model training and optimize the image data to make feature extraction more accurate and efficient.
[0098] In step S102, a convolutional neural network is used to learn features of the preprocessed vegetable image dataset. This process involves using multiple layers of convolutional layers, ReLU activation layers, and maximum pooling layers to extract and learn important features in the image. The convolutional layer helps capture the spatial and texture information in the image, the ReLU activation layer increases the nonlinear processing capability, and the maximum pooling layer is used to reduce the spatial dimension of the feature, thereby reducing the amount of calculation and preventing overfitting.
[0099] In step S103, based on the preliminary feature representation of the vegetable image, activation function and batch normalization are applied to generate an optimized feature representation of the vegetable image. The activation function increases the nonlinear characteristics of the network, allowing the model to capture more complex features. Batch normalization standardization helps speed up training, improve model stability, and reduce sensitivity to initialization weights.
[0100] In step S104, the fully connected layer and softmax classifier are used to classify the optimized vegetable image features to generate a vegetable feature set. The fully connected layer concentrates the features extracted by the previous layer into a vector, and the softmax classifier converts this feature vector into a probability distribution, thereby effectively classifying the vegetables. This step ensures that the features extracted from the image can be correctly classified, providing an accurate basis for subsequent vegetable type identification and quality assessment.
[0101] See also Figure 3 ,Based on the vegetable feature set, the U-Net model is used for image segmentation. The steps to generate segmented vegetable images are as follows:
[0102] S201: Based on the vegetable feature set, the encoder of the U-Net model is used to perform feature downsampling to generate feature downsampling representation;
[0103] S202: Based on the vegetable feature set, a decoder of the U-Net model is used to perform feature upsampling to generate a feature upsampling representation;
[0104] S203: Based on the feature upsampling representation and the feature downsampling representation, the skip connection technology is applied to fuse the features of the encoder and the decoder to generate a fused feature representation;
[0105] S204: Based on the fusion feature representation, a pixel-by-pixel classifier is used to perform pixel-level classification to generate a segmented vegetable image;
[0106] The encoder includes multiple convolutional layers and pooling layers, the decoder includes upsampling layers and convolutional layers, the skip connection technology combines the features of the encoder with the decoder, and the pixel-by-pixel classifier is specifically a pixel-by-pixel softmax.
[0107] In step S201, the encoder of the U-Net model is first used to extract features from the vegetable image. The encoder contains multiple convolutional layers and pooling layers, which are responsible for gradually reducing the spatial size of the image while increasing the depth of the feature channel. In this process, each convolutional layer extracts specific features in the image through the learned filter, while the pooling layer reduces the dimension of the data to help the model capture more abstract features. Finally, the encoder outputs a downsampled representation of the features, which provides rich feature information for subsequent steps.
[0108] In step S202, the decoder of the U-Net model is used to upsample the features. The decoder structure usually includes an upsampling layer and a convolution layer, which is responsible for gradually restoring the spatial size of the image. The upsampling layer expands the size of the feature map through techniques such as interpolation or transposed convolution, while the convolution layer continues to process the features. This process makes the feature map gradually approach the original image size, preparing for accurate segmentation.
[0109] In step S203, the features of the encoder and decoder are fused using the skip connection technique. The skip connection technique merges the high-resolution features in the encoder with the corresponding layer features in the decoder, which can retain more spatial information and details during the segmentation process. This fusion method helps improve the accuracy of the segmentation edges, especially when processing vegetable images with complex shapes or boundaries.
[0110] In step S204, based on the fused feature representation, a pixel-by-pixel classifier is used for pixel-level classification. The pixel-by-pixel classifier usually uses a softmax function, which can assign a category label to each pixel to achieve accurate image segmentation. In this way, the model can distinguish different vegetables and their backgrounds and generate clear segmented vegetable images. This step is the key to achieving high-quality image segmentation because it directly determines the accuracy and quality of the final output image.
[0111] See also Figure 4 ,Based on the vegetable feature set, the support vector machine and K-nearest neighbor algorithm are used to classify vegetables.,The steps to generate the classification results of vegetable types are as follows:
[0112] S301: Based on the vegetable feature set, a data preprocessing technology is used to perform feature standardization and dimensionality reduction processing to generate preprocessed vegetable feature data;
[0113] S302: Based on the preprocessed vegetable feature data, a support vector machine algorithm is used to perform nonlinear classification using a radial basis function kernel to generate a support vector machine classification result;
[0114] S303: Based on the support vector machine classification result, a K-nearest neighbor algorithm is used to improve the classification accuracy through weighted distance measurement to generate a K-nearest neighbor classification result;
[0115] S304: Based on the support vector machine classification results and the K-nearest neighbor classification results, model fusion and result optimization are performed to generate vegetable type classification results;
[0116] The data preprocessing techniques include principal component analysis and Z-score normalization, the support vector machine algorithm includes SVM classifier using RBF kernel, the K-nearest neighbor algorithm includes weighted Euclidean distance metric, and the model fusion includes voting method and confidence weighting method.
[0117] In step S301, the vegetable feature set is processed through data preprocessing techniques to lay a solid foundation for the subsequent classification algorithm, including dimensionality reduction using principal component analysis (PCA) to reduce the complexity and noise of the data while retaining the most critical features. Next, Z-score standardization is applied to normalize the features to ensure that different features have equal weight in the classification algorithm. These steps help improve the performance and accuracy of the subsequent classification model.
[0118] In step S302, the support vector machine (SVM) algorithm is used to classify vegetables. The radial basis function (RBF) kernel is specially selected here to deal with nonlinear classification problems. The RBF kernel helps to effectively distinguish the characteristics of different categories of vegetables in high-dimensional space, thereby improving the accuracy of classification. The support vector machine algorithm generates preliminary classification results in this step, providing a strong mathematical basis for the identification of vegetable types.
[0119] In step S303, based on the classification results of the support vector machine, the K-nearest neighbor (KNN) algorithm is further applied for classification. In this process, the weighted Euclidean distance metric is used to make the distance calculation more accurate and improve the classification accuracy. The K-nearest neighbor algorithm generates a second classification result on this basis, which enhances the robustness and accuracy of the classification by considering the distance between the vegetable features and their nearest neighbors.
[0120] In step S304, the voting method and the confidence weighting method are comprehensively applied to perform model fusion and result optimization. This process intelligently fuses the classification results of the support vector machine and the K-nearest neighbor algorithm to optimize the final classification results of vegetable types. Model fusion not only improves the accuracy of the classification results, but also increases the generalization ability of the model, making the final classification results more reliable and robust.
[0121] See also Figure 5 ,Based on the segmented vegetable images, random forest or gradient boosting machine algorithm is used for quality assessment and defect detection.,The specific steps of generating vegetable quality and defect reports are as follows:
[0122] S401: Based on the segmented vegetable image, feature engineering technology is used to extract key features to generate vegetable image feature data;
[0123] S402: Based on the vegetable image feature data, a random forest algorithm is used to perform quality assessment to generate a random forest quality assessment result;
[0124] S403: Based on the random forest quality assessment result, a gradient boosting algorithm is used to perform defect detection, and a gradient boosting algorithm defect detection result is generated;
[0125] S404: Generate vegetable quality and defect reports based on the random forest quality assessment results and gradient boosting machine defect detection results using statistical analysis and data visualization methods;
[0126] The feature engineering technology specifically includes Gabor filter and gray-level co-occurrence matrix, the random forest algorithm specifically includes multi-tree construction based on information gain, and the gradient boosting machine algorithm specifically includes iterative decision tree construction based on negative gradient optimization.
[0127] In step S401, the key features of the segmented vegetable images are extracted through feature engineering technology. Specifically, two technologies, Gabor filter and gray-level co-occurrence matrix, are used. Gabor filter is widely used in image processing to capture texture information in a specific direction and scale, while gray-level co-occurrence matrix is used to extract texture features of images, such as contrast, consistency and entropy. These features reflect important information such as the surface texture and color uniformity of vegetables, providing a data basis for subsequent quality assessment and defect detection.
[0128] In step S402, the random forest algorithm is used to evaluate the quality of the vegetable image feature data. Random forest is an ensemble learning method that improves the accuracy of prediction by building multiple decision trees and combining their prediction results. In this step, a multi-tree construction strategy based on information gain is used to identify and evaluate the quality of vegetables, such as maturity, freshness, etc. The advantage of random forest lies in its flexibility in feature selection and resistance to overfitting, which makes it perform well when processing complex data sets.
[0129] In step S403, based on the random forest quality assessment results, the gradient boosting algorithm is used for defect detection. Gradient boosting is a powerful machine learning technique that optimizes the prediction model by iteratively building a decision tree. The algorithm pays special attention to the errors in the previous iteration and gradually improves the performance of the model through negative gradient optimization. In this step, the gradient boosting machine will be used to identify various defects in the vegetable images, such as spots, cracks, or foreign objects.
[0130] In step S404, the quality assessment results of random forest and the defect detection results of gradient boosting machine are combined to generate the quality and defect report of vegetables using statistical analysis and data visualization methods. This step aims to transform complex data and analysis results into easy-to-understand charts and reports, so that users can quickly grasp the overall quality status of vegetables. The visualization report can include information such as quality grade distribution, defect type and severity, providing a basis for classification, quality control and further processing of vegetables.
[0131] See also Figure 6 ,Based on the vegetable quality and defect reports, the isolation forest or autoencoder algorithm is used to detect abnormal patterns.,The specific steps for generating anomaly detection reports are:
[0132] S501: Based on the vegetable quality and defect report, the isolation forest algorithm is used to perform preliminary abnormal data identification and generate a preliminary abnormal data identification report;
[0133] S502: Based on the preliminary abnormal data identification report, apply the autoencoder algorithm to perform deep abnormal data analysis and generate a deep abnormal data analysis report;
[0134] S503: Based on the deep abnormal data analysis report, perform data cleaning, remove or correct abnormal data, and generate a cleaned data set;
[0135] S504: applying the isolation forest algorithm to the cleaned data set again to perform abnormal pattern detection and generate a final abnormality detection report;
[0136] The isolation forest algorithm specifically constructs a random forest and uses the path length of the tree structure to identify outliers. The autoencoder algorithm includes encoding and decoding processes. Data cleaning includes processing missing values, removing outliers, and normalizing data.
[0137] In step S501, preliminary abnormal data identification is performed using the isolation forest algorithm. This algorithm constructs a random forest and uses the path length of the tree structure to identify abnormal points, which is suitable for processing large-scale data sets. Based on the vegetable quality and defect reports, the isolation forest algorithm effectively identifies those outliers that are significantly different from the majority of the data. The generated preliminary abnormal data identification report provides a preliminary understanding of potential problems.
[0138] In step S502, an autoencoder algorithm is applied to perform deep abnormal data analysis. An autoencoder is an algorithm based on a neural network, including an encoding process and a decoding process, which can learn high-level feature representations of data. In this way, the initially identified abnormal data can be further analyzed to reveal possible abnormal patterns or trends. The generated deep abnormal data analysis report provides a deeper perspective for identifying and understanding abnormal data.
[0139] In step S503, data cleaning is performed to remove or correct abnormal data. This includes processing missing values, removing outliers, and normalizing data. This process ensures the quality and consistency of the data set, laying a solid foundation for further data analysis and model training.
[0140] In step S504, the isolation forest algorithm is applied again to the cleaned data set for abnormal pattern detection. This step is to verify the effect of data cleaning and ensure that the final data set no longer contains obvious outliers. The generated final anomaly detection report provides a comprehensive assessment of vegetable quality and defects, providing an important basis for subsequent quality control and processing decisions.
[0141] See also Figure 7 Based on the classification results of vegetable types, a deep learning model is used to evaluate maturity and freshness. The steps to generate a maturity and freshness evaluation report are as follows:
[0142] S601: Based on the classification results of vegetable types, a convolutional neural network is used to extract vegetable image features to generate a vegetable image feature dataset;
[0143] S602: Based on the vegetable image feature dataset, a deep learning classification model is used to perform a preliminary maturity assessment and generate a preliminary maturity assessment report;
[0144] S603: Based on the preliminary maturity assessment report, the long short-term memory network is used to assess the freshness of the vegetables and generate a freshness assessment report;
[0145] S604: Integrate the preliminary maturity assessment report and the freshness assessment report, and use data fusion technology to generate a maturity and freshness assessment report;
[0146] The convolutional neural network includes convolutional layers, pooling layers and fully connected layers. The deep learning classification model specifically uses neural networks to analyze image features. The long short-term memory network includes the processing of time series data to capture the freshness characteristics that change over time. The data fusion technology specifically extracts comprehensive conclusions through weighted analysis of multi-dimensional evaluation results.
[0147] In step S601, the convolutional neural network (CNN) is used to extract features from the vegetable images based on the classification results of vegetable species. The structure of CNN includes convolutional layers, pooling layers, and fully connected layers, which are specially designed to capture important visual features in the image. In this step, the features extracted from the vegetable images are organized into a dataset, which provides key input information for the assessment of maturity and freshness.
[0148] Step S602 uses a deep learning classification model to perform a preliminary maturity assessment on the vegetable image feature dataset. The neural network model used here analyzes the features extracted from the image to determine the maturity of the vegetables. The generated preliminary maturity assessment report provides an estimate of the maturity stage for each vegetable, laying the foundation for subsequent refined assessments.
[0149] In step S603, the long short-term memory network (LSTM) is used to evaluate the freshness of vegetables. LSTM is particularly suitable for processing time series data and can capture features that change over time, such as color changes and softening of vegetables. The freshness assessment report generated in this step provides an in-depth analysis of the freshness of vegetables.
[0150] In step S604, data fusion technology is used to integrate the assessment results of maturity and freshness. By weighted analysis of multi-dimensional assessment results, a comprehensive conclusion on the maturity and freshness of vegetables is extracted. This comprehensive assessment report provides a comprehensive and detailed perspective for the final quality judgment of vegetables, supporting more accurate classification and processing decisions.
[0151] See also Figure 8 ,Based on the segmented vegetable images, the image processing algorithm is used to measure the size and shape, and the steps of generating the vegetable size and shape measurement report are as follows:
[0152] S701: Based on the segmented vegetable image, extract the vegetable contour through Canny edge detection to generate vegetable contour data;
[0153] S702: performing geometric shape analysis based on the vegetable contour data to measure the vegetable shape and generate vegetable shape feature data;
[0154] S703: Execute digital image processing technology based on the vegetable shape feature data to measure the vegetable size and generate vegetable size data;
[0155] S704: Execute data fusion technology based on the vegetable shape feature data and the vegetable size data, comprehensively analyze the size and shape of the vegetables, and generate a vegetable size and shape measurement report;
[0156] Canny edge detection includes applying Gaussian blur to remove noise, calculating gradients, and applying non-maximum suppression and double threshold detection to determine edges. Geometric shape analysis includes the Douglas-Peucker algorithm and calculating shape descriptors. Digital image processing technology includes using pixel ratio conversion to estimate the actual size of an object. Data fusion technology includes multi-source data analysis and weighted averaging.
[0157] In step S701, a Gaussian filter is used to smooth the image to reduce noise in the image, thereby reducing misjudgment in subsequent processing.
[0158] Code example:
[0159] import cv2;
[0160] image = cv2.imread('vegetable_image.jpg');
[0161] blurred = cv2.GaussianBlur(image, (5, 5), 0);
[0162] Calculate Gradients: Use the Sobel operator to calculate the horizontal and vertical gradients of the image to find the strength and direction of the edges.
[0163] Code example:
[0164] grad_x = cv2.Sobel(blurred, cv2.CV_64F, 1, 0, ksize=3);
[0165] grad_y = cv2.Sobel(blurred, cv2.CV_64F, 0, 1, ksize=3);
[0166] Non-maximum suppression: Used to refine edges.
[0167] In OpenCV, this step is done automatically inside the Canny function.
[0168] Dual Threshold Detection: Used to determine real and potential edges.
[0169] Code example:
[0170] edges = cv2.Canny(blurred, threshold1, threshold2);
[0171] In step S702, the Douglas-Peucker algorithm is used to simplify the contour and retain the main features.
[0172] In OpenCV, this can be achieved through approxPolyDP.
[0173] Compute shape descriptors: including perimeter, area, etc.
[0174] Code example:
[0175] contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE);
[0176] for contour in contours:
[0177] epsilon = 0.01 * cv2.arcLength(contour, True);
[0178] approx = cv2.approxPolyDP(contour, epsilon, True);
[0179] # Calculate descriptors like area, perimeter, etc.
[0180] area = cv2.contourArea(approx);
[0181] perimeter = cv2.arcLength(approx, True);
[0182] In step S703, the size of the vegetables is measured by applying digital image processing technology. This step uses the shape feature data of the vegetables, such as the outline and shape descriptors obtained from step S702. Using the pixel ratio conversion method, these features can be converted into actual physical dimensions, such as length, width and area. This requires a reference object of known size or a ruler in the image to accurately convert the pixel size into the actual size. Ultimately, this step generates detailed data about the size of the vegetables.
[0183] In step S704, the size and shape of the vegetables are comprehensively analyzed by performing data fusion techniques. This involves combining the vegetable size data obtained in step S703 with the previous vegetable shape feature data. Using multi-source data analysis and weighted average methods, information from different data sources can be comprehensively considered to improve the accuracy and reliability of the measurement. The final product of this step is a comprehensive vegetable size and shape measurement report that provides a comprehensive view of vegetable size, including key metrics and shape features.
[0184] See also Fig. 9 , a vegetable verification system based on image recognition, the vegetable verification system based on image recognition is used to execute the above-mentioned vegetable verification method based on image recognition, the system includes a vegetable feature extraction module, an image segmentation module, a vegetable classification module, a quality assessment and defect detection module, an abnormal pattern detection module, and a maturity and freshness assessment module.
[0185] The vegetable feature extraction module uses convolutional neural networks to extract features based on vegetable images, perform image preprocessing and feature optimization, and generate a vegetable feature set;
[0186] The image segmentation module uses the U-Net model to segment the image based on the vegetable feature set and performs feature fusion to generate segmented vegetable images;
[0187] The vegetable classification module generates vegetable classification results based on the vegetable feature set, applying data preprocessing technology and classification algorithms;
[0188] The quality assessment and defect detection module generates vegetable quality and defect reports based on segmented vegetable images and applies feature engineering techniques and quality assessment algorithms;
[0189] The abnormal pattern detection module uses isolation forest and autoencoder algorithms to identify and analyze abnormal data based on vegetable quality and defect reports and generate anomaly detection reports;
[0190] The maturity and freshness assessment module uses a deep learning model to evaluate maturity and freshness based on the vegetable type classification results and generates a maturity and freshness assessment report.
[0191] The vegetable feature extraction module uses convolutional neural networks to automatically extract features, which improves the accuracy and efficiency of feature recognition and significantly reduces the error rate and labor costs. The image segmentation module uses the U-Net model for high-precision image segmentation, accurately separating vegetable images from complex backgrounds, and providing a clear and accurate image basis for classification and quality assessment.
[0192] The vegetable classification module combines data preprocessing and classification algorithms to effectively classify vegetables into different categories, optimize supply chain management, and reduce economic losses caused by misclassification. The quality assessment and defect detection module uses feature engineering technology and quality assessment algorithms to comprehensively evaluate the quality of vegetables and identify defects, ensuring the quality of vegetables and providing consumers with safer food choices.
[0193] The abnormal pattern detection module uses the isolation forest and autoencoder algorithms to specifically identify and analyze abnormal data, which is crucial for early identification of food safety issues and preventing defective products from entering the market. The maturity and freshness assessment module uses a deep learning model to assess the maturity and freshness of vegetables, providing key information for the storage, transportation and sales of vegetables, and reducing food waste.
[0194] The above are only preferred embodiments of the present invention and are not intended to limit the present invention in other forms. Any technician familiar with the profession may use the technical contents disclosed above to change or modify them into equivalent embodiments with equivalent changes and apply them to other fields. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. Vegetable verification system based on image recognition, It is characterized in that It includes vegetable feature extraction module, image segmentation module, vegetable classification module, quality assessment and defect detection module, abnormal pattern detection module, maturity and freshness assessment module; The vegetable feature extraction module uses a convolutional neural network to extract features based on vegetable images, performs image preprocessing and feature optimization, and generates a vegetable feature set; The image segmentation module uses a U-Net model to perform image segmentation based on a vegetable feature set, and performs feature fusion to generate a segmented vegetable image; The vegetable classification module generates vegetable type classification results based on the vegetable feature set and applies data preprocessing technology and classification algorithms; The quality assessment and defect detection module generates vegetable quality and defect reports based on segmented vegetable images and applying feature engineering techniques and quality assessment algorithms; The abnormal pattern detection module uses isolation forest and autoencoder algorithms to identify and analyze abnormal data based on vegetable quality and defect reports, and generates an abnormal detection report; The maturity and freshness assessment module uses a deep learning model to perform maturity and freshness assessment based on the vegetable type classification results and generates a maturity and freshness assessment report; The vegetable feature set includes shape descriptors, color histograms, and texture features, the segmented vegetable image is specifically an independent image of each vegetable, the vegetable type classification result includes category labels of multiple vegetables, the vegetable quality and defect report includes freshness grade, size data, and color health, the anomaly detection report includes identified surface anomaly patterns, the maturity and freshness assessment report includes maturity stages and freshness conditions of multiple vegetables, and the vegetable size and shape measurement report includes length, width, and volume information of each vegetable; Based on the vegetable images, the convolutional neural network is used for feature extraction. The steps to generate the vegetable feature set are as follows: Based on the vegetable images, the image preprocessing technology is used to process them and generate a preprocessed vegetable image dataset; Based on the preprocessed vegetable image dataset, a convolutional neural network is used to perform feature learning to generate a preliminary feature representation of the vegetable image; Based on the preliminary feature representation of the vegetable image, an activation function and batch normalization are used to generate an optimized feature representation of the vegetable image; Based on the optimized vegetable image feature representation, a fully connected layer and a softmax classifier are used for classification to generate a vegetable feature set; The image preprocessing technology includes image resizing, color space conversion and histogram equalization, the convolutional neural network includes multiple convolutional layers, ReLU activation layers and maximum pooling layers, the batch normalization is specifically a standardization process, and the softmax classifier is used to convert the feature vector into a probability distribution; Based on the vegetable feature set, the U-Net model is used for image segmentation, and the steps of generating segmented vegetable images are specifically as follows: Based on the vegetable feature set, an encoder of a U-Net model is used to perform feature downsampling to generate a feature downsampling representation; Based on the vegetable feature set, a decoder of a U-Net model is used to perform feature upsampling to generate a feature upsampling representation; Based on the feature up-sampling representation and the feature down-sampling representation, a skip connection technique is applied to fuse the features of the encoder and the decoder to generate a fused feature representation; Based on the fusion feature representation, a pixel-by-pixel classifier is used to perform pixel-level classification to generate a segmented vegetable image; The encoder includes multiple convolutional layers and pooling layers, the decoder includes upsampling layers and convolutional layers, the jump connection technology combines the features of the encoder with the decoder, and the pixel-by-pixel classifier is specifically a pixel-by-pixel softmax; Based on the vegetable feature set, the steps of using support vector machine and K-nearest neighbor algorithm to classify vegetables and generate vegetable type classification results are as follows: Based on the vegetable feature set, a data preprocessing technology is used to perform feature standardization and dimensionality reduction processing to generate preprocessed vegetable feature data; Based on the preprocessed vegetable feature data, a support vector machine algorithm is used to perform nonlinear classification using a radial basis function kernel to generate a support vector machine classification result; Based on the support vector machine classification result, a K-nearest neighbor algorithm is used to improve the classification accuracy through weighted distance measurement to generate a K-nearest neighbor classification result; Based on the support vector machine classification results and the K-nearest neighbor classification results, model fusion and result optimization are performed to generate vegetable type classification results; The data preprocessing technology is specifically principal component analysis and Z score normalization, the support vector machine algorithm is specifically an SVM classifier using an RBF kernel, the K-nearest neighbor algorithm is specifically a weighted Euclidean distance metric, and the model fusion is specifically a voting method and a confidence weighted method; Based on the segmented vegetable images, the steps of using random forest or gradient boosting algorithm to perform quality assessment and defect detection and generate vegetable quality and defect reports are as follows: Based on the segmented vegetable image, feature engineering technology is used to extract key features to generate vegetable image feature data; Based on the vegetable image feature data, a random forest algorithm is used to perform quality assessment to generate a random forest quality assessment result; Based on the random forest quality assessment result, a gradient boosting machine algorithm is used to perform defect detection to generate a gradient boosting machine defect detection result; Based on the random forest quality assessment results and gradient boosting machine defect detection results, a vegetable quality and defect report is generated using statistical analysis and data visualization methods; The feature engineering technology is specifically Gabor filter and gray-level co-occurrence matrix, the random forest algorithm is specifically multi-tree construction based on information gain, and the gradient boosting algorithm is specifically iterative decision tree construction based on negative gradient optimization; Based on the vegetable quality and defect report, an abnormal pattern detection is performed using an isolation forest or autoencoder algorithm. The steps for generating an abnormal detection report are as follows: Based on the vegetable quality and defect report, an isolation forest algorithm is used to perform preliminary abnormal data identification and generate a preliminary abnormal data identification report; Based on the preliminary abnormal data identification report, applying an autoencoder algorithm to perform deep abnormal data analysis to generate a deep abnormal data analysis report; Based on the deep abnormal data analysis report, perform data cleaning, remove or correct abnormal data, and generate a cleaned data set; Applying the isolation forest algorithm to the cleaned data set again to perform abnormal pattern detection and generate a final anomaly detection report; The isolation forest algorithm specifically constructs a random forest and uses the path length of the tree structure to identify outliers. The autoencoder algorithm includes an encoding process and a decoding process. The data cleaning includes processing missing values, removing outliers, and normalizing data. Based on the classification results of the vegetable types, the deep learning model is used to evaluate the maturity and freshness, and the steps of generating a maturity and freshness evaluation report are as follows: Based on the vegetable type classification results, a convolutional neural network is used to extract vegetable image features to generate a vegetable image feature data set; Based on the vegetable image feature dataset, a deep learning classification model is used to perform a preliminary maturity assessment and generate a preliminary maturity assessment report; Based on the preliminary maturity assessment report, the long short-term memory network is used to assess the freshness of the vegetables and generate a freshness assessment report; Combining the preliminary maturity assessment report and the freshness assessment report, and using data fusion technology to generate a maturity and freshness assessment report; The convolutional neural network includes a convolutional layer, a pooling layer and a fully connected layer. The deep learning classification model specifically uses a neural network to analyze image features. The long short-term memory network includes processing time series data to capture freshness features that change over time. The data fusion technology specifically extracts comprehensive conclusions by weighted analysis of multi-dimensional evaluation results. Based on the segmented vegetable image, the steps of using the image processing algorithm to measure the size and shape and generate the vegetable size and shape measurement report are as follows: Based on the segmented vegetable image, extract the vegetable contour through Canny edge detection to generate vegetable contour data; Performing geometric shape analysis based on the vegetable contour data for measuring the vegetable shape and generating vegetable shape feature data; Execute digital image processing technology based on the vegetable shape feature data to measure the vegetable size and generate vegetable size data; Based on the vegetable shape feature data and the vegetable size data, a data fusion technology is performed to comprehensively analyze the size and shape of the vegetables and generate a vegetable size and shape measurement report; The Canny edge detection includes applying Gaussian blur to remove noise, calculating gradients, and applying non-maximum suppression and double threshold detection to determine edges. The geometric shape analysis includes the Douglas-Peucker algorithm and calculating shape descriptors. The digital image processing technology includes using pixel ratio conversion to estimate the actual size of an object. The data fusion technology includes multi-source data analysis and weighted averaging.
