Agricultural product quality detection and grading method and system based on computer assistance

Through computer-aided methods, chain code operation and convex hull algorithm are used to obtain the final outer contour edge line of agricultural products, solving the problem of inaccurate contour lines in agricultural product classification, and achieving efficient and accurate grading of agricultural product quality.

CN120279342AActive Publication Date: 2025-07-08SHENYANG JIUDAO TECHNOLOGY CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510764397.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-07-08
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

In the prior art, in the quality inspection of agricultural products, it is difficult to accurately obtain the outer contour lines that do not contain non-fruit parts, resulting in inaccurate classification of agricultural products.

Method used

Using computer-aided methods, through chain code operation and convex hull algorithm, the abnormal edges of the initial outer contour edge line are deleted, the incomplete edge line is filled, the final outer contour edge line is obtained, and the distance between each pixel point and the center point is calculated to evaluate the roundness of the agricultural product.

Benefits of technology

The accurate acquisition and grading of the outer contour lines of agricultural products is achieved, the accuracy and efficiency of agricultural product grading is improved, and the influence of subjective factors is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120279342A_ABST
    Figure CN120279342A_ABST
Patent Text Reader

Abstract

The invention relates to a computer-aided agricultural product quality detection grading method and system, and belongs to the technical field of image processing, and the method comprises the steps: obtaining a to-be-detected agricultural product image, extracting a skin part in the to-be-detected agricultural product image as an initial agricultural product image, and obtaining an initial outer contour edge line of the initial agricultural product image; obtaining a chain code sequence of the initial outer contour edge line, and selecting an abnormal chain code value in the chain code sequence; forming an abnormal edge by the pixel points corresponding to the abnormal chain code values, deleting the abnormal edge to obtain an incomplete edge line, and filling the incomplete edge line to obtain a final outer contour edge line of the skin; according to the method, the final outer contour edge line of the agricultural product can be accurately obtained, the roundness degree of the final outer contour edge line is calculated according to the distance between each pixel point on the final outer contour edge line and the center point, and the agricultural product is graded according to the roundness degree.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing, and particularly relates to a method and system for detecting and grading the quality of agricultural products based on computer assistance. Background Art

[0002] With the advancement of agricultural modernization, the yield and quality of agricultural products have been significantly improved. However, the quality evaluation of agricultural products still mainly relies on manual experience, which is not only inefficient but also easily affected by subjective factors. In order to achieve rapid and accurate grading of agricultural products and improve the market competitiveness of agricultural products, it is particularly important to develop a method and system for detecting and grading the quality of agricultural products based on computer assistance.

[0003] In order to quickly select the agricultural products with the best quality from the batch-picked agricultural products, it is necessary to accurately obtain the outer contour line of the agricultural products and calculate the roundness of the area enclosed by the outer contour line. However, the conventional methods for obtaining the outer contour line of agricultural products have defects: if the non-fruit parts of the agricultural products (such as green leaves, fruit stalks, etc.) are included, it will lead to inaccurate calculation of the roundness of the agricultural products; if the non-fruit parts are directly removed completely, depressions will be formed in the non-fruit parts, and there are actually agricultural product fruits in the depression areas. If the outer contour line of the agricultural products is directly recognized in the presence of depression areas, the recognized outer contour line will be defective, and thus the agricultural products cannot be accurately graded. Summary of the Invention

[0004] The present invention provides a method and system for detecting and grading the quality of agricultural products based on computer assistance, which can accurately obtain the final outer contour edge line of the agricultural products, and calculate the roundness of the final outer contour edge line by using the distance between each pixel point on the final outer contour edge line and the center point, and grade the agricultural products according to the roundness.

[0005] The method for detecting and grading the quality of agricultural products based on computer assistance of the present invention adopts the following technical solutions: Obtain an image of the agricultural product to be detected; Extract the epidermal part in the image of the agricultural product to be detected as the initial agricultural product image, and obtain the initial outer contour edge line of the initial agricultural product image; Start from any pixel point on the initial outer contour edge line to perform chain code operation on the initial outer contour edge line, and obtain the chain code sequence of the initial outer contour edge line in the clockwise direction; Calculate the difference between adjacent two chain code values in the chain code sequence, and select all adjacent two chain code values whose absolute value of the difference is less than or equal to a preset first threshold as abnormal chain code values; Form an abnormal edge by the pixel points corresponding to the abnormal chain code values, and delete the abnormal edge in the initial outer contour edge line to obtain an incomplete edge line; Fill in the incomplete edge line to obtain the final outer contour edge line of the epidermis; Obtain the center point of the area enclosed by the final outer contour edge line, calculate the roundness of the final outer contour edge line using the distance between each pixel point on the final outer contour edge line and the center point, and classify the agricultural products according to the roundness.

