Watermelon fruit internal quality prediction method, system, equipment and medium
Through image processing and machine learning technology, the surface texture characteristics of watermelon fruits are extracted and the internal quality prediction model is constructed, which solves the rapid and non-destructive problems of internal quality detection of watermelon fruits in the existing technology, and achieves efficient quality prediction and management.
Patent Information
- Application Number
- CN202410804608.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-11-12
AI Technical Summary
The prior art is difficult to achieve rapid and non-destructive detection of the internal quality of watermelon fruits, especially in large-scale production. Acoustic technology and near-infrared spectroscopy technology have limitations, and external phenotypes are difficult to accurately analyze to reflect internal quality.
Image processing technology is used to extract the surface texture characteristics of watermelon fruits, and a prediction model is constructed in combination with machine learning algorithms. By taking surface images of different growth periods, gap, contrast, average RGB value and texture proportion characteristics are extracted, and quality measurement data is used for training. Establish an internal quality prediction model.
It achieves accurate and reliable prediction of the internal quality of watermelon fruits, assists growers in fine management and fruit grading processing, enhances market competitiveness, and provides scientific quality control tools for agriculture.
Smart Images

Figure CN118941496A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of fruit quality prediction, and in particular to a method, system, equipment and medium for predicting the internal quality of a watermelon fruit. Background Art
[0002] As a fruit, watermelon plays an important role in global agriculture. Its rich water content, nutritional value and moderate sweetness make it an ideal fruit pursued by consumers. For market sales, the internal quality of the fruit determines the sales price. Accurate prediction of fruit quality traits helps growers to manage finely, give priority to cultivating high-quality fruits, and improve market competitiveness through grading. At present, the quality inspection of watermelon fruit often uses destructive testing equipment such as texture analyzers and saccharimeter. The test accuracy is high, but the operation process is relatively cumbersome. In addition, this method is often accompanied by destructive testing of the fruit, which will directly affect the integrity and market value of the product.
[0003] In recent years, the continuous innovation and application of non-destructive testing technology has provided a more feasible option for internal quality assessment. Acoustic technology and near-infrared spectroscopy technology have been studied and applied on watermelon fruits, but they are limited to laboratory research and still have some limitations in actual production. Watermelons are relatively large in size and unevenly distributed in structure. When using sound detection, the microphone distance and tapping angle will directly affect the test results; when using near-infrared spectroscopy detection, the cost of spectral equipment is relatively high and the light source is not easy to penetrate the melon skin to reflect the internal quality. Large-scale testing in production faces challenges, and existing technologies are difficult to achieve rapid testing of large quantities of watermelons.
[0004] In addition, since there is a close relationship between the external phenotype and internal quality of the fruit, the phenotypes and characteristics of the external surface shape, color, texture, etc. are a reflection of the growth and development of the fruit, and are also a comprehensive reflection of multiple factors such as environmental conditions, climate, and soil nutrients. Therefore, external characteristics are often directly related to the physiological processes inside the fruit, including the accumulation of nutrients, changes in sugar content, etc. The maturity and sugar content of the fruit, as the determining factors of internal quality, are often initially reflected in the changes in external phenotypic traits.
[0005] However, the texture of the external fruit of watermelon is generally difficult to accurately analyze and can only rely on sensory evaluation, which makes it difficult to express its distribution differences. With the continuous advancement of computer vision and machine learning technology, there are possible methods for quantitative analysis of fruit texture. The gap algorithm can describe the distribution of gaps around the target in the image. By combining image processing technology, the texture of the outer surface of watermelon can be accurately quantified. The introduction of machine learning algorithms can further improve the ability to analyze the relationship between watermelon texture and quality. By training the model, machine learning can learn the association between different texture features and internal quality from a large amount of image data. It provides new possibilities for non-destructive and efficient prediction of watermelon quality. Summary of the invention
[0006] In view of the deficiencies in the prior art, the purpose of the present invention is to provide a method, system, device and medium for predicting the internal quality of watermelon fruit. By using image processing technology to perform fine analysis and quantification of the texture of the watermelon fruit, combined with a machine learning algorithm to explore the potential correlation between texture features and internal quality indicators, an accurate and reliable prediction model is established to achieve the prediction of the internal quality of watermelon.
[0007] To achieve the above object, the technical solution adopted by the present invention is as follows:
[0008] A method for predicting the internal quality of watermelon fruit comprises the following steps:
[0009] Step 1, obtaining surface images of watermelon fruits at different growth stages taken under a standard light environment;
[0010] Step 2, using image processing algorithms to extract the region of interest in the watermelon fruit surface image;
[0011] Step 3, extracting the texture distribution features of the watermelon fruit in the region of interest image, wherein the texture distribution features include a gap feature, a contrast feature, an average RGB value, and a texture proportion feature;
[0012] Step 4, obtaining the quality measurement data of the watermelon fruit described in step 1;
[0013] Step 5, using ordinary least squares method, support vector machine and decision tree algorithm to build a watermelon fruit internal quality prediction model, and using the extracted watermelon fruit texture distribution characteristics as independent variables and the quality measurement data as dependent variables to prepare a training data set to train the watermelon fruit internal quality prediction model;
[0014] Step 6: Input the surface image of the watermelon fruit to be predicted into the trained watermelon fruit internal quality prediction model to obtain the watermelon fruit internal quality prediction result.
[0015] Furthermore, the surface images described in step 1 are obtained from watermelon fruits on the 14th, 21st, 28th, 35th and 42nd day after pollination, and each surface image includes a stem position image, a navel position image and surface images of both sides.
[0016] Further, the steps of extracting the region of interest in step 2 are as follows:
[0017] Step 2.1, converting the surface image into a grayscale image;
[0018] Step 2.2, using histogram equalization technology to perform feature enhancement processing on the grayscale image;
[0019] Step 2.3, converting the image processed by feature enhancement from RGB color space to HSV color space;
[0020] Step 2.4, set the HSV color threshold, locate the watermelon fruit area, and generate a binary mask image;
[0021] Step 2.5, separating the foreground and background parts of the binary mask image to achieve contour detection of the target area;
[0022] Step 2.6, calculate and obtain the minimum bounding rectangle that completely includes the target area;
[0023] Step 2.7: Calculate the maximum inscribed rectangle in the target area based on the center point, size and angle information of the minimum circumscribed rectangle to obtain the region of interest.
[0024] Furthermore, in step 3, the gap feature is calculated using a gap algorithm; the contrast feature is calculated using a gray level co-occurrence matrix algorithm; the average RGB value is obtained by calculating the RGB value of each pixel in the image of the region of interest and then averaging them; the texture proportion feature is obtained by calculating the proportion of black pixels in the image of the region of interest.
[0025] Furthermore, the specific steps of calculating the gap feature by the gap algorithm are as follows:
[0026] Set multiple sliding boxes of different sizes to slide on the image of the region of interest and traverse each pixel;
[0027] The position covered by each sliding box on the image of the region of interest is an analysis point, and the sum of the number of pixels in the sliding box and the sum of the squares at all analysis points are statistically calculated;
[0028] Based on the size of each sliding box, the gap characteristic is calculated using the following formula:
[0029]
[0030] Where L(ε) is the gap characteristic, ε is the size of the sliding box, Q1=∑ i p(i, ε) is the sum of the number of pixels in the sliding box at the i-th analysis point, Q2 = ∑ i p(i, ε) 2 is the sum of the squares of the number of pixels in the sliding window at the i-th analysis point, and p(i, ε) is the number of pixels in the sliding box at the i-th analysis point.
[0031] Furthermore, the quality measurement data in step 4 include central sugar content, edge sugar content, hardness, adhesiveness, elasticity, viscosity, cohesion, chewiness, and resilience.
[0032] Furthermore, the quality measurement data in step 4 is obtained by measuring the quality of watermelon fruit using a texture analyzer, a colorimeter, and a saccharimeter.
[0033] In a second aspect, the present invention provides a watermelon fruit internal quality prediction system, comprising:
[0034] A surface image acquisition module, used to acquire surface images of watermelon fruits at different growth stages under a standard light environment;
[0035] An image processing module, used for extracting a region of interest in a surface image using an image processing algorithm;
[0036] A feature extraction module is used to extract the texture distribution features of the watermelon fruit in the region of interest image; wherein the texture distribution features include gap features, contrast features, average RGB value and texture proportion features;
[0037] A data acquisition module is used to obtain quality measurement data of watermelon fruits;
[0038] The model building and training module is used to construct a watermelon fruit internal quality prediction model using ordinary least squares method, support vector machine and decision tree algorithm, and to train using a training data set made with the extracted watermelon fruit texture distribution characteristics as independent variables and quality measurement data as dependent variables;
[0039] The result output module is used to use the trained watermelon fruit internal quality prediction model to predict the surface image of the watermelon fruit to obtain the watermelon fruit internal quality prediction result.
[0040] In a third aspect, the present invention proposes a computer device for predicting the internal quality of watermelon fruit, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the method described in the first aspect when executing the computer program.
[0041] In a fourth aspect, the present invention proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and is characterized in that when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0042] The remarkable effects of the present invention are:
[0043] The present invention takes a large number of images and extracts the ROI area through an image processing algorithm, and extracts the gap information using a gap algorithm, thereby combining the gap feature and the contrast feature extracted by the gray level co-occurrence matrix algorithm, as well as the average RGB value and the texture proportion feature to form the texture distribution feature of the watermelon fruit skin. Then, the texture distribution feature of the watermelon fruit skin is used as an independent variable, and the quality measurement data obtained by 9 quality measurements are used as a dependent variable for modeling and training, thereby obtaining a quality prediction model that can be used to accurately predict the internal quality of the watermelon fruit to be predicted, and achieving the purpose of predicting quality traits such as hardness and adhesion through image data. The method can assist growers in fine management, improve the level of watermelon fruit quality management, help to give priority to the cultivation of high-quality fruits, and can also help watermelon fruit grading and processing to improve market competitiveness, and provide agricultural producers with a scientific and operational tool that can help them more effectively perform quality control and decision-making management. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is a flow chart of the method of the present invention;
[0045] Figure 2 is a schematic diagram of the obtained surface image of a watermelon fruit;
[0046] Figure 3 It is a schematic diagram of extracting the region of interest from the surface image of a watermelon fruit;
[0047] Figure 4 It is a schematic diagram of the gap characteristics of the extracted region of interest;
[0048] Figure 5 This is a schematic diagram of the principle of texture ratio calculation and gap degree algorithm;
[0049] Figure 6 This is a comparison of two watermelon fruits with different textures;
[0050] Figure 7 This is a comparison of two watermelon fruit surface images with different textures;
[0051] Figure 8 It is a principle block diagram of the system of the present invention. DETAILED DESCRIPTION
[0052] The specific implementation manner and working principle of the present invention are further described in detail below with reference to the accompanying drawings.
[0053] Embodiment 1:
[0054] like Figure 1 As shown, this embodiment proposes a method for predicting the internal quality of watermelon fruit, and the specific steps are as follows:
[0055] Step 1, obtaining surface images of watermelon fruits at different growth stages taken under a standard light environment with a color temperature of 6000K;
[0056] The surface images are obtained from watermelon fruits on the 14th, 21st, 28th, 35th and 42nd days after pollination. Figure 2 As shown, each surface image includes Figure 2 The image of the melon stem position shown in a, Figure 2 The image of the melon navel shown in b, Figure 2 c and Figure 2 d shows the surface images of both sides, a total of 240 images were collected.
[0057] Step 2: Use image processing algorithm to extract the region of interest in the watermelon fruit surface image. The schematic diagram of extracting the region of interest in the watermelon fruit surface image is as follows: Figure 3 As shown, the specific extraction steps are as follows:
[0058] Step 2.1, use cv2.cvtColor function to convert the surface image into a grayscale image;
[0059] Step 2.2, based on the histogram equalization technology, use the cv2.equalizeHist function to perform feature enhancement processing on the grayscale image to enhance the image contrast and make the target more prominent in the image;
[0060] The principle of histogram equalization technology is: histogram equalization stretches the distribution of image pixel values to enhance the contrast and make it easier to distinguish the target area.
[0061] Step 2.3, use the cv2.cvtColor function to convert the contrast-enhanced image from RGB color space to HSV color space, which is conducive to color segmentation and analysis;
[0062] Step 2.4, set the HSV color threshold, accurately locate the watermelon fruit area, make the specific color of the target stand out, and generate a binary mask image;
[0063] Step 2.5, separating the foreground and background parts of the binary mask image to achieve contour detection of the target area;
[0064] In this example, during the target location phase, the contour detection and screening method was used. By finding the contours in the image and screening them according to the preset conditions, the contour representing the watermelon was successfully selected. Specifically:
[0065] The contour detection function cv2.findContours is used to find the contour of the target area. The part of interest (foreground) and the part of no interest (background) in the image are separated by binarization, and the boundary between the foreground and background areas is found. The contour of the target object (watermelon) is the largest in the image, and the preset condition is that the contour of the target object in the input image is the largest. Make sure that the largest contour is selected to accurately represent the target object.
[0066] Step 2.6, use the cv2.convexHull function to calculate the maximum convex hull of the target area. The convex hull is the smallest convex polygon that can completely surround the target contour; use the cv2.minAreaRect function to calculate the minimum circumscribed rectangle of the convex hull, which is the smallest rotated rectangle that can completely surround the convex hull, with center point, size (width and height) and angle information;
[0067] Step 2.7: Calculate the vertex coordinates of the maximum inscribed rectangle of the required size based on the center point, size and angle information of the minimum circumscribed rectangle. Utilize the characteristics of the convex hull and the minimum circumscribed rectangle to accurately extract the maximum inscribed rectangle in the target area by mathematical calculation to obtain the region of interest.
[0068] Step 3, extracting the texture distribution characteristics of the watermelon fruit in the image of the region of interest, the texture distribution characteristics including gap characteristics, contrast characteristics, average RGB value and texture proportion characteristics; wherein the gap characteristics are calculated using a gap algorithm; the contrast characteristics are calculated using a gray level co-occurrence matrix algorithm; the average RGB value is obtained by calculating the RGB value of each pixel in the image of the region of interest and then averaging them; the texture proportion feature is obtained by calculating the proportion of black pixels in the image of the region of interest.
[0069] For the gap algorithm:
[0070] The gap algorithm is a statistic used to describe the distribution of holes or gaps in an image or structure. It is usually used to analyze the spatial structure and fractal characteristics of the texture of an image, such as Figure 4 and Figure 5As shown. It is a method to quantify spatial heterogeneity and uneven distribution. The algorithm is based on the sliding window principle and adopts a variance calculation method. By accurately calculating the variance of the pixel values in each window, it reveals the texture changes and gap distribution between rectangular boxes in the image. It slides on the image using a series of boxes of different sizes. The position covered by each box on the image is called an analysis point. At each analysis point, the distribution of gaps inside the box is counted. These gaps are blank areas, holes, or missing areas in the image. For each box size, the distribution characteristics of the gaps are calculated, and two indicators can be measured: the sum of the number of pixels in each box Q1 and the sum of squares Q2. These two indicators can measure the gap distribution of the image under a specific size box. The specific steps are:
[0071] Set multiple sliding boxes of different sizes to slide on the image of the region of interest and traverse each pixel;
[0072] The position covered by each sliding box on the image of the region of interest is an analysis point, and the sum of the number of pixels in the sliding box and the sum of the squares at all analysis points are statistically calculated;
[0073] Based on the size of each sliding box, the gap characteristic is calculated using the following formula:
[0074]
[0075] Where L(ε) is the gap characteristic, ε is the size of the sliding box, q1=∑ i p(i, ε) is the sum of the number of pixels in the sliding box at the i-th analysis point, Q2 = ∑ i p(i, ε) 2 is the sum of the squares of the number of pixels in the sliding window at the i-th analysis point, and p(i, ε) is the number of pixels in the sliding box at the i-th analysis point.
[0076] For example, if the box size is 4×4, then there will be many 4×4 boxes when traversing the image, and p is the value of the number of pixels in one of the boxes. N refers to the number of boxes. If 1 is the size of the image, then the number of boxes with a width of ε is N(ε) = (1-ε+1), and the width of the box ε makes its value equivalent to 2, 4, 8, ... 256. At this point, two indicators can be measured: the sum of the number of pixels in each box Q1 and the sum of the squares Q2. Improving these two indicators can measure the gap distribution of the image under a specific size box.
[0077] For the gray-level co-occurrence matrix algorithm:
[0078] Gray-Level Co-occurrence Matrix (GLCM) is a statistical method used to describe image texture. GLCM reflects the texture characteristics of an image by calculating the spatial relationship between the gray values of pixels in an image. Specifically, GLCM counts the number of co-occurrences of each gray level in an image at a certain spatial distance and direction. The dissimilarity parameter measures the degree of difference between the gray levels of adjacent pixels in an image. Its calculation formula is:
[0079] Dissimilarity=∑ i,j |ij|*p(i, ε) (2)
[0080] Where P(i,j) is the (i,j)th element in the normalized GLCM.
[0081] The contrast parameter is used to reflect the intensity of grayscale changes and local contrast in the image, and its calculation formula is:
[0082] Dissimilarity=∑ i,j (ij) 2 *p(i, ε) (3)
[0083] The larger the contrast value, the more dramatic the grayscale changes in the image and the more obvious the texture.
[0084] For average RGB value:
[0085] Get the RGB values of all pixels in the selected area. The color of each pixel is composed of three components: red (R), green (G), and blue (B). Average the RGB values of all pixels in the selected area and calculate the average red value, average green value, and average blue value of the area. Use the weighted method to convert the RGB image to a grayscale image. Conversion formula:
[0086] Gray=0.299×R+0.587×G+0.114×B (4)
[0087] For texture ratio features:
[0088] The purpose of binarization is to convert the grayscale image into an image with only black and white colors. A threshold T is set by the Otsu method, and pixels with grayscale values greater than T are set to white (255), and pixels less than or equal to T are set to black (0). The binarized image is traversed, and the number of pixels with black (0) values is counted. The number of black pixels represents the texture ratio of the area in the image.
[0089] In this example, in order to prove the effectiveness of the extracted gap feature, contrast feature, average RGB value and texture ratio feature, that is, they can be used for watermelon internal quality prediction, this example uses SVM, GBDT, and XGBoost as classification tools to classify the watermelon internal quality. Figure 6 Different types of fruit textures such as dark green toothed texture and walnut skin texture are classified. By extracting the features output by the algorithm, a classification data set is established, and these features are trained and classified using three classification algorithms. To evaluate the performance of the classification model, the accuracy P, recall R and F1 value indicators are used as evaluation criteria, and the formula is as follows:
[0090]
[0091] Among them, TP, FP and FN represent the correctly identified target, the wrongly identified target and the unrecognized target, respectively.
[0092] right Figure 7 The two different types of fruit textures, dark green serrated texture and walnut skin texture, are used as the data basis to establish a data set for classification and verify the effectiveness of the algorithm. Among the three different algorithms, SVM, GBDT, and XGBoost, the verification algorithm SVM algorithm TP=21, FN=0, FP=1, TN=9; GBDT algorithm TP=20, FN=1, FP=0, TN=10; XGBoost algorithm TP=9, FN=1, FP=1, TN=20. The evaluation indicators obtained by the three algorithms are P=0.95, R=1.00, F1=0.98; P=1.00, R=0.95, F1=0.98; P=0.90, R=0.90, F1=0.90. It can be found that P, R, and F1 are all greater than 0.9 in the classification effects of the three classification algorithms. The texture distribution features extracted by the method described in this embodiment can successfully replace the texture distribution of watermelon fruit. Moreover, in the quality prediction model constructed based on these characteristics, the texture characteristic indicators show a significant correlation with hardness, stickiness, and chewiness.
[0093] like Figure 4 As shown in Figure 1, based on the captured ROI, the above model is applied to extract the texture information in the image, and the black area of the image is binarized, that is, the watermelon texture ratio, as shown in Figure 1. Figure 5 -a. The core principle of calculating the gap information is as follows Figure 5 -b, as shown in 5-c, different sliding windows have different gap sizes.
[0094] Step 4, obtaining quality measurement data obtained after comprehensive quality measurement of the watermelon fruit in step 1 using a texture analyzer, a colorimeter, a saccharimeter, etc.;
[0095] When measuring quality, a cylindrical probe with a specific diameter is used to test under the set trigger force, detection speed and puncture distance. In addition, the pulp at the center and edge is tested for sugar content using a handheld sugar meter. A total of 9 quality indicators, including center sugar content, edge sugar content, hardness, adhesiveness, elasticity, viscosity, cohesion, chewiness and resilience, are measured to form quality measurement data;
[0096] Step 5, using ordinary least squares method, support vector machine and decision tree algorithm to build a watermelon fruit internal quality prediction model, and extracting texture distribution information from the fruit images of the five growth stages and correlating it with the internal quality of the watermelon fruit, that is, taking the extracted watermelon fruit texture distribution characteristics as independent variables, taking the quality measurement data consisting of 9 quality indicators of center sugar content, edge sugar content, hardness, adhesiveness, elasticity, viscosity, cohesion, chewiness and resilience as dependent variables, making a training data set to train the watermelon fruit internal quality prediction model, specifically:
[0097] About the least squares regression model:
[0098] Ordinary least squares (OLS) is a commonly used parameter estimation method. Its basic idea is to find the optimal model parameter estimation by minimizing the residual sum of squares between the actual observation value and the model prediction value. Here, the output parameters of the image processing algorithm are used as independent variables and the fruit quality data are used as dependent variables to enter the model for modeling. The specific formula of the regression model is as follows:
[0099] y=xβ+∈ (8)
[0100] Where y is the dependent variable vector, x is the independent variable matrix, and β is the regression coefficient vector. ∈ is the error term. The goal of OLS is to minimize the residual sum of squares (RSS):
[0101]
[0102] By solving the normal equation to minimize RSS, we can get the estimated values of the regression coefficients:
[0103] β=(x T x) -1 ·x T y (10)
[0104] Where T represents the transpose of the matrix.
[0105] About Support Vector Regression:
[0106] Support Vector Regression (SVR) is specifically used to solve regression problems. Its core idea is to construct an optimal hyperplane so that the interval between all data points and this hyperplane is as large as possible, and fit as many data points as possible within this interval.
[0107] About the decision tree algorithm:
[0108] A decision tree is a supervised learning algorithm based on a tree structure, used for regression and classification tasks. It constructs a tree structure by recursively splitting the data, where each node represents a feature and each leaf node (final node) represents an output value. In regression problems, the prediction process of a decision tree is relatively simple and intuitive. It starts from the root node and traverses the tree step by step according to the value of the feature until it reaches a leaf node. The predicted value of a leaf node is the average of all training samples in that leaf node. The decision tree regressor uses the CART (Classification and Regression Trees) algorithm, which selects features and thresholds that minimize the mean square error during the splitting process of each node.
[0109] Based on the above three algorithms, the steps for establishing the watermelon fruit internal quality prediction model described in this example are as follows:
[0110] Step 4-1. Data preparation phase:
[0111] Data were read from the Excel file, the texture distribution characteristics extracted by the image processing algorithm were specified as the modeling dependent variable, and the quality measurement data of watermelon fruit measured by instruments such as a texture analyzer were specified as the independent variable.
[0112] Step 4-2. Model selection:
[0113] For each dependent variable, multiple linear regression model (OLS), decision tree model and support vector regression model (SVR) were selected for comparison. Each model has different advantages and disadvantages and is suitable for different data types and model assumptions.
[0114] Step 4-3. Cross-validation settings:
[0115] K-fold cross validation was used and the data was divided into 10 folds.
[0116] Each fold is divided into a training set and a validation set to ensure the independence and fairness of training and evaluation.
[0117] Step 4-4. Model training and validation:
[0118] Multiple Linear Regression Model (OLS),In each fold, fit a multiple linear regression model and calculate the predicted values on the training set and the validation set.
[0119] Decision tree model,In each fold, a decision tree model with a depth of 5 is trained using the training set and then predicted on the validation set.
[0120] Support Vector Machine Model (SVM), in each fold, the hyperparameters (C, kernel function, gamma, etc.) were adjusted using grid search. The SVM model was trained based on the best hyperparameters, fitted after data standardization on the training set, and predicted on the validation set.
[0121] Step 4-5. Model evaluation:
[0122] Calculate the performance indicators of each model on the validation set, such as root mean square error (RMSE), mean absolute percentage error (MAPE), and coefficient of determination (R-squared). Obtain the R of each dependent variable 2 The values were 0.88, 0.88, and 0.84, respectively. The validation set was validated by cross-validation, and the R 2 The values are 0.78, 0.82, and 0.77 respectively. In addition, the RRMSE are 0.23, 0.29, and 0.34 respectively, and the MAPE are 0.22, 0.34, and 0.38 respectively. It can be seen that the watermelon fruit internal quality prediction method based on the rind texture gap algorithm can achieve the effect of predicting the internal quality of watermelon fruit.
[0123] Finally, a summary of the cross-validation results is output, including performance metrics for each model.
[0124] In this example, the training process of the watermelon fruit internal quality prediction model covers three different machine learning models, and cross-validation is used to ensure the generalization ability and robustness of the model. Each model is predicted on the validation set, and multiple evaluation metrics are calculated to compare performance.
[0125] Step 6: Input the surface image of the watermelon fruit to be predicted into the trained watermelon fruit internal quality prediction model to obtain the watermelon fruit internal quality prediction result.
[0126] Embodiment 2:
[0127] like Figure 8 As shown, this embodiment proposes a watermelon fruit internal quality prediction system based on the watermelon fruit internal quality prediction method described in Example 1, comprising:
[0128] A surface image acquisition module, used to acquire surface images of watermelon fruits at different growth stages under a standard light environment;
[0129] An image processing module, used for extracting a region of interest in a surface image using an image processing algorithm;
[0130] A feature extraction module is used to extract the texture distribution features of the watermelon fruit in the region of interest image; wherein the texture distribution features include gap features, contrast features, average RGB value and texture proportion features;
[0131] A data acquisition module is used to obtain quality measurement data of watermelon fruits;
[0132] The model building and training module is used to construct a watermelon fruit internal quality prediction model using ordinary least squares method, support vector machine and decision tree algorithm, and to train using a training data set made with the extracted watermelon fruit texture distribution characteristics as independent variables and quality measurement data as dependent variables;
[0133] The result output module is used to use the trained watermelon fruit internal quality prediction model to predict the surface image of the watermelon fruit to obtain the watermelon fruit internal quality prediction result.
[0134] Embodiment 3:
[0135] This embodiment proposes a computer device for predicting the internal quality of watermelon fruit, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the method described in Example 1 is implemented.
[0136] It should be understood that in the embodiments of the present invention, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The memory may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the type of device.
[0137] Embodiment 4:
[0138] This embodiment provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the method described in Embodiment 1 is implemented.
[0139] The computer-readable storage medium may be an internal storage unit of the controller, such as a hard disk or memory of the controller. The computer-readable storage medium may also be an external storage device of the controller, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the controller. The computer-readable storage medium may also include both the internal storage unit of the controller and the external storage device.
[0140] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referenced to each other.
[0141] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0142] The present invention is described with reference to the flowcharts and / or block diagrams of the method, terminal device (system), and computer program product according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0143] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0144] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0145] In summary, the present invention takes a large number of images and extracts the ROI area through an image processing algorithm, and uses a gap algorithm to extract gap information, thereby combining the gap feature and the contrast feature extracted by the gray level co-occurrence matrix algorithm, as well as the average RGB value and the texture proportion feature to form the texture distribution feature of the watermelon fruit skin, and then uses the texture distribution feature of the watermelon fruit skin as an independent variable and the quality measurement data obtained by 9 quality measurements as a dependent variable for modeling and training, and obtains a quality prediction model that can be used to accurately predict the internal quality of the watermelon fruit to be predicted, and achieves the purpose of predicting quality traits such as hardness and adhesion through image data. This method can assist growers in fine management, improve the level of watermelon fruit quality management, help to give priority to the cultivation of high-quality fruits, and can also help watermelon fruit grading to improve market competitiveness, and provide agricultural producers with a scientific and operational tool that can help them more effectively perform quality control and decision-making management.
[0146] The technical solution provided by the present invention is described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A method for predicting the internal quality of watermelon fruit, It is characterized in that The following steps are involved: Step 1, obtaining surface images of watermelon fruits at different growth stages taken under a standard light environment; Step 2, using image processing algorithms to extract the region of interest in the watermelon fruit surface image; Step 3, extracting the texture distribution features of the watermelon fruit in the region of interest image, wherein the texture distribution features include a gap feature, a contrast feature, an average RGB value, and a texture proportion feature; Step 4, obtaining the quality measurement data of the watermelon fruit described in step 1; Step 5, using ordinary least squares method, support vector machine and decision tree algorithm to build a watermelon fruit internal quality prediction model, and using the extracted watermelon fruit texture distribution characteristics as independent variables and the quality measurement data as dependent variables to prepare a training data set to train the watermelon fruit internal quality prediction model; Step 6: Input the surface image of the watermelon fruit to be predicted into the trained watermelon fruit internal quality prediction model to obtain the watermelon fruit internal quality prediction result.
2. The method for predicting the internal quality of watermelon fruit according to claim 1, It is characterized in that The surface images described in step 1 are obtained from watermelon fruits on the 14th, 21st, 28th, 35th and 42nd day after pollination, and each surface image includes a stem position image, a navel position image and surface images on both sides.
3. The method for predicting the internal quality of watermelon fruit according to claim 1, It is characterized in that The steps to extract the region of interest in step 2 are as follows: Step 2.1, converting the surface image into a grayscale image; Step 2.2, using histogram equalization technology to perform feature enhancement processing on the grayscale image; Step 2.3, converting the image processed by feature enhancement from RGB color space to HSV color space; Step 2.4, set the HSV color threshold, locate the watermelon fruit area, and generate a binary mask image; Step 2.5, separating the foreground and background parts of the binary mask image to achieve contour detection of the target area; Step 2.6, calculate and obtain the minimum bounding rectangle that completely includes the target area; Step 2.7: Calculate the maximum inscribed rectangle in the target area based on the center point, size and angle information of the minimum circumscribed rectangle to obtain the region of interest.
4. The method for predicting the internal quality of watermelon fruit according to claim 1, It is characterized in that In step 3, the gap feature is calculated using a gap algorithm; the contrast feature is calculated using a gray level co-occurrence matrix algorithm; the average RGB value is obtained by calculating the RGB value of each pixel in the image of the region of interest and then averaging them; the texture ratio feature is obtained by calculating the ratio of black pixels in the image of the region of interest.
5. The method for predicting the internal quality of watermelon fruit according to claim 4, It is characterized in that The specific steps of calculating the gap degree feature by the gap degree algorithm are as follows: Set multiple sliding boxes of different sizes to slide on the image of the region of interest and traverse each pixel; The position covered by each sliding box on the image of the region of interest is an analysis point, and the sum of the number of pixels in the sliding box and the sum of the squares at all analysis points are statistically calculated; Based on the size of each sliding box, the gap characteristic is calculated using the following formula: Among them, L(ε) is the gap characteristic, ε is the size of the sliding box, Q 1 =∑ i p(i, ε) is the sum of the number of pixels in the sliding box at the i-th analysis point, Q 2 =∑ i p(i, ε) 2 is the sum of the squares of the number of pixels in the sliding window at the i-th analysis point, and p(i, ε) is the number of pixels in the sliding box at the i-th analysis point.
6. The method for predicting the internal quality of watermelon fruit according to claim 1, It is characterized in that The quality measurement data in step 4 include the center sugar content, edge sugar content, hardness, adhesiveness, elasticity, viscosity, cohesion, chewiness, and resilience.
7. The method for predicting the internal quality of watermelon fruit according to claim 1, It is characterized in that The quality measurement data described in step 4 is obtained by measuring the quality of watermelon fruit using a texture analyzer, a colorimeter, and a saccharimeter.
8. A watermelon fruit internal quality prediction system, It is characterized in that include: A surface image acquisition module, used to acquire surface images of watermelon fruits at different growth stages under a standard light environment; An image processing module, for extracting a region of interest in a surface image using an image processing algorithm; A feature extraction module is used to extract the texture distribution features of the watermelon fruit in the region of interest image; wherein the texture distribution features include gap features, contrast features, average RGB value and texture proportion features; A data acquisition module is used to obtain quality measurement data of watermelon fruits; The model building and training module is used to construct a watermelon fruit internal quality prediction model using ordinary least squares method, support vector machine and decision tree algorithm, and to train using a training data set made with the extracted watermelon fruit texture distribution characteristics as independent variables and quality measurement data as dependent variables; The result output module is used to use the trained watermelon fruit internal quality prediction model to predict the surface image of the watermelon fruit to obtain the watermelon fruit internal quality prediction result.
9. A computer device for predicting the internal quality of watermelon fruit, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, It is characterized in that When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Multi-feature fusion Hami melon quality nondestructive testing method and system
CN119850547A
