CN-122016816-A - Method for automatically analyzing deterioration degree of vegetables and fruits
Abstract
The invention belongs to the field of artificial intelligence category and new generation information technology through machine vision and artificial intelligence technology. The invention automatically analyzes the quality change condition of vegetables and fruits (hereinafter referred to as vegetables and fruits), automatically judges whether the vegetables and fruits are spoiled, and gives the spoiled grade. The method can be used for quality detection and analysis of the occasions such as commodity feeding detection, storage, processing and the like of agricultural products such as vegetables and fruits. The invention can be applied to the related industries of agricultural product production, processing, storage, logistics and the like. The vegetables and fruits can be deteriorated after a certain period of time due to natural properties of the vegetables and fruits, such as storage mode, logistics process, storage environment, diseases and insect pests, and the like, and are reflected in the appearance of the vegetables and fruits as phenomena of color change, water loss, shrinkage, liquefaction, mildew, decay and the like. According to the method, the quantitative deterioration degree of the vegetables and the fruits is calculated according to the automatic analysis of the appearance of the vegetables and the fruits so as to take corresponding treatment measures in time, and the method can also be used for routine quality inspection and analysis of the vegetables and the fruits. According to the invention, by analyzing the appearance characteristics of the vegetables and fruits, whether the vegetables and fruits are deteriorated or not and the deterioration degree are judged under the condition of no damage to the vegetables and fruits. The invention can analyze the deterioration condition of vegetables and fruits according to the images of the vegetables and fruits, and can play an important role in the construction of intelligent agriculture and food safety systems in the regular quality inspection of agricultural products.
Inventors
- QIN QINGYI
- LI JINDI
- ZHOU BEN
- CAI HUI
Assignees
- 广东绿鑫源农产品有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260311
Claims (6)
- 1. A method for automatically analyzing deterioration degree of vegetables and fruits, which comprises the following characteristics: (11) Shooting by a detection camera to obtain a vegetable and fruit image P to be detected; (12) Calculating an external rectangle Rec with the smallest vegetable and fruit area in P, and extracting an image in the rectangular area to obtain PRec; (13) Converting PRec into a gray level map Pgray, performing Sobel operator filtering on Pgray, but not limited to Sobel operator filtering to obtain a filtered image Pfil, extracting a vegetable and fruit outer contour line Con in Pfil, removing background noise to obtain PCon, repairing the fracture of the outer contour line Con on the PCon by an expansion and corrosion method to obtain an enhanced outer contour line image PEnh of the vegetable and fruit region; (14) Calculating the position of a minimum intersection point of a diagonal line of the circumscribed rectangle PEnh, taking the point as an origin O, respectively taking a straight line which passes through O and is parallel to a long side and a short side of the circumscribed rectangle as a longitudinal axis, establishing an XOY rectangular coordinate system, and respectively calculating the weighted asymmetry of PEnh under the two established XOY coordinate systems; (15) And calculating and outputting the deterioration grade of the vegetables and fruits according to the value of the weighted asymmetry.
- 2. The method according to claim 1, wherein the method of step (11) is as follows: The shot area is a front image of the vegetables and fruits, and the shot images are images when the vegetable and fruit areas are completely exposed, namely, when the shot areas are not shielded.
- 3. The authentication method according to claim 1, wherein the step (12) method is as follows: When the circumscribed rectangle Rec with the smallest vegetable and fruit area is calculated, the area of the circumscribed rectangle takes the pixel points in the rectangle as a measurement unit and the product of the width and the height of the rectangle as the area of the circumscribed rectangle.
- 4. The authentication method according to claim 1, wherein the step (13) method is as follows: The outer contour boundary of vegetable and fruit is extracted by gradient operation of the transformed gray map Pgray, and the boundary is noise filtered and contour line repaired by digital image processing method to obtain continuous and closed outer contour boundary map PEnh of vegetable and fruit.
- 5. The authentication method according to claim 1, wherein the method of step (14) is as follows: The intersection point of the diagonal lines of the minimum circumscribed rectangle of PEnh is used as an origin O to establish a plane rectangular coordinate system, PEnh is decomposed into four quadrants in the plane rectangular coordinate system, the lengths of the long side and the short side of the circumscribed rectangle are calculated, and a straight line parallel to the long side is used as a Y axis. If 4 sides of the circumscribed rectangle are equal in length, any one side is taken as a long side, any adjacent side is taken as a short side, and a straight line parallel to any side is taken as a Y axis. Alternately scanning the Y-axis positive direction and the Y-axis negative direction from the O point horizontally by taking pixels as step units and parallel to the X-axis to obtain a scanning line PY, wherein the intersection points of the PY on the left side and the right side of the Y-axis and the outer contour PEnh are respectively marked as PYL and PYR. In pixel units, calculating pixel-unit distances D PYL-Y and D PYR-Y from PYL and PYR to Y-axis, respectively, scanning from O point to PEnh along Y-axis positive direction, stopping scanning to Y-axis positive direction, scanning from O point to PEnh along Y-axis negative direction, stopping scanning to Y-axis negative direction, calculating asymmetric pixel point numbers of pixel points on scanning line PY on two sides of Y-axis according to formula (1), and recording as ; (1) Wherein the method comprises the steps of The lower boundary and the upper boundary of PEnh during scanning are respectively indicated, and the rows corresponding to the scanning lines when the ordinate represents the minimum value and the maximum value are respectively located. The value of j is an integer, and is a line number, the line number is a positive integer when the scanning line PY is above the X axis, a negative integer when the scanning line PY is below the X axis, and 0 when the scanning line PY is coincident with the X axis. According to formula (2) corresponding to Asymmetry of single scan of (a) , (2) Calculating the areas of the closed areas surrounded by the vegetable and fruit contour lines and the coordinate axes in the first quadrant to the fourth quadrant, respectively marking the areas as PS 1 ,PS 2 ,PS 3 ,PS 4 , and taking pixel points as calculation units; calculating the ratio of the areas in the total area according to the formula (3) as the weight of the asymmetry 1 , 2 , 3 , 4 ; (3) Calculated according to formulas (4) - (7) Is a weighted sum of the sums of the weighted sums of (2) (4) (5) (6) (7) X is the value of the abscissa in the corresponding quadrant. Calculating weighted asymmetry according to equation (8) (8) The O-point is taken as the Y-axis with a straight line parallel to the short side of the bounding rectangle, and the weighted asymmetry is calculated according to the method described above for point 5. The smaller of the weighted asymmetries is used as the final weighted asymmetry at the end of the step, and if the two weighted asymmetries are equal, any weighted asymmetry calculated in the step is selected as the final weighted asymmetry at the end of the step.
- 6. The authentication method according to claim 1, wherein the method of step (15) is as follows: according to the requirements for quality control of vegetables and fruits, a monotonically increasing threshold sequence is set according to a formula (9), and 10 grades are provided in total, but the method is not limited to 10 grades. (9) Is a threshold for judging the deterioration degree of vegetables and fruits, namely a tolerable limit, and i is an integer with a value of 1 to 10. =0.025, But is not limited to 0.025. Selecting a threshold level i according to quality control requirements when When the quality of the vegetable and fruit is judged to be deteriorated, the deterioration level is i, and the larger i is, the higher the deterioration degree of the vegetable and fruit is.
Description
Method for automatically analyzing deterioration degree of vegetables and fruits Technical Field The invention uses machine vision and artificial intelligence technology to quantitatively analyze the deterioration degree of vegetables and fruits, and belongs to the technical field of artificial intelligence category and new generation information. Background The vegetables and fruits are gradually deteriorated with the lapse of time after picking. In general, the contour of the vegetable and fruit is approximately axisymmetric. When fruits and vegetables deteriorate, water loss or mildew generally occurs to different degrees, which increases the shrinkage of the leaves, changes the flatness and uniformity of the surfaces of the fruits and vegetables, and even the liquefaction and spoilage of the leaves occur. Deterioration of the vegetables and fruits can lead to leaf wilting and reduced stiffness, resulting in reduced continuity and symmetry of the edges of the vegetables and fruits. These factors can lead to reduced symmetry of the vegetable and fruit profile. The symmetry of the outer contour of the vegetables and fruits is automatically detected through the machine vision and artificial intelligence technology, and the deterioration degree of the vegetables and fruits is timely analyzed and judged. Deterioration of vegetables and fruits directly affects quality and nutrition of the vegetables and fruits, affects market price, and serious deterioration also causes food safety problems. The quantitative analysis method can quantitatively analyze the deterioration degree of the vegetables and the fruits so as to take targeted treatment measures or early warning of deterioration of the vegetables and the fruits, slow down the deterioration process of the vegetables and the fruits, and reduce the value loss of the vegetables and the fruits caused by deterioration, thereby being beneficial to improving the quality of agricultural products and meeting the increasing material living needs of consumers. Disclosure of Invention The invention provides a method for judging whether vegetables and fruits are spoiled or not based on the outline characteristics of the vegetables and fruits. The method is equally effective for identifying feature variations of other objects having a relatively stable outer profile. The aim of the invention is achieved by the following technical method: Symmetry generally occurs in side images of fresh vegetables and fruits, such as apples, watermelons, tomatoes, radishes, cabbages, carrots, garlic and the like. Over time, the vegetables and fruits can gradually deteriorate, deterioration can be accelerated when the storage environment is improper, shrinkage, dent, mildew, discoloration, liquefaction, decay and the like of different degrees appear according to the difference of deterioration degrees, and the profile is asymmetric of different degrees. The invention determines whether the vegetables and fruits are spoiled according to the following steps, and outputs the spoiling grade: 1. Taking picture P from side of vegetable and fruit, wherein the side is defined as vegetable root facing downward and fruit pedicel facing downward, and for slender fruits and vegetables such as carrot, watermelon and pumpkin, taking its flat position 2. Extracting a vegetable and fruit region in P as a region to be analyzed, namely a region ROI (Region of Interest) of interest; 3. graying the P to obtain a gray image, and marking GY; 4. calculating the gradient of GY by using a Sobel operator but not limited to the Sobel operator to obtain a gradient map GR; 5. Repairing breaking points of the outer contour line of the GR by an expansion and corrosion method to obtain a closed outer contour map Contr; 6. Taking the intersection point of the diagonal lines of the minimum circumscribed rectangle of Contr as the origin O of a rectangular coordinate system; 7. and calculating the lengths of the long side and the short side of the circumscribed rectangle, and taking a straight line parallel to the long side through the O point as a Y axis. If 4 sides of the circumscribed rectangle are equal in length, a straight line parallel to any side is taken as a Y axis; 8. a straight line passing through the origin O and perpendicular to the Y is defined as an X axis, and an XOY rectangular coordinate system is established; 9. Alternately scanning horizontally along the positive direction and the negative direction of the Y axis from the O point by taking pixels as step units to obtain scanning lines PY, wherein the intersection points of the PY on the left and right sides of the Y axis and the outer contour Contr are respectively denoted as PYL and PYR. Calculating distances D PYL-Y and D PYR-Y in pixels from PYL and PYR to the Y axis respectively in pixels; 10. after the lower boundary of Contr is scanned, the scanning in the reverse direction of the Y axis is stopped; 11. calculating the number of asymmetric pixel p