[0006] Further, the steps of calculating the roundness of the final outer contour edge line using the distance between each pixel point on the final outer contour edge line and the center point include: Establish a coordinate system with the center point of the area enclosed by the final outer contour edge line as the origin; Calculate the distance between each pixel point on the final outer contour edge line and the center point, form a distance set from all the obtained distance values, and take the mean of all the obtained distances as the virtual radius; Calculate the standard deviation of all the distance values in the distance set, and take the ratio of the standard deviation to the virtual radius as the first eigenvalue; According to the intersection points of the final outer contour edge line with the horizontal and vertical axes of the coordinate system, calculate the aspect ratio of the final outer contour edge line, and take the aspect ratio of the final outer contour edge line as the second eigenvalue; Take the product of the first eigenvalue and the second eigenvalue as the roundness of the final outer contour edge line.

[0007] Further, the steps of calculating the aspect ratio of the final outer contour edge line according to the intersection points of the final outer contour edge line with the horizontal and vertical axes of the coordinate system include: Obtain the first intersection point of the final outer contour edge line with the positive half-axis of the horizontal axis of the coordinate system and the second intersection point with the negative half-axis of the horizontal axis of the coordinate system; Add the absolute value of the abscissa of the first intersection point and the absolute value of the abscissa of the second intersection point as the width of the final outer contour edge line; Obtain the third intersection point of the final outer contour edge line with the positive half-axis of the vertical axis of the coordinate system and the fourth intersection point with the negative half-axis of the vertical axis of the coordinate system; Add the absolute value of the ordinate of the third intersection point and the absolute value of the ordinate of the fourth intersection point as the length of the final outer contour edge line; Calculate the aspect ratio of the final outer contour edge line.

[0008] Further, the steps of classifying the agricultural products according to the roundness include: When the roundness is greater than the preset second threshold, determine that the agricultural product to be detected is a low-quality agricultural product; When the roundness is less than or equal to the preset second threshold, determine that the agricultural product to be detected is a high-quality agricultural product.

[0009] Further, the step of extracting the epidermal part from the agricultural product image to be detected as the initial agricultural product image includes: Performing color clustering on the agricultural product image to be detected to extract the epidermal part in the image as the initial agricultural product image.

[0010] Further, the step of filling the incomplete edge line to obtain the final outer contour edge line of the epidermis includes: Using the convex hull algorithm to fill the incomplete edge line to obtain the final outer contour edge line of the epidermis.

[0011] A computer-aided agricultural product quality detection and grading system includes: An image acquisition module for acquiring an agricultural product image to be detected; An initial outer contour edge line acquisition module for extracting the epidermal part from the agricultural product image to be detected as the initial agricultural product image and obtaining the initial outer contour edge line of the initial agricultural product image; A chain code sequence acquisition module for performing chain code operations on the initial outer contour edge line starting from any pixel point on the initial outer contour edge line and obtaining the chain code sequence of the initial outer contour edge line in the clockwise direction; An abnormal chain code value selection module for calculating the difference between adjacent two chain code values in the chain code sequence and selecting both adjacent two chain code values whose absolute value of the difference is less than or equal to a preset first threshold as abnormal chain code values; A final outer contour edge line acquisition module for forming an abnormal edge from the pixel points corresponding to the abnormal chain code values, deleting the abnormal edge in the initial outer contour edge line to obtain an incomplete edge line; and for filling the incomplete edge line to obtain the final outer contour edge line of the epidermis; A roundness calculation module for obtaining the center point of the area enclosed by the final outer contour edge line and calculating the roundness of the final outer contour edge line using the distance between each pixel point on the final outer contour edge line and the center point; A grading module for grading agricultural products according to the roundness.

