Fruit identification method based on image processing

By applying image processing technology in crop phenotype research, combined with Unet model and other algorithms, the difficulty of identifying and measuring in the case of fruit occlusion in traditional methods is solved, and efficient and accurate fruit recognition and phenotype analysis is achieved.

CN119763085APending Publication Date: 2025-04-04NORTHWEST A & F UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411815570.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Traditional crop phenotype research methods rely on manual measurements, are inefficient and easy to introduce artificial errors. Especially when watermelon fruits are blocked, it is difficult to accurately identify and measure the phenotype characteristics of the fruit.

Method used

Using the fruit recognition method based on image processing, semantic segmentation, Sobel operator extraction profile, RANSAC denoising and overall least squares ellipse fitting method are performed through the Unet model, the fruit profile is fitted and the projected area is calculated to achieve accurate recognition and measurement of fruits.

Benefits of technology

This method can effectively identify occlusion fruits, improve the efficiency and accuracy of phenotype analysis of watermelon fruits, reduce artificial errors, and accurately calculate the projection area of ​​the fruit.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119763085A_ABST
    Figure CN119763085A_ABST
Patent Text Reader

Abstract

The invention discloses a fruit identification method based on image processing. The method comprises the following steps: acquiring a to-be-identified image; segmenting the to-be-identified image to obtain a fruit segmentation result; performing edge detection on the fruit segmentation result to obtain an edge contour; fitting the edge contour by using an overall least square ellipse fitting method to obtain a fitted fruit contour; and calculating the projection area of the fitted fruit contour, and performing fruit identification according to the projection area. According to the method, a watermelon sheltered fruit segmentation model is built by combining Unet semantic segmentation, Ransac noise reduction, Sobel operator contour extraction, overall least square ellipse fitting and other methods, and accurate measurement and calculation of the watermelon fruit projection area can be achieved through the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of agronomy, and in particular relates to a fruit recognition method based on image processing. Background Art

[0002] Crop phenotyping is a comprehensive assessment of a series of complex characteristics of crops, covering multiple aspects such as growth, development, structure and yield. Examples of directly measured phenotypic parameters include leaf characteristics, fruit shape and biomass accumulation. Through the measurement and analysis of these parameters, we can have a deeper understanding of the physiological and ecological characteristics of crops, providing a strong scientific basis for plant breeding and agricultural production. Quantitative extraction and analysis of phenotypic traits such as plant height, stem diameter, leaf area and fruit size of crops, and further exploration of the relationship between phenotype and yield, have become important contents of agricultural breeding and phenomics research.

[0003] Traditional crop phenotyping studies usually use manual observation and measurement methods, which not only consumes a lot of manpower, but also has limited data, low efficiency, and difficulty in comprehensive analysis of multiple plant traits. In addition, watermelon phenotyping methods based on manual measurement are mostly destructive measurements, and the collected phenotypic data are also prone to measurement errors caused by human factors. In order to overcome these shortcomings, researchers are exploring and developing new phenotyping research methods and technologies. Phenotyping analysis methods based on images and deep learning have effectively improved the efficiency and accuracy of phenotyping studies, providing strong support for agricultural scientific research and crop breeding.

[0004] With the development of computer technology, machine learning and computer vision technology have been widely used in fields such as botany, agriculture, and ecology. Plant phenotyping research using machine learning algorithms and computer vision technology helps to gain a deeper understanding of the growth and development laws of plants and their mechanisms of adapting to the environment, providing a scientific basis for plant breeding, disease prevention, and ecological environmental protection. However, machine learning algorithms usually require manual feature extraction and have a high dependence on training data, resulting in poor generalization performance of this method in phenotypic research. Summary of the invention

[0005] In order to solve the above technical problems, the present invention proposes a fruit recognition method based on image processing, which can realize effective recognition of occluded fruits.

[0006] The present invention provides a fruit recognition method based on image processing, comprising:

[0007] Obtain an image to be recognized;

[0008] Segmenting the image to be identified to obtain a fruit segmentation result;

