Nondestructive walnut grading detection method based on ray technology
The lossless grading detection of walnuts is achieved through CT imaging and depth residual network model, solving the problem of walnut kernel color grading, and improving the grading efficiency and market value.
Patent Information
- Application Number
- CN202510358843.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-07-11
AI Technical Summary
The existing technology is difficult to effectively classify the color of walnut kernels, resulting in a decrease in the income of fruit farmers and affecting the economic value of the walnut industry.
The lossless walnut grading detection method based on ray technology is used to identify and classify walnuts through CT imaging and depth residual network model, including CT imaging, preprocessing, training sample annotation, model training and grading detection.
The non-destructive grading detection of walnuts has been realized, the grading efficiency has been improved, the cost has been reduced, the labor time and uncertainty of manual grading has been solved, and the market value of the walnut industry has been enhanced.
Smart Images

Figure CN120299031A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of walnut grading detection, and specifically, it is a non-destructive walnut grading detection method based on ray technology. Background Art
[0002] According to the current investigation of walnut kernels by consumers, the acceptance of white, yellow, and light yellow walnut kernels is higher than that of brown and dark brown kernels. The colors of black and brown kernels are misidentified by consumers as moldy and deteriorated walnut kernels. How to grade the colors of walnut kernels of nuts is the key to improving the commercialization rate of walnuts. Taking the 'Wen 185' walnut as an example, the irregular cultivation and management by fruit farmers have led to a more obvious browning phenomenon of the inner seed coat, seriously affecting the economic value of the 'Wen 185' walnut and resulting in a reduction in the income of fruit farmers.
[0003] Machine vision technology for walnut grading and walnut shell-breaking equipment provides a theoretical basis and practical guidance for grading walnut nuts. However, the research on solving the problems of black and browning of walnuts and further grading problems of in-shell walnut fruits is still in development. The color of walnut kernels is the most direct judgment of walnut quality by consumers, thus affecting the domestic demand supply of walnuts and having a certain impact on the walnut industry. Therefore, the development research on grading in-shell walnut fruits using non-destructive testing technologies such as X-ray and CT is carried out to directly understand the key data for fruit grading, such as the color and plumpness of walnut kernels, from the outside of in-shell walnuts. The present invention lays a theoretical foundation for the research on grading in-shell walnut fruits by observing the differences in images of walnuts under various experimental equipment. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a non-destructive walnut grading detection method based on ray technology for the above deficiencies.
[0005] The present invention adopts the following technical solutions:
[0006] A non-destructive walnut grading detection method based on ray technology, comprising the following steps:
[0007] Step 1: Perform CT imaging on in-shell walnuts of different sizes through a CT imaging device to obtain a number of walnut CT images. After preprocessing the CT images, use them as training samples. Then, break the walnuts and perform manual grading, and label the actual grades corresponding to the training samples;
[0008] Step 2: Input the CT images of walnut kernels of different grades into a deep residual network model. The deep residual network model performs feature recognition and grading on the walnut kernels and outputs a grading detection result. Train the deep residual network model by minimizing the difference between the grading detection result and the actual grade to obtain a trained walnut grading detection model;
[0009] Step 3: Use a CT imaging device to perform CT imaging on different walnuts with shells to obtain a number of CT images of walnuts with shells. After preprocessing the CT images of walnuts with shells, use them as test samples.
[0010] Step 4: Input the CT images of walnuts with shells into the walnut grading detection model. The walnut grading detection model identifies the surface image features of the CT images of the fruits to be detected and outputs the grading detection results.
[0011] Further, the deep residual network model is ResNet50.
[0012] Further, the preprocessing methods in Step 1 and Step 3 include the following steps:
[0013] Step 1.1: Perform binarization processing on the CT images.
[0014] Step 1.2: Segment the binarized image according to a preset threshold to distinguish the walnuts in the image from the background or other objects, so that each walnut kernel becomes an independent image unit.
[0015] After the present invention adopts the above technical solutions, compared with the prior art, it has the following advantages:
[0016] Through CT identification, the present invention can achieve non-destructive grading detection of walnuts, and judge and analyze the quality of fruits and vegetables through the feedback of relevant spectrograms and signals. This technology realizes the rapid and accurate grading of fruits and vegetables and the non-destructive rapid detection of nutritional and functional components without destroying the original state and chemical properties of the substances to be detected, improving efficiency and reducing costs. It is of great significance for the grading of fruit specifications and quality, realizing market value and the development of intelligent equipment, and reducing equipment costs.
[0017] The present invention will be described in detail below with reference to the accompanying drawings and embodiments. Description of the Drawings
[0018] Figure 1 It is a black-and-white processed image of walnuts obtained after post-processing of binarization;
[0019] Figure 2 It is the training accuracy curve and loss curve graph of walnuts of different grades;
[0020] Figure 3 It is the classification confusion matrix graph of walnuts of different grades;
[0021] Figure 4 It is the classification ROC curve graph of walnuts of different grades. Detailed Embodiments
[0022] The principles and features of the present invention will be described below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention and are not intended to limit the scope of the present invention.
[0023] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", "clockwise", "counterclockwise", etc. is based on the orientation or positional relationship shown in the accompanying drawings. It is 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 should not be construed as a limitation of the present invention.
[0024] 1 Materials and Methods
[0025] 1.1 Test Materials
[0026] Test materials: Xinjiang walnut variety 'Wen 185', Zhejiang-Xinjiang Fruit Industry Co., Ltd.
[0027] 1.2 Test Methods
[0028] 1.2.1 Treatment of Walnuts
[0029] (1) According to expert advice and visual inspection method, walnuts were divided into three grades: inferior, medium, and large.
[0030] (2) For appearance level control treatment, taking large fruits as the control group, and using inferior fruits, medium fruits, and large fruits as control treatments respectively.
[0031] (3) Walnuts of the three grades were numbered and fixed on cardboard respectively, and scanned and imaged using a CT device.
[0032] (4) Use a deep learning algorithm to build a model to identify and classify the images.
[0033] (5) Walnuts of the three grades were shelled respectively, and the numerical values of walnut kernels were measured using a color difference meter and recorded.
[0034] 1.2.2 Test Methods
[0035] Use a CT device to image. The device is the CT instrument in the school hospital; use a color difference meter to measure the walnut kernels. Basic principle of CT imaging: Use an X-ray beam to scan a certain thickness of the layer of the human body part to be examined. When the X-ray passes through different tissue structures of the human body, the degree of absorption is different. Therefore, the amount of X-ray reaching the screen or film is different. The X-ray passing through this layer is received by the detector, converted into visible light, then converted into an electrical signal by the photoelectric converter, and then converted into a digital signal by the analog / digital converter and input into the computer for processing to form a CT image.
[0036] 1.3 Data Processing Method and Algorithm Model
[0037] 1.3.1 Data Processing Method
[0038] (1) Use Microsoft Excel 2016 to process and analyze the data, and use DPS to conduct one-way ANOVA on the total color difference, peel brightness, etc. of different kernel-color walnuts; use Origin 2024 software to draw graphs to achieve data visualization.
[0039] (2) Use python for writing and design, use the ResNet50 method as the algorithm for walnut grade classification, and conduct walnut image processing and model training.
[0040] 1.3.2 ResNet50 Model
[0041] (1) The ResNet50 model is a deep residual model proposed by researchers at Microsoft Research in 2015, which is applied to multiple fields such as detection, segmentation, and recognition, and has the characteristics of being easy to optimize and having a small amount of computation.
[0042] (2) Experimental Data and Pretreatment
[0043] The image data of the present invention is sourced from imaging under a walnut CT device, and a total of 300 walnut images are collected. The original image data is in Dicom format. After reading the Dicom format data, it is converted into an 8-bit image and saved as a png format. The visualization results are as follows: By converting to an 8-bit image and saving as a png format, the walnut image data can be clearly viewed, and subsequent image processing and analysis work can be carried out.
[0044] First, binarize the dataset. This is a process of converting image data into only two colors, black and white, in order to more clearly highlight the key information in the image. By setting an appropriate threshold for segmentation, the walnuts in the image are distinguished from the background or other objects. In this way, one by one walnuts can be accurately cut out, making each walnut an independent image unit. As Figure 1 shown, after this series of processes, the shape and contour of the walnuts are accurately extracted, providing convenience for subsequent classification.
[0045] After processing, data of three classes are obtained, which are divided into a training set and a validation set according to a ratio of 8:2. Among them, the training set contains 336 images and the validation set contains 84 images for classification training.
[0046] 2 Results and Analysis
[0047] 2.1 Conduct Quality Analysis Directly According to the Appearance Color of Walnut Kernels
[0048] The experimental samples selected were 'Wen 185' walnuts from Xinjiang. The shells were broken by hand to obtain the kernels. 300 walnut kernel samples were selected, including two integrity levels of 1 / 4 kernels and 1 / 2 kernels, and three color levels of mildewed black, amber, and light yellow. Examples of different appearance levels of the walnut kernel samples are shown as Figure 2 shown, and the appearance level of the samples is shown in Table 1. Before using the vision inspection machine to grade the walnut kernels, most of them were classified by visual inspection, and the walnut kernels were graded according to the intuitive visual effect. Amber and light yellow are the ideal colors of walnut kernels, which not only give consumers an intuitive visual selection, but also have good taste and high nutritional value. However, during the growth process of some walnuts, due to non-standard cultivation, the walnuts show browning phenomenon, which to a certain extent affects the color of the walnut kernels, and even affects the taste and nutritional value.
[0049] Table 1 Appearance analysis of walnut kernels at different grades
[0050]
[0051] 2.2 Classification training results and index analysis of walnuts at different grades
[0052] Precision curves are often used to evaluate the predictability of a model. By plotting the precision curves at different thresholds, the prediction effects of the model under different conditions can be visually observed, so as to find the optimal prediction threshold. According to Figure 2 the left precision curve, according to the training results, it can be seen that the deviation between the test data result curve and the threshold model curve is relatively large. Due to the small amount of data, the training trend is oscillating upward. As the number of training times increases, the precision becomes higher and finally reaches the Top1 index of 100%.
[0053] Loss curves mainly show the progress of the training process and how the gap between the model prediction results and the actual results changes. By observing the loss curves, the improvement situation during the model training process can be visually seen. According to Figure 2 the right loss curve, for the loss curve during the training process, during the training process, the trends of the actual results and the model prediction results are the same. Due to the small amount of data, the training trend is oscillating downward. The reasons for the oscillation and increase of the loss function are overfitting and underfitting of the model. Ideally, the loss function gradually decreases as the number of training times increases and finally tends to a relatively small stable value.
[0054] 2.3 Results and analysis of the confusion matrix diagram for classifying walnuts at different grades
[0055] The confusion matrix is usually used as an evaluation metric for deep learning classification models. It can show the number of observed values that the model misclassifies and correctly classifies, thereby evaluating the performance of the model. The dark diagonal in the figure shows the number of correct identifications, and the light diagonal shows the number of incorrect identifications. According to Figure 3 it can be seen that there are a total of 84 walnuts predicted. Among them, 30 poor-quality walnuts have predictions that match the model classification, 29 medium-quality walnuts, 25 large-quality walnuts, and there are no misclassified walnuts.
[0056] 2.4 Results and Analysis of the ROC Curve for the Classification of Walnuts of Different Grades
[0057] The Receiver Operating Characteristic (ROC) curve and the Area Under the ROC Curve (AUC) can be used to predict the accuracy of the model. On the ROC curve, the point closest to the upper left corner of the coordinate graph is the critical value with relatively high sensitivity and specificity. The larger the area enclosed by the curve and the coordinate axes, the better the classification effect of the model. The ROC curve graph and AUC for the classification of walnuts of different grades are as Figure 4 shown. In the analysis of the ROC curve, walnuts of the three grades all achieved an AUC value of 100% at different thresholds, indicating that the above walnut classification model belongs to an excellent model.
[0058] 3 Discussion
[0059] In the present invention, the imaging images of walnuts under a CT device are classified and recognized through a deep learning algorithm, and a fitting model is constructed. Through the model, the whole walnuts can be graded intuitively, which solves the problems of laborious time-consuming and uncertainty in manual grading, and at the same time provides a strong guarantee for the processing of the walnut nut industry.
[0060] Since its invention in the 1970s, CT has become an important tool in medical imaging. With the development and progress of society, CT technology has developed vigorously in other fields like bamboo shoots after a spring rain, such as non-destructive testing of wood, fruits, and food. In the present invention, the walnuts are scanned and imaged by a CT device, and the pictures are recognized and classified through an algorithm model to achieve the quality grading of whole walnuts. Shanbin Dan and Xiao He also used CT technology to detect the density value and moisture content value of logs, and the density and moisture content of logs regardless of tree age, heartwood or sapwood can be detected by CT, avoiding the disadvantage of conventional detection that requires damaging the wood, which has guiding significance for saving and rationally using wood. Xingyi Huang and Qinglei Zhang collected walnut images through soft X-ray imaging technology for processing and analysis to judge the internal quality of walnuts and achieve comprehensive non-destructive testing of walnut quality.
[0061] According to research on walnut processing factories, the current walnut quality grading is divided into three steps: ① Fruit farmers conduct a rough grading and send the superior fruits to the factory for further grading to obtain inferior fruits, superior fruits, special-grade fruits, etc. ② The factory pours the walnuts into a shelling machine to break them, obtaining walnut shells and walnut kernels, and conducts a preliminary manual selection. ③ The walnut shells and walnut kernels after preliminary selection enter a machine vision separation device to separate the shells and kernels, and then manual workers select the defective products to obtain high-quality walnut kernels, which are then packed and packaged. The innovation of this invention lies in that, without breaking the walnuts, the integrity and color of the kernels inside the walnuts can be obtained through machine model scanning to complete the grading of the walnuts. The advantages are saving time and manpower and improving work efficiency.
[0062] 4 Conclusion
[0063] This invention constructs a model through the ResNet50 algorithm to identify and classify images, as Figure 3 and Figure 4 shown. A confusion matrix graph is introduced to evaluate the model. From the results, it is obtained that 84 walnuts are classified without misclassification; through the analysis of the area under the ROC curve, the three grades of walnuts all achieved an AUC value of 100% at different thresholds, indicating that the walnut classification model belongs to an excellent model.
[0064] The above is an example of the best implementation mode of this invention, and the parts not described in detail are all common knowledge of those of ordinary skill in the art. The protection scope of this invention shall be subject to the content of the claims, and any equivalent transformation based on the technical inspiration of this invention is also within the protection scope of this invention.
Claims
1. A non-destructive walnut grading detection method based on ray technology, characterized in that Including the following steps: Step 1: Use a CT imaging device to perform CT imaging on walnuts with shells of different sizes to obtain a number of walnut CT images. After preprocessing the CT images, use them as training samples. Then, crack the walnuts and perform manual grading, and label the actual grades corresponding to the training samples; Step 2: Input the CT images of walnut kernels of different grades into a deep residual network model. The deep residual network model performs feature recognition and grading on the walnut kernels and outputs a grading detection result. Train the deep residual network model by minimizing the difference between the grading detection result and the actual grade to obtain a trained walnut grading detection model; Step 3: Use a CT imaging device to perform CT imaging on different walnuts with shells to obtain a number of CT images of walnuts with shells. After preprocessing the CT images of walnuts with shells, use them as test samples; Step 4: Input the CT images of walnuts with shells into the walnut grading detection model. The walnut grading detection model recognizes the surface image features of the CT images of the fruits to be detected and outputs a grading detection result.
2. The non-destructive walnut grading detection method based on ray technology according to claim 1, wherein The deep residual network model is ResNet50.
3. The non-destructive walnut grading detection method based on ray technology according to claim 1, wherein, The preprocessing methods in Step 1 and Step 3 include the following steps: Step 1.1: Perform binary processing on the CT images; Step 1.2: Segment the binary image according to a preset threshold to distinguish the walnuts in the image from the background or other objects, so that each walnut kernel becomes an independent image unit.
Citation Information
Cited By
X-ray-based nutlet damage assessment method and device under walnut shell breaking
CN120953202A