[0012] The beneficial effects of the present invention are: The present invention provides a computer-aided method and system for detecting and grading the quality of agricultural products. First, an initial image of an agricultural product containing only the epidermal part is initially obtained, and at the same time, the initial outer contour edge line of the initial agricultural product image is obtained. Since the non-fruit part is deleted from the initial agricultural product image, the area with green leaves in the initial outer contour edge line will be deleted, resulting in a depression in the initial outer contour edge line. And the depression position in the initial outer contour edge line will also exist. Therefore, the depression position in the initial outer contour edge line is the abnormal position. To obtain the abnormal position of the initial outer contour edge line, a chain code operation is performed on the initial outer contour edge line to obtain the chain code sequence of the initial outer contour edge line, and the abnormal chain code value is selected according to the difference between the values of two adjacent chain codes in the chain code sequence.

[0013] The abnormal edge is composed of the pixel points corresponding to the abnormal chain code values. After deleting the abnormal edge in the initial outer contour edge line, an incomplete edge line is obtained. The convex hull algorithm is used to fill the incomplete edge line to obtain the final outer contour edge line of the agricultural product. The final outer contour edge line obtained thereby removes the non-fruit part and at the same time obtains the complete edge line of the agricultural product fruit area; after obtaining the final outer contour edge line, the roundness of the final outer contour edge line is calculated according to the distance between each pixel point on the final outer contour edge line and the center point, and the agricultural products are graded according to the roundness. Brief Description of the Drawings

[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0015] Figure 1 It is a flowchart of the overall steps of the embodiment of the computer-aided method for detecting and grading the quality of agricultural products of the present invention; Figure 2 It is a schematic diagram of the distance from any edge point K on the final outer contour edge line to the center point in the present invention; Figure 3 It is a schematic diagram of high-quality agricultural products in the present invention; Figure 4 It is a schematic diagram of low-quality agricultural products in the present invention. Detailed Embodiments

[0016] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0017] An embodiment of the computer-aided agricultural product quality detection and grading method of the present invention is as Figure 1 shown, and the method includes: S1. Obtain an image of the agricultural product to be detected.

[0018] The present invention is applicable to a variety of agricultural products, including but not limited to apples, pears, peaches, citrus fruits, tomatoes, etc. These agricultural products occupy an important position in the market, and the quality directly affects consumers' willingness to purchase and the economic benefits of agricultural products. Taking apples as an example, as the king of fruits, they are sweet in taste and high in nutritional value, integrating the advantages of fruits, vegetables, and medicine, and are a kind of green, environmentally friendly, and health-care food. However, there are differences in the quality of apples, resulting in different tastes and selling prices. The quality of apples is closely related to their external shape characteristics. Apples with a round shape, a round tail, and a short and plump overall shape have a higher maturity, better taste and quality; on the contrary, apples with a long and thin shape and an obvious conical tail have lower water and sugar content, relatively bland taste, and poor quality. Similarly, other agricultural products such as pears, peaches, citrus fruits, tomatoes, etc. also have similar situations, and their quality is closely related to their external shape characteristics.

[0019] In the present invention, the picked agricultural products (taking apples as an example) are placed on a pure white background conveyor belt, and a camera is used to collect the full-domain image of the agricultural product to be detected directly above the conveyor belt. The collected full-domain image of the agricultural product to be detected is grayscale processed, and then the Otsu self-adaptive threshold segmentation method is used to extract the agricultural product area in the full-domain image of the agricultural product to be detected as the image of the agricultural product to be detected. Then the image of the agricultural product to be detected is transmitted to a computer, and the computer processes the collected image. The following steps are specific computer processing steps.

[0020] S2. Extract the epidermis part in the image of the agricultural product to be detected as the initial agricultural product image, and obtain the initial outer contour edge line of the initial agricultural product image.

[0021] The step of extracting the epidermis part in the image of the agricultural product to be detected as the initial agricultural product image includes: performing color clustering on the image of the agricultural product to be detected to extract the epidermis part in the image as the initial agricultural product image.

[0022] The steps for obtaining the initial outer contour edge line of the initial agricultural product image include: performing binarization processing on the obtained initial agricultural product image to obtain a binarized agricultural product image, and connecting the outer contour edge pixel points in the binarized agricultural product image to obtain the outer contour edge line.

[0023] In step S1, the color image of the agricultural product to be detected has been obtained. However, since there are a large number of leaves (non-fruit parts) in the color image of the agricultural product to be detected, which interfere with the recognition and judgment of the shape of the agricultural product, it is necessary to remove the interference of the leaves from the image of the agricultural product to be detected, and fill the edge defects of the removed agricultural product image to restore it to the original smooth contour, and finally obtain the final edge that only contains the fruit of the agricultural product and is smooth.