[0009] Performing edge detection on the fruit segmentation result to obtain edge contours;

[0010] Using the global least squares ellipse fitting method, the edge contour is fitted to obtain a fitted fruit contour;

[0011] The projection area of ​​the fitted fruit contour is calculated, and the fruit is identified according to the projection area.

[0012] Optionally, the image to be identified is segmented using a Unet model to obtain a fruit segmentation result;

[0013] Wherein, the Unet model includes: an encoder and a decoder;

[0014] The encoder is used to extract high-level features and low-resolution features of the image to be recognized;

[0015] The decoder is used to restore the low-resolution features extracted by the encoder and perform feature fusion in combination with the high-level features of the corresponding layer of the encoder.

[0016] Optionally, performing edge detection on the fruit segmentation result to obtain edge contours includes:

[0017] The Sobel operator is used to perform edge detection on the fruit segmentation result to obtain the edge contour.

[0018] Optionally, the edge contour is fitted using an overall least squares ellipse fitting method, and before obtaining the fitted fruit contour, the method also includes: denoising the edge contour using a RANSAC method.

[0019] Optionally, performing denoising processing on the edge contour by using the RANSAC method includes:

[0020] Acquire a plurality of sample points and two focal points on the edge profile;

[0021] Calculating the distance between the two focal points to obtain a first distance;

[0022] respectively calculating the sum of the distances from the sample point to the two foci to obtain a second distance;

[0023] Acquire a third distance according to the first distance and the second distance;

[0024] It is determined whether the third distance meets a preset condition, noise points are determined, and the noise points are removed.

[0025] Optionally, a method for determining whether the third distance satisfies a preset condition is:

[0026] z i =|Dd i|

[0027]

[0028] z i ≥0.8σ

[0029] Where D is the sum of the distances between the two foci, d i is the sum of the distances between each sample point and the two foci, Z i D and d i The absolute value of the difference, σ is Z i The standard deviation of Z i The mean of , n is the total number of samples.

[0030] Optionally, fitting the edge contour using an overall least squares ellipse fitting method to obtain the fitted fruit contour includes:

[0031] Get the data parameters of the edge contour and the ellipse objective function:

[0032] ax 2 +bxy+cy 2 +dx+ey+f=0;

[0033] Among them, x, y are the parameters of the edge contour, a, b, c, d, e, f are the parameters of the ellipse objective function;

[0034] Transform the objective function to obtain unknown parameters Valuation;

[0035] Solving for the unknown parameters Estimate and obtain the fitted fruit outline.

[0036] Optionally, the method for calculating the projected area of ​​the fitted fruit outline is:

[0037] S=N1 / N2·S0

[0038] Among them, S is the actual area of ​​the fitted fruit contour, S0 is the actual area of ​​the reference object, N1 is the number of pixels of the reference object in the image, and N2 is the number of pixels covered by the fitted fruit projection.

[0039] Compared with the prior art, the present invention has the following advantages and technical effects:

[0040] In the process of watermelon fruit recognition, in order to solve the problem of watermelon fruit occlusion, a watermelon occluded fruit segmentation model was built by combining Unet semantic segmentation, Ransac denoising, Sobel operator contour extraction and global least squares ellipse fitting. This model can realize the accurate measurement of the projection area of ​​watermelon fruit. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0042] Figure 1 It is a flow chart of a fruit recognition method based on image processing according to an embodiment of the present invention;

[0043] Figure 2 It is a UNet network structure diagram of an embodiment of the present invention;

[0044] Figure 3 is a schematic diagram of comparison results of segmentation results of different models according to an embodiment of the present invention;

[0045] Figure 4 is a schematic diagram of a fruit occlusion sample according to an embodiment of the present invention;

[0046] Figure 5 is a schematic diagram of a result of traditional segmentation of occluded fruit according to an embodiment of the present invention;

[0047] Figure 6 Schematic diagram of the Sobel operator extraction result of an embodiment of the present invention

[0048] Figure 7 is a schematic diagram of an ellipse definition according to an embodiment of the present invention;