[0024] In order to obtain the final outer contour edge line of the agricultural product, it is first necessary to use a color clustering algorithm to extract the non-fruit parts from the image of the agricultural product to be detected, and reduce the interference brought by the non-fruit parts. The specific operation is as follows: Use the KMeans pixel clustering method, which is a classic algorithm in solving clustering problems and is simpler and more efficient. It is an unsupervised algorithm and does not require preparing a training set; the algorithm idea is very simple. For a given sample set, the Euclidean distance is used as the standard to measure the similarity between objects. The greater the similarity, the shorter the distance; the purpose is to extract the green leaves.

[0025] 1. Data preparation: Input the sample set , determine the number of clusters for clustering (In order to distinguish between leaves and the agricultural product itself, it is set to two clusters of red and green for classification. Red represents red apples, and green represents green apple leaves), and the output is the cluster division .

[0026] 2. For the unclustered data set, first randomly select K samples from the sample data set as the initial K centroids, that is, two centroids.

[0027] 3. Calculate the distance from each sample data to the center point, and cluster according to the center point that is closest to itself.

[0028] 4. According to the result of the previous clustering, calculate the new center point (the average value, that is, the mean vector of the cluster).

[0029] 5. Repeat steps 3 and 4 iteratively. When the change of the center point meets the convergence condition (reaching the set number of iterations or the mean vector no longer changes), the final clustering result is obtained. The above steps divide the agricultural product image to be detected into two parts: green and red. Extract the green pixel part and leave the remaining part as the initial agricultural product image. Use median filtering operation on the initial agricultural product image to remove the interference of noise in the image. The median filtering method is a non-linear smoothing technique that sets the gray value of each pixel point to the median of the gray values of all pixel points within a certain neighborhood window of this point. It can achieve a good filtering effect without significantly blurring the image and can simultaneously maintain the original edge features of the agricultural product image, without losing the contour information, making the surrounding pixels closer to the true values, thereby eliminating isolated noise points. After obtaining the denoised image, perform binarization processing on the denoised image to obtain a binarized agricultural product image. Connect the outer contour edge pixel points in the binarized agricultural product image to obtain the initial outer contour edge line.

[0030] S3. Start from any pixel point on the initial outer contour edge line and perform a chain code operation on the initial outer contour edge line to obtain the chain code sequence of the initial outer contour edge line in the clockwise direction.

[0031] Perform a chain code operation on the initial outer contour edge line using the Freeman chain code. It is a method that uses the starting point coordinates of the curve and the boundary point direction code to describe the curve or boundary, and it is a coding representation method of the boundary. This step determines the smoothness of the initial outer contour edge line, that is, the abnormal degree of the initial outer contour edge line, according to the chain code.

[0032] Start from any pixel point on the initial outer contour edge line, traverse each pixel point on the initial outer contour edge line in the clockwise direction, and record the direction of the next pixel point relative to the previous pixel point.

[0033] Quantify the relative direction into specific values. Since there are 8 adjacent points around any pixel, and the eight-connected chain code just conforms to the actual situation of the pixel points and can accurately describe the information of the central pixel point and its adjacent points, the eight-connected chain code is selected for judging the smoothness of the edge. Select any edge point on the initial outer contour edge line as the starting point S. The chain code starts from the starting point S of the initial outer contour edge line and obtains the trend of the initial outer contour edge line in the clockwise direction to form the chain code sequence of the outer contour edge line.

[0034] S4. Calculate the difference between adjacent two chain code values in the chain code sequence, and select all adjacent two chain code values whose absolute value of the difference is less than or equal to the preset first threshold as abnormal chain code values.

[0035] After obtaining the chain code sequence, calculate the difference between each chain code value and the previous adjacent chain code value in the adjacent two chain code values of the chain code sequence; among them, the previous adjacent chain code value of the first chain code value in the chain code sequence is the last chain code value in the chain code sequence; when the absolute value of the difference is less than or equal to the preset first threshold, both chain code values corresponding to the difference are selected as abnormal chain code values, and all abnormal chain code values are selected in the same way.