[0049] Figure 8 is a schematic diagram for comparing fitting results of an embodiment of the present invention;

[0050] Fig. 9 It is a schematic diagram of the comparison results of the watermelon fruit area according to the embodiment of the present invention. DETAILED DESCRIPTION

[0051] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0052] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0053] The present invention proposes a fruit recognition method based on image processing. Figure 1 As shown, the specific steps include:

[0054] Obtain an image to be recognized;

[0055] Segment the image to be identified and obtain the fruit segmentation result;

[0056] Perform edge detection on the fruit segmentation results to obtain edge contours;

[0057] The edge contour is fitted using the overall least squares ellipse fitting method to obtain the fitted fruit contour;

[0058] The projection area of ​​the fitted fruit contour is calculated and the fruit is identified based on the projection area.

[0059] Furthermore, the Unet model is used to segment the image to be identified to obtain the fruit segmentation result;

[0060] Among them, the Unet model includes: encoder and decoder;

[0061] The encoder is used to extract high-level features of the image to be recognized;

[0062] The decoder is used to restore the low-resolution features extracted by the encoder and perform feature fusion with the high-level features of the corresponding layer of the encoder.

[0063] Specifically, fruit size is one of the important phenotypic characteristics of economic crops such as watermelon, which can directly reflect the quality and yield of the crop. In this embodiment, Unet is selected for watermelon fruit segmentation. Figure 2 As shown in the figure, Unet is a variant of the traditional convolutional neural network FCN, which adopts a symmetrical U-shaped encoding and decoding structure. The encoder part is responsible for extracting the high-level feature representation of the input image, and gradually reduces the size and number of channels of the feature map through continuous convolution and pooling operations. The decoder part restores the low-resolution feature map extracted by the encoder to the resolution of the input image through upsampling operations, and combines the features of the corresponding layers of the encoder for feature fusion, and finally produces dense pixel-level segmentation results.

[0064] Furthermore, edge detection is performed on the fruit segmentation result to obtain edge contours, including:

[0065] The Sobel operator is used to perform edge detection on the fruit segmentation results to obtain the edge contour.

[0066] Specifically, the Sobel operator is a discrete differential operator for edge detection. The Sobel operator combines Gaussian smoothing and differential derivation. The Sobel operator detects edges by convolving the image to highlight high spatial frequency areas. It consists of a pair of 3×3 convolution kernels, which are applied to the image to produce horizontal and vertical gradient approximations. The Sobel operator is derived in the x and y directions respectively. The image is convolved with the kernel G in the horizontal direction. x Convolution; vertically convolve the image with the kernel G yPerform convolution. G x and G y As shown in formula 1. Finally, the above two results are combined at each point of the image to obtain the approximate gradient as shown in formula (1).

[0067]

[0068] In the formula, A is all the elements in the convolution kernel, G x is the horizontal gradient, G y is the vertical gradient.

[0069] This embodiment uses the Sobel operator to extract the outline of the watermelon fruit based on the occluded watermelon mask segmented by the Unet model. The extraction result is as follows: Figure 6 shown.

[0070] Furthermore, the edge contour is fitted by using the global least squares ellipse fitting method, and before obtaining the fitted fruit contour, the method also includes: performing denoising on the edge contour by using the RANSAC method;

[0071] Furthermore, the RANSAC method is used to perform denoising on the edge contour, including:

[0072] Acquire several sample points and two focal points on the edge profile;

[0073] Calculate the distance between the two foci and obtain a first distance;

[0074] Calculate the sum of the distances from the sample point to the two foci respectively to obtain the second distance;

[0075] According to the first distance and the second distance, obtaining a third distance;

[0076] It is determined whether the third distance meets a preset condition, a noise point is determined, and the noise point is removed.

[0077] Specifically, RANSAC (Random Sample Consensus) is a statistical method for fitting models and removing outliers in data. RANSAC uses random sampling to reduce the impact of outliers on the model and screen out inliers that fit the best model, which can robustly handle outliers in the data. The model fits geometric models (such as lines, planes, circles, etc.) and removes outliers caused by noise or other interference. This embodiment uses the RANSAC algorithm to remove noise that occurs during the watermelon contour extraction process. The specific steps are as follows:

[0078] Using the geometric definition of an ellipse, such as Figure 7As shown, the distance between the moving point P and the two fixed points F1 and F2 is a constant, where P is a point on the ellipse, and F1 and F2 are the two foci of the ellipse. Randomly select three points to construct an ellipse model. Assume that one of the points is point A on the ellipse, and the other two points are foci F1 and F2. Calculate the distance between the two foci as D.

[0079] Calculate the distance between each sample point and the two foci and d i (i=1,2,…,n), calculate z i =|Dd i |value.

[0080] definition in, If z i If ≥0.8σ, it is considered as a noise point and the deletion operation is performed; otherwise, the point is considered as an internal point and the retention operation is performed.

[0081] Where D is the sum of the distances between the two foci, d i is the sum of the distances between each sample point and the two foci, Z i D and d i The absolute value of the difference, σ is Z i The standard deviation of Z i The mean of , n is the total number of samples.

[0082] Furthermore, the edge contour is fitted using the overall least squares ellipse fitting method to obtain the fitted fruit contour, including:

[0083] Get the data parameters of the edge contour and the ellipse objective function:

[0084] ax 2 +bxy+cy 2 +dx+ey+f=0;

[0085] Among them, x, y are the parameters of the edge contour, a, b, c, d, e, f are the parameters of the ellipse objective function;

[0086] Transform the objective function to obtain unknown parameters Valuation;

[0087] Solving for unknown parameters Estimate and obtain the fitted fruit outline.

[0088] Specifically, Total Least Squares (TLS) is used to consider the influence of errors in the data. Unlike ordinary least squares, TLS considers not only the measurement error of the dependent variable, but also the measurement error of the independent variable, and minimizes the sum of the squares of the error correction numbers of all variables. It is suitable for situations where there is noise or error in the data. The total least squares method eliminates noise by minimizing the error influencing terms, and then performs a singular value decomposition operation on the matrix to obtain the least squares solution. This embodiment uses the total least squares method to achieve the fitting of the watermelon contour, and its principle is as follows:

[0089] Get the data parameters of the edge contour and the ellipse objective function:

[0090] ax 2 +bxy+cy 2 +dx+ey+f=0

[0091] Among them, x, y are the parameters of the edge contour, and a, b, c, d, e, f are the parameters of the ellipse objective function.

[0092] Move the item to get:

[0093] ax 2 +bxy+cy 2 +dx+f=-ey

[0094] Divide the left side of the equation by e:

[0095]

[0096] Let L = -y, Let m,n,p,q,r.

[0097] mx 2 +nxy+py 2 +qx+r=L

[0098] Let A = [x 2 xy y 2 x1],X=[mnpqr] T ,get:

[0099] L=AX

[0100] According to the overall least squares theory, considering that there are errors in both the coefficient matrix and the observation vector, we get:

[0101] L+e L =(A+E A )X

[0102] E A represents the error matrix of the coefficient matrix A, e Lrepresents the error matrix of the observation matrix L. By moving the above equation to and writing it in matrix form, we get:

[0103]

[0104] Perform singular value decomposition on the augmented matrix [A, L] to obtain:

[0105]

[0106] Among them, U1 represents an n×(m+1)-dimensional matrix, U2 represents an n×[n-(m+1)]-dimensional matrix, ∑ represents an (m+1)×(m+1)-dimensional matrix, and V represents an (m+1)×(m+1)-dimensional matrix.

[0107] Then the estimate of the unknown parameter estimate X is:

[0108]

[0109] in, V 12 and V 22 is the element in the last column of the orthogonal matrix V, V 12 is a (m+1)×(1)-dimensional vector, V 22 That is v m+1,m+1 is the last element of the last column.

[0110] Solving for ellipse parameter estimates After that, the ellipse equation fitted by the overall least squares method is obtained.