[0036] When the initial outer contour edge is relatively smooth and there is no abnormal mutation, the absolute value of the difference between the subsequent chain code value and the previous chain code value in the obtained chain code sequence is not greater than 1. Therefore, the preset first threshold is set to 1, and the obtained set of chain code sequences is , then , the calculation formula for the difference between adjacent two chain code values can be obtained as: Among them, represents the th chain code value in the chain code sequence; represents the th chain code value in the chain code sequence; calculate the difference between adjacent two chain code values according to the formula. When the absolute value of the difference is less than or equal to the preset first threshold, both chain code values corresponding to the difference are selected as abnormal chain code values, and all abnormal chain code values are selected.

[0037] S5. The abnormal edge is composed of the pixel points corresponding to the abnormal chain code values. After deleting the abnormal edge in the initial outer contour edge line, an incomplete edge line is obtained.

[0038] After obtaining the abnormal chain code values, the abnormal edge is composed of the pixel points corresponding to the abnormal chain code values, that is, the abnormal edge that needs to be deleted due to the interference of green leaves is obtained. After finding the abnormal edge where the depression exists, the abnormal edge is deleted in the initial outer contour edge line, and an incomplete edge line is obtained.

[0039] S6. Fill the incomplete edge line to obtain the final outer contour edge line of the epidermis.

[0040] After deleting the abnormal edge in the initial outer contour edge line, an incomplete edge line is obtained. It is necessary to fill the incomplete edge line. The convex hull algorithm is selected to fill the incomplete edge line to obtain the final outer contour edge line of the epidermis.

[0041] When filling in incomplete edge lines, the edge of agricultural products can be represented as follows: The pixel points around the incomplete edge line are placed in a set D, and the minimum point set E is obtained so that the polygon shape formed by connecting E can contain all the pixel points in D. For the concave part of the agricultural product edge, the surrounding pixel points are found and then the specific operation of forming a convex hull is carried out using the classic Graham scan method. The idea of this scan method is to first find a point on the convex hull, and then starting from this point, find the points on the convex hull one by one in the counterclockwise direction for convex hull filling. After convex hull filling, the final outer contour edge line of the epidermis is obtained. The final outer contour edge line is the ideal edge of the agricultural product image, and then further geometric analysis is carried out based on the obtained final outer contour edge line.

[0042] S7. Obtain the center point of the area enclosed by the final outer contour edge line, calculate the roundness of the final outer contour edge line using the distance between each pixel point on the final outer contour edge line and the center point, and classify the agricultural products according to the roundness.

[0043] The steps of calculating the roundness of the final outer contour edge line using the distance between each pixel point on the final outer contour edge line and the center point include: Establish a coordinate system with the center point of the area enclosed by the final outer contour edge line as the origin; Calculate the distance between each pixel point on the final outer contour edge line and the center point, and form a distance set from all the obtained distance values. Take the mean value of all the obtained distances as the virtual radius; Calculate the standard deviation of all the distance values in the distance set, and take the ratio of the standard deviation to the virtual radius as the first eigenvalue; According to the intersection points of the final outer contour edge line with the horizontal axis and vertical axis of the coordinate system, calculate the aspect ratio of the final outer contour edge line, and take the aspect ratio of the final outer contour edge line as the second eigenvalue; Take the product of the first eigenvalue and the second eigenvalue as the roundness of the final outer contour edge line.

[0044] The steps of calculating the aspect ratio of the final outer contour edge line according to the intersection points of the final outer contour edge line with the horizontal axis and vertical axis of the coordinate system include: Obtain the first intersection point of the final outer contour edge line with the positive half-axis of the horizontal axis of the coordinate system and the second intersection point with the negative half-axis of the horizontal axis of the coordinate system; Add the absolute value of the abscissa of the first intersection point and the absolute value of the abscissa of the second intersection point as the width of the final outer contour edge line; Obtain the third intersection point of the final outer contour edge line with the positive half-axis of the vertical axis of the coordinate system and the fourth intersection point with the negative half-axis of the vertical axis of the coordinate system; Add the absolute value of the ordinate of the third intersection point and the absolute value of the ordinate of the fourth intersection point as the length of the final outer contour edge line; Calculate the aspect ratio of the final outer contour edge line.

[0045] The steps for grading agricultural products according to the roundness include: when the roundness is greater than the preset second threshold, determining the agricultural product to be detected as a low-quality agricultural product; when the roundness is less than or equal to the preset second threshold, determining the agricultural product to be detected as a high-quality agricultural product.