[0111] Furthermore, the projection area of ​​the fitted fruit outline is calculated, and the fruit recognition package is performed based on the projection area.

[0112] include:

[0113] The pixel statistics method is used to calculate the projection area of ​​the fitted fruit contour, and the fruit is identified based on the projection area.

[0114] This embodiment takes hanging vine watermelon as an example to perform fruit recognition, and the specific method is as follows:

[0115] In this embodiment, in order to select the most suitable semantic segmentation model for the watermelon fruit dataset, six pre-trained models were trained for comparison, including Unet (Resnet50), Unet (vgg), DeepLabV3 (Mobilnet), DeepLabV3 (Xception), Hrnet and Pspnet. Among them, two backbone networks were selected for comparison with Unet as the framework, namely Resnet50 and vgg; two backbone networks were selected for comparison with DeepLabV3 as the framework, namely Mobilnet and Xception.

[0116] This embodiment selects IOU, Recall and Precision as evaluation indicators.

[0117]

[0118] Among them, TP, FP, and FN are true positive, true negative, false positive, and false negative test results, respectively.

[0119] The segmentation experiment results are shown in Table 1. The watermelon fruit segmentation results are compared. Figure 3 As shown. It can be seen from the results that the model based on the Unet framework has the best segmentation effect. The IOU of the Unet (resnet) model is 97.53%, the Recall is 99.23%, and the precision is 98.27%. The Unet model with Resnet as the backbone network performed poorly, with an IOU of 97.48%, a Recall of 99.27%, and a precision of 98.19%. The two models with DeepLabV3 as the framework performed well when processing watermelon fruits with simple backgrounds, but when processing watermelon fruit images containing net bags, the segmentation mask showed obvious noise. In addition, the segmentation effect of Pspnet is significantly worse than that of other models, with an IOU of 62.5%, a Recall of 80.04%, and a precision of 74.05%. Based on the above results, in subsequent experiments, this embodiment uses the Unet (Resnet50) model as the watermelon fruit segmentation model to provide a mask for the calculation of the fruit projection area.

[0120] Table 1

[0121]

[0122] The growing environment of hanging vine watermelons is complex. In the natural shooting process, there is a widespread phenomenon of fruit occlusion. In the later stage of the growth of hanging vine watermelons, net bags are used to support and protect the watermelon fruits. The occlusion of watermelon fruits and net bags result in the edge information of watermelon fruits not being prominent during the segmentation process, which seriously restricts the accurate segmentation and area calculation of watermelon fruits in complex natural environments. This embodiment selects 300 occluded watermelon fruits from the self-made watermelon fruit dataset and divides them into three categories. The occluded fruit samples are as follows: Figure 4 As shown in the figure, samples 1, 2 and 3 are typical leaf-occluded images during the shooting process; samples 4 and 5 are typical label-occluded images during the shooting process; and sample 6 is a watermelon stem-occluded image during the shooting process.

[0123] This example uses the trained Unet (Resnet50) model to segment the above six typical fruit occlusion samples, and obtains the following Figure 5The results are shown in Figure 2. It can be found that the traditional segmentation model has a strong segmentation ability for unobstructed fruits, but performs poorly on the obstructed fruit dataset and cannot restore the obstructed part of the fruit. This problem will lead to large errors in the subsequent calculation of the projected area of ​​watermelon fruits using the pixel statistics method.

[0124] Traditional segmentation models cannot accurately segment occluded fruits, which affects the subsequent calculation of the fruit projection area. To this end, this embodiment proposes a fruit recognition method based on image processing. Considering that most of the captured watermelon fruit samples are elliptical in shape, first, this embodiment performs edge detection based on the watermelon fruit mask segmented by the traditional segmentation model to extract the edge contour of the watermelon fruit. Then, the overall least squares ellipse fitting method is used with the watermelon fruit contour as a sample to fit the elliptical contour of the watermelon fruit. Finally, the occluded part of the fruit is inferred from this contour to complete the segmentation of the watermelon fruit. The projection area of ​​the watermelon fruit is estimated based on the pixel statistics method. The experimental results are shown in the figure. Figure 8 shown.

[0125] The least squares method is widely used in various fitting problems. Its principle is to minimize the sum of squares of the measured fitting errors. There are two main methods for least squares fitting ellipses: algebraic method and geometric method. This embodiment uses the geometric method to fit the contour of the watermelon fruit. An ellipse is a special quadratic curve. Figure 5-6 The geometric definition of the ellipse is shown. The representation of the ellipse feature area is as follows:

[0126] In geometry, a general ellipse at any orientation can be defined as:

[0127] ax 2 +bxy+cy 2 +dx+ey+f=0

[0128] Among them, x, y are the parameters of the edge contour, and a, b, c, d, e, f are the parameters of the ellipse objective function.

[0129] Move the item to get:

[0130] ax 2 +bxy+cy 2 +dx+f=-ey

[0131] Divide the left side of the equation by e:

[0132]

[0133] Let L = -y, Let m,n,p,q,r.

[0134] mx 2 +nxy+py 2 +qx+r=L

[0135] Let A = [x 2 xy y 2 x1[,X=[mnpqr] T ,get:

[0136] L=AX

[0137] According to the overall least squares theory, considering that there are errors in both the coefficient matrix and the observation vector, we get:

[0138] L+e L =(A+E A )X

[0139] E A represents the error matrix of the coefficient matrix A, e L represents the error matrix of the observation matrix L. By moving the above equation to and writing it in matrix form, we get:

[0140]

[0141] Perform singular value decomposition on the augmented matrix [A, L] to obtain:

[0142]

[0143] Among them, U1 represents an n×(m+1)-dimensional matrix, U2 represents an n×[n-(m+1)]-dimensional matrix, ∑ represents an (m+1)×(m+1)-dimensional matrix, and V represents an (m+1)×(m+1)-dimensional matrix.

[0144] Then the estimate of the unknown parameter estimate X is:

[0145]

[0146] in, V 12 and V 22 is the element in the last column of the orthogonal matrix V, V 12 is a (m+1)×(1)-dimensional vector, V 22 That is v m+1,m+1 is the last element of the last column.

[0147] Solving for ellipse parameter estimates After that, the ellipse equation fitted by the overall least squares method is obtained.

[0148] from Figure 8It can be seen that the watermelon fruit contour fitted by the least squares method has obvious underfitting in the occluded part (the black box marked in the figure), and the fitted contour is smaller than the manually annotated true value contour; the results of fitting based on Ransac and the overall least squares method are basically consistent with the true value. In order to more accurately evaluate the accuracy of the model, the inferred watermelon occluded area is converted into a binary image and compared with the true value. The results are shown in Table 2. Among them, the segmentation model based on the overall least squares method has an IOU index improvement of 3.54%, a precision improvement of 6.05%, and a recall improvement of 2.53% compared with the least squares method.

[0149] Table 2

[0150]

[0151] In order to verify the performance of Unet (Resnet50) in calculating the projected area of ​​watermelon fruit, this example randomly selected 30 watermelon fruit samples to evaluate the calculation results of the projected area of ​​watermelon fruit. The projected area of ​​watermelon fruit was calculated using the pixel statistics method and compared with the manual measurement value. The results are as follows: Fig. 9 The coefficient of determination R between the calculated and manually measured values ​​of the watermelon fruit projection area is shown in Figure 2. 2 The root mean square error (RMSE) is 0.92, the mean absolute percentage error (MAPE) is 0.17 mm, and the mean absolute percentage error (MAPE) is 3.49%, indicating that the model we established can more accurately segment watermelon fruits and complete the measurement of the projection area of ​​watermelon fruits.

[0152] The present invention first introduces the experimental environment and training parameters, then compares and analyzes the segmentation performance of six traditional semantic segmentation models on a watermelon fruit dataset, and analyzes the experimental results in detail. Finally, the benchmark model for calculating the projection area of ​​watermelon fruit is determined to be the Unet model with Resnet50 as the backbone network. At the same time, the present invention verifies that the traditional segmentation model performs poorly in occluded fruit samples. To this end, the present invention analyzes the morphological features of three typical occluded samples, and based on the features, proposes an occluded fruit segmentation model based on ellipse fitting based on Ransac and global least squares. For the proposed fruit segmentation model, the experimental results of the model in the occluded fruit dataset are compared and analyzed from the evaluation indicators and visualization results, and the accuracy of the model is verified. Finally, a watermelon fruit projection area calculation model is built based on the segmentation results of the above model, and the root mean square error RMSE, mean absolute percentage error MAPE and determination coefficient R 2 Indicators such as ΔE and ΔG verified the effectiveness of the model in calculating the projection area of ​​watermelon fruit.

[0153]

[0154] In the formula, y and are the true value and the predicted value respectively. N represents the total number of samples, y i represents the true label value of the i-th sample, represents the average value of sample labels, represents the predicted label value of the i-th sample.

[0155] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A fruit recognition method based on image processing, characterized in that: include: Obtain an image to be recognized; Segmenting the image to be identified to obtain a fruit segmentation result; Performing edge detection on the fruit segmentation result to obtain edge contours; Using the global least squares ellipse fitting method, the edge contour is fitted to obtain a fitted fruit contour; The projection area of ​​the fitted fruit contour is calculated, and the fruit is identified according to the projection area.

2. A fruit recognition method based on image processing according to claim 1, characterized in that: Using the Unet model to segment the image to be identified, and obtaining a fruit segmentation result; Wherein, the Unet model includes: an encoder and a decoder; The encoder is used to extract high-level features and low-resolution features of the image to be recognized; The decoder is used to restore the low-resolution features extracted by the encoder and perform feature fusion in combination with the high-level features of the corresponding layer of the encoder.

3. A fruit recognition method based on image processing according to claim 1, characterized in that: Performing edge detection on the fruit segmentation result to obtain edge contours includes: The Sobel operator is used to perform edge detection on the fruit segmentation result to obtain the edge contour.

4. A fruit recognition method based on image processing according to claim 1, characterized in that: The edge contour is fitted by using the global least squares ellipse fitting method, and before obtaining the fitted fruit contour, the method also includes: performing denoising processing on the edge contour by using the RANSAC method.

5. A fruit recognition method based on image processing according to claim 4, characterized in that: The denoising process of the edge contour using the RANSAC method includes: Acquire a plurality of sample points and two focal points on the edge profile; Calculating the distance between the two focal points to obtain a first distance; respectively calculating the sum of the distances from the sample point to the two foci to obtain a second distance; Acquire a third distance according to the first distance and the second distance; It is determined whether the third distance meets a preset condition, noise points are determined, and the noise points are removed.

6. A fruit recognition method based on image processing according to claim 5, characterized in that: The method for judging whether the third distance meets the preset condition is: z i =|D-d i | z i ≥0.8σ Where D is the sum of the distances between the two foci, d i is the sum of the distances between each sample point and the two foci, z i D and d i The absolute value of the difference, σ is z i The standard deviation of For z i The mean of , n is the total number of samples.

7. A fruit recognition method based on image processing according to claim 1, characterized in that: Using the overall least squares ellipse fitting method to fit the edge contour, obtaining the fitted fruit contour includes: Get the data parameters of the edge contour and the ellipse objective function: ax 2 +bxy+cy 2 +dx+ey+f=0; Among them, x, y are the parameters of the edge contour, a, b, c, d, e, f are the parameters of the ellipse objective function; Transform the objective function to obtain unknown parameters Valuation; Solving for the unknown parameters Estimate and obtain the fitted fruit outline.

8. A fruit recognition method based on image processing according to claim 1, characterized in that: The method for calculating the projected area of ​​the fitted fruit outline is: S=N1 / N2·S0 Among them, S is the actual area of ​​the fitted fruit contour, S0 is the actual area of ​​the reference object, N1 is the number of pixels of the reference object in the image, and N2 is the number of pixels covered by the fitted fruit projection.