[0046] After obtaining the final outer contour edge line, the center point of the final outer contour edge line is found through the OTSU algorithm. Then, with the center point O as the origin, a coordinate axis is established, and the distances from each edge point on the final outer contour edge line to the center point are obtained. Given that the coordinates of the center point are (0, 0), as Figure 2 shown, it is a schematic diagram of the distance from any edge point K on the final outer contour edge line to the center point; for any edge point K ( , ) on the final outer contour edge line, the calculation formula for the distance d1 to the center point is: where, represents the distance from any edge point K ( , ) on the final outer contour edge line to the center point; represents the abscissa of any edge point K on the final outer contour edge line; represents the ordinate of any edge point K on the final outer contour edge line; the set of edge points on the final outer contour edge line is , and thus, the distance calculation from the ideal edge point K to the center point O is performed in sequence. The obtained distance set D can be expressed as . The first intersection point of the final outer contour edge line with the positive half-axis of the x-axis of the coordinate system is and the second intersection point of the final outer contour edge line with the negative half-axis of the x-axis of the coordinate system . At the same time, the third intersection point of the final outer contour edge line with the positive half-axis of the y-axis of the coordinate system and the fourth intersection point with the negative half-axis of the y-axis of the coordinate system are also obtained. Starting from the point, each edge point and its value from the center point O are traversed clockwise in the order of (Q1, P1, Q2, P2). According to the shape of the final outer contour edge line, the roundness of the agricultural product is evaluated, and then the quality of the agricultural product is analyzed.

[0047] According to the distances d corresponding to each edge point K on the final outer contour edge line, the curve contours of agricultural products of different qualities are drawn respectively. The image contours drawn from the distances of each edge point to the center point are relatively round, and there will also be contours that are relatively more elliptical in shape. The roundness of the final outer contour edge line is evaluated, and the difference between the final outer contour edge line and the standard circle is compared (the smaller the difference, the better the quality).

[0048] First, obtain the set D of the distances from all the edge points on the final outer contour edge line to the center point, calculate the mean value of all the values in the set D, that is, the average length of the edge points from the center point, and let it be the virtual radius of the reference circle. Then calculate the standard deviation of all the values in the set D, and calculate the ratio of the standard deviation to the virtual radius. The reason for choosing the standard deviation is that it can reflect the degree of dispersion of a set of data, that is, the degree of large or small changes in the curve, and then determine the roundness of the final outer contour edge line. Calculate the standard deviation of all the distance values in the distance set, and take the ratio of the standard deviation to the virtual radius as the first eigenvalue; according to the intersection points of the final outer contour edge line with the horizontal and vertical axes of the coordinate system, calculate the aspect ratio of the final outer contour edge line, and take the aspect ratio of the final outer contour edge line as the second eigenvalue; take the product of the first eigenvalue and the second eigenvalue as the roundness of the final outer contour edge line. The greater the obtained roundness of the final outer contour edge line, the more round the agricultural product to be detected is proved. On the contrary, it proves that the roundness of the agricultural product to be detected is low. According to the appearance quality characteristics of the agricultural product, the rounder it is, the deeper its maturity, and the relatively more water and sugar it contains. On the contrary, the taste of the slender-shaped one is relatively worse, and the relatively less water and sugar it contains.

[0049] The following is a specific expansion: It is known that the set of the distances from the edge points on the final outer contour edge line to the center point is D = , and the calculation formula for its mean value is: = Among them, represents the mean value of all the distance values in the set D; represents the total number of the distance values included in the set D; represents the th distance value in the set D; Calculate the standard deviation of all the distance values in the set D, take the mean value of all the obtained distances as the virtual radius, and take the ratio of the standard deviation to the virtual radius as the first eigenvalue S. The calculation formula for the first eigenvalue S is: Among them, represents the first eigenvalue; represents the standard deviation of all the distance values in the set D; represents the virtual radius.

[0050] Take the ratio of the length and width of the final outer contour edge line contour as an important reference. The smaller this ratio is, the more uniform and coordinated the contour distribution is, and the greater the possibility of judging it as a high-quality agricultural product; the larger this ratio is, the more obvious the difference between the length and width of the contour is, and the more likely it is to be a low-quality agricultural product.

[0051] Calculate the aspect ratio of the final outer contour edge line: Among them, represents the second eigenvalue; represents the third intersection point of the final outer contour edge line and the positive semi-axis of the vertical axis of the coordinate system; represents the fourth intersection point of the final outer contour edge line and the negative semi-axis of the vertical axis of the coordinate system; represents the first intersection point of the final outer contour edge line and the positive semi-axis of the horizontal axis of the coordinate system; represents the second intersection point of the final outer contour edge line and the negative semi-axis of the horizontal axis of the coordinate system.

[0052] Take the product of the first eigenvalue and the second eigenvalue as the roundness of the final outer contour edge line. The roundness of the final outer contour edge line The calculation formula is: Among them, represents the roundness of the final outer contour edge line; represents the first eigenvalue; represents the second eigenvalue. When the contour of the final outer contour edge line is closer to the standard circle, the aspect ratio of the curve approaches 1, and the ratio of the standard deviation of the curve to the virtual radius is smaller; as the values of S and C gradually increase, the roundness of the final outer contour edge line will gradually decrease. Therefore, the smaller S and C are, the more likely it is to be high-quality agricultural products, as Figure 3 shown in the schematic diagram of high-quality agricultural products; the larger S and C are, the more likely it is to be low-quality agricultural products, as Figure 4 shown in the schematic diagram of low-quality agricultural products.

[0053] Classify agricultural products using the second threshold. Set the second threshold as G = 2, and this second threshold is set according to experience.

[0054] When S * C > G, it is determined that the agricultural product to be detected is a low-quality agricultural product.

[0055] On the contrary, when S * C < G, it is determined that the agricultural product to be detected is a high-quality agricultural product.

[0056] Finally, the classification of the quality of agricultural products is realized, and the intelligent grading of the quality of agricultural products is achieved.

[0057] The computer-aided agricultural product quality detection and grading system includes: An image acquisition module for acquiring an image of the agricultural product to be detected; An initial outer contour edge line acquisition module for extracting the epidermal part in the image of the agricultural product to be detected as the initial agricultural product image and acquiring the initial outer contour edge line of the initial agricultural product image; The chain code sequence acquisition module is used to perform chain code operations on the initial outer contour edge line starting from any pixel point on the initial outer contour edge line, and obtain the chain code sequence of the initial outer contour edge line in the clockwise direction; The abnormal chain code value selection module is used to calculate the difference between two adjacent chain code values in the chain code sequence, and select both adjacent chain code values whose absolute value of the difference is less than or equal to a preset first threshold as abnormal chain code values; The final outer contour edge line acquisition module is used to form an abnormal edge from the pixel points corresponding to the abnormal chain code values, and delete the abnormal edge in the initial outer contour edge line to obtain an incomplete edge line; it is used to fill the incomplete edge line to obtain the final outer contour edge line of the epidermis; The roundness calculation module is used to obtain the center point of the area enclosed by the final outer contour edge line, and calculate the roundness of the final outer contour edge line using the distance between each pixel point on the final outer contour edge line and the center point; The grading module is used to grade agricultural products according to the roundness.

[0058] In summary, the present invention provides a method and system for detecting and grading the quality of agricultural products based on computer assistance, which can accurately obtain the final outer contour edge line of agricultural products, calculate the roundness of the final outer contour edge line using the distance between each pixel point on the final outer contour edge line and the center point, and grade agricultural products according to the roundness.

[0059] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A computer-aided method for detecting and grading the quality of agricultural products, characterized in that, The method includes: Obtaining an agricultural product image to be detected; Extracting the epidermal part in the agricultural product image to be detected as the initial agricultural product image, and obtaining the initial outer contour edge line of the initial agricultural product image; Starting from any pixel point on the initial outer contour edge line, performing a chain code operation on the initial outer contour edge line, and obtaining a chain code sequence of the initial outer contour edge line in the clockwise direction; Calculating the difference between adjacent two chain code values in the chain code sequence, and selecting all adjacent two chain code values whose absolute value of the difference is less than or equal to a preset first threshold as abnormal chain code values; Forming an abnormal edge by the pixel points corresponding to the abnormal chain code values, and deleting the abnormal edge in the initial outer contour edge line to obtain an incomplete edge line; Filling the incomplete edge line to obtain the final outer contour edge line of the epidermis; Obtaining the center point of the area surrounded by the final outer contour edge line, calculating the roundness of the final outer contour edge line by using the distance between each pixel point on the final outer contour edge line and the center point, and grading the agricultural product according to the roundness.

2. The computer-aided agricultural product quality detection and grading method according to claim 1, characterized in that The step of calculating the roundness of the final outer contour edge line by using the distance between each pixel point on the final outer contour edge line and the center point includes: Establishing a coordinate system with the center point of the area surrounded by the final outer contour edge line as the origin; Calculating the distance between each pixel point on the final outer contour edge line and the center point, forming a distance set from the obtained all distance values, and taking the mean value of the obtained all distances as the virtual radius; Calculating the standard deviation of all distance values in the distance set, and taking the ratio of the standard deviation to the virtual radius as the first eigenvalue; Calculating the aspect ratio of the final outer contour edge line according to the intersection points of the final outer contour edge line with the horizontal axis and the vertical axis of the coordinate system, and taking the aspect ratio of the final outer contour edge line as the second eigenvalue; Taking the product of the first eigenvalue and the second eigenvalue as the roundness of the final outer contour edge line.

3. The computer-aided agricultural product quality inspection and grading method according to claim 2, wherein The step of calculating the aspect ratio of the final outer contour edge line according to the intersection points of the final outer contour edge line with the horizontal axis and the vertical axis of the coordinate system includes: Obtaining the first intersection point of the final outer contour edge line with the positive half-axis of the horizontal axis of the coordinate system and the second intersection point with the negative half-axis of the horizontal axis of the coordinate system; Adding the absolute value of the abscissa of the first intersection point and the absolute value of the abscissa of the second intersection point as the width of the final outer contour edge line; Obtaining the third intersection point of the final outer contour edge line with the positive half-axis of the vertical axis of the coordinate system and the fourth intersection point with the negative half-axis of the vertical axis of the coordinate system; Adding the absolute value of the ordinate of the third intersection point and the absolute value of the ordinate of the fourth intersection point as the length of the final outer contour edge line; Calculating the aspect ratio of the final outer contour edge line.

4. The computer-aided agricultural product quality detection and grading method according to claim 1, characterized in that The step of grading the agricultural product according to the roundness includes: When the roundness is greater than a preset second threshold, determining that the agricultural product to be detected is a low-quality agricultural product; When the roundness is less than or equal to the preset second threshold, determining that the agricultural product to be detected is a high-quality agricultural product.

5. The computer-aided agricultural product quality detection and grading method according to claim 1, characterized in that, The step of extracting the epidermal part in the agricultural product image to be detected as the initial agricultural product image includes: Performing color clustering on the agricultural product image to be detected to extract the epidermal part in the image as the initial agricultural product image.

6. The computer-aided agricultural product quality detection and grading method according to claim 1, characterized in that The step of filling the incomplete edge line to obtain the final outer contour edge line of the epidermis includes: The convex hull algorithm is used to fill in the incomplete edge line to obtain the final outer contour edge line of the epidermis.

7. A computer-aided agricultural product quality detection and grading system, characterized in that, It includes: An image acquisition module for acquiring the image of the agricultural product to be detected; An initial outer contour edge line acquisition module for extracting the epidermis part in the image of the agricultural product to be detected as the initial agricultural product image and acquiring the initial outer contour edge line of the initial agricultural product image; A chain code sequence acquisition module for performing chain code operations on the initial outer contour edge line starting from any pixel point on the initial outer contour edge line and obtaining the chain code sequence of the initial outer contour edge line in the clockwise direction; An abnormal chain code value selection module for calculating the difference between adjacent two chain code values in the chain code sequence and selecting both adjacent two chain code values whose absolute value of the difference is less than or equal to a preset first threshold as abnormal chain code values; A final outer contour edge line acquisition module for forming an abnormal edge from the pixel points corresponding to the abnormal chain code values, deleting the abnormal edge in the initial outer contour edge line to obtain an incomplete edge line; and for filling in the incomplete edge line to obtain the final outer contour edge line of the epidermis; A roundness calculation module for obtaining the center point of the area enclosed by the final outer contour edge line and calculating the roundness of the final outer contour edge line by using the distance between each pixel point on the final outer contour edge line and the center point; A grading module for grading the agricultural products according to the roundness.

Citation Information

Patent Citations

  • Test and classification method

    CN101322969A

  • Remote sensing image road identification method based on multistage frame significant characteristics

    CN104915636A

  • Leukocyte segmentation method based on active contour model

    CN113570628A

  • Nuclear magnetic resonance tumor region extraction method

    CN115797356A

  • System and method for using three dimensional infrared imaging for libraries of standardized medical imagery

    WO2008130903A1