Mango sorting method and system based on machine vision and medium
By pre-processing and edge detection of mango sample images, combined with shape analysis and evaluation rules, the precise grading of mango samples is achieved, solving the problem that fruit indicators cannot be comprehensively evaluated in the existing technology, and improving sorting accuracy.
Patent Information
- Application Number
- CN202510190293.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-06-13
AI Technical Summary
The existing fruit sorting methods cannot comprehensively evaluate the fruit size, color, shape and other indicators through machine vision angles, which affects the sorting accuracy.
By pre-processing, edge detection, shape analysis and evaluation rule analysis of mango sample images, the cross-sectional size, color fullness and shape regularity of the fruit are quantified to achieve accurate grading of mango samples.
It realizes accurate grading of mango samples, improves sorting accuracy, and is suitable for different varieties of mango grading testing.
Smart Images

Figure CN120147237A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of fruit sorting, and more particularly, to a mango sorting method, system and medium based on machine vision. Background Art
[0002] Machine vision technology is a rapidly developing branch of artificial intelligence, including image processing, mechanical engineering technology, control, electric light source lighting, optical imaging, sensors, analog and digital video technology, computer software and hardware technology. Using a camera device to convert the captured target into an image signal and transmitting it to an image processing system to obtain the morphological information of the captured target. According to pixel distribution, brightness, color and other information, it is converted into digital signals, and various operations are performed on these signals to extract target features, and then corresponding decisions are made according to the recognition results.
[0003] Existing fruit sorting methods cannot comprehensively evaluate fruit grading from the perspectives of fruit size, color, shape and other indicators through machine vision, thus affecting the sorting accuracy. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide a mango sorting method, system and medium based on machine vision. By optimizing and processing the mango sample image, the appearance of the fruit is quantitatively calculated from the perspectives of fruit cross-section size, fruit color and fullness, fruit shape regularity, etc., to achieve accurate grading of mango samples, so as to grade and sort mangoes, and it is applicable to the grading detection of different varieties of mangoes.
[0005] The embodiments of this application also provide a mango sorting method based on machine vision, including:
[0006] Obtain a mango sample image, preprocess the mango sample image to obtain a preprocessed image;
[0007] Perform edge detection on the preprocessed image based on an edge detection algorithm to obtain mango edge information;
[0008] Analyze the mango cross-section size, shape regular ratio and area ratio based on the mango edge information;
[0009] Analyze the mango cross-section size, shape regular ratio and area ratio based on an evaluation rule, grade the mango level to obtain a grading result;
[0010] Perform grading and sorting on the mango sample based on the grading result.
[0011] Optionally, in the mango sorting method based on machine vision described in the embodiments of this application, obtaining a mango sample image, preprocessing the mango sample image to obtain a preprocessed image specifically includes:
[0012] Obtain a mango sample image and perform grayscale processing on the mango sample image;
[0013] Based on the image enhancement technology, perform image enhancement on the grayscale processed mango sample image to obtain an enhanced image;
[0014] Based on the non-local mean filtering method, denoise the mango sample image, remove the noise features, and eliminate the environmental noise in the mango sample image;
[0015] Perform binarization processing on the mango sample image, segment the target features, and obtain a preprocessed image.
[0016] Optionally, in the mango sorting method based on machine vision described in the embodiments of the present application, performing image enhancement on the grayscale processed mango sample image based on the image enhancement technology to obtain an enhanced image specifically includes:
[0017] Obtain the brightness feature of the mango sample image, and analyze the contrast of the image pixel points based on the brightness feature;
[0018] Compare the contrast with a set contrast threshold to obtain a contrast difference;
[0019] Generate enhancement parameters based on the contrast difference;
[0020] Based on the enhancement parameters, perform brightness and grayscale enhancement on the mango sample image to obtain an enhanced image.
[0021] Optionally, in the mango sorting method based on machine vision described in the embodiments of the present application, performing edge detection on the preprocessed image based on the edge detection algorithm to obtain mango edge information specifically includes:
[0022] Construct a Gaussian filtering function, and perform smoothing processing on the preprocessed image based on the Gaussian filtering function;
[0023] Use the first-order partial derivative finite difference to calculate the gradient magnitude and direction;
[0024] Perform non-maximum suppression on the gradient magnitude to obtain a suppression result, and determine whether the suppression result meets the set condition information;
[0025] If the set condition information is met, use the double-threshold algorithm to detect and connect the edge features;
[0026] If the set condition information is not met, re-search for the maximum value of the gradient magnitude.
[0027] Optionally, in the mango sorting method based on machine vision described in the embodiments of the present application, analyzing the cross-sectional size, shape regular ratio, and area ratio of the mango based on the mango edge information specifically includes:
[0028] Obtain the edge information of the mango, obtain the mango sample area based on the mango edge information, perform a sectioning process on the mango sample area to obtain the largest cross-section;
[0029] Calculate the mango cross-section size based on the largest cross-section;
[0030] Extract multiple vertices on the periphery of the mango based on the mango edge information, and establish a rectangular frame based on the multiple vertices;
[0031] Calculate the mango cross-section area based on the mango cross-section size, and perform a ratio calculation based on the mango cross-section area and the area of the rectangular frame to obtain the area ratio;
[0032] Analyze the mango shape regularity ratio based on the mango cross-section size and the area ratio.
[0033] Optionally, in the mango sorting method based on machine vision described in the embodiments of the present application, grade the mango grades to obtain a grading result, specifically including:
[0034] Set multiple mango grade evaluation index intervals based on the evaluation rules;
[0035] Analyze the mango evaluation index values based on the mango cross-section size, shape regularity ratio, and area ratio;
[0036] Analyze the mango grade evaluation index interval where the mango evaluation index value is located to obtain analysis information;
[0037] Generate a mango grade based on the analysis information to obtain a grading result.
[0038] In a second aspect, the embodiments of the present application provide a mango sorting system based on machine vision. The system includes: a memory and a processor. The memory includes a program of the mango sorting method based on machine vision. When the program of the mango sorting method based on machine vision is executed by the processor, the following steps are implemented:
[0039] Obtain a mango sample image, preprocess the mango sample image to obtain a preprocessed image;
[0040] Perform edge detection on the preprocessed image based on an edge detection algorithm to obtain mango edge information;
[0041] Analyze the mango cross-section size, shape regularity ratio, and area ratio based on the mango edge information;
[0042] Analyze the mango cross-section size, shape regularity ratio, and area ratio based on the evaluation rules, grade the mango grades to obtain a grading result;
[0043] Perform grading and sorting on the mango samples based on the grading result.
[0044] Optionally, in the machine vision-based mango sorting system described in the embodiments of the present application, a mango sample image is obtained, and the mango sample image is preprocessed to obtain a preprocessed image, which specifically includes:
[0045] Obtain a mango sample image and perform grayscale processing on the mango sample image;
[0046] Based on the image enhancement technology, perform image enhancement on the grayscale-processed mango sample image to obtain an enhanced image;
[0047] Based on the non-local mean filtering method, perform denoising on the mango sample image, remove the noise features, and eliminate the environmental noise in the mango sample image.
[0048] Perform binarization processing on the mango sample image, segment the target features, and obtain a preprocessed image.
[0049] Optionally, in the machine vision-based mango sorting system described in the embodiments of the present application, based on the image enhancement technology, perform image enhancement on the grayscale-processed mango sample image to obtain an enhanced image, which specifically includes:
[0050] Obtain the brightness feature of the mango sample image and analyze the contrast of the image pixels based on the brightness feature;
[0051] Compare the contrast with a set contrast threshold to obtain a contrast difference;
[0052] Generate enhancement parameters based on the contrast difference;
[0053] Based on the enhancement parameters, perform brightness and grayscale enhancement on the mango sample image to obtain an enhanced image.
[0054] In a third aspect, the embodiments of the present application further provide a computer-readable storage medium, which includes a program for the machine vision-based mango sorting method. When the program for the machine vision-based mango sorting method is executed by a processor, the steps of the machine vision-based mango sorting method described in any one of the above are implemented.
[0055] As can be seen from the above, a mango sorting method, system and medium based on machine vision provided by the embodiments of the present application obtain a mango sample image, preprocess the mango sample image to obtain a preprocessed image; perform edge detection on the preprocessed image based on an edge detection algorithm to obtain mango edge information; analyze the cross-sectional size, shape regularity ratio and area ratio of the mango based on the mango edge information; analyze the cross-sectional size, shape regularity ratio and area ratio of the mango based on an evaluation rule, classify the mango grades to obtain a classification result; perform classification and sorting on the mango samples based on the classification result; through the optimized processing of the mango sample image, quantitatively calculate the appearance of the fruit from the perspectives of the fruit cross-sectional size, fruit color and fullness, fruit shape regularity, etc., realize the precise classification of the mango samples, and thus perform classification and sorting on the mangoes, which is applicable to the classification detection of different varieties of mangoes. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other relevant drawings can also be obtained based on these drawings.
[0057] Figure 1 It is a flowchart of the mango sorting method based on machine vision provided by the embodiments of the present application;
[0058] Figure 2 It is a flowchart of the preprocessing of the mango sample image of the mango sorting method based on machine vision provided by the embodiments of the present application;
[0059] Figure 3 It is a flowchart of the method for obtaining an enhanced image of the mango sorting method based on machine vision provided by the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0060] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all of them. The components of the embodiments of the present application described and illustrated herein can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application provided in the following drawings is not intended to limit the scope of the claimed present application, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0061] It should be noted that similar reference numerals and letters indicate similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present application, terms such as "first" and "second" are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0062] Please refer to Figure 1 , Figure 1 which is a flowchart of a machine vision-based mango sorting method in some embodiments of the present application. This machine vision-based mango sorting method is used in a terminal device. The machine vision-based mango sorting method includes the following steps:
[0063] S101, Obtain a mango sample image, preprocess the mango sample image to obtain a preprocessed image;
[0064] S102, Perform edge detection on the preprocessed image based on an edge detection algorithm to obtain mango edge information;
[0065] S103, Analyze the cross-sectional size, shape regularity ratio, and area ratio of the mango based on the mango edge information;
[0066] S104, Analyze the cross-sectional size, shape regularity ratio, and area ratio of the mango based on an evaluation rule, classify the mango grades to obtain a classification result;
[0067] S105, Classify and sort the mango samples based on the classification result.
[0068] It should be noted that the purpose of edge detection is to detect the edge information of an object in an image, that is, the contour of the object. The basic principle of edge detection is to find the positions where the pixel values change significantly in the image, and the object edge is generally also where the pixel values change violently. Thus, the contour of the mango can be detected. Commonly used edge detection algorithms include the Sobel operator, Canny operator, or Laplace operator. By using the mango size, weight, color, and shape detection method based on machine vision technology, the accuracy of mango sorting can be effectively improved.
[0069] Please refer to Figure 2 , Figure 2 which is a flowchart of the preprocessing of a mango sample image of a machine vision-based mango sorting method in some embodiments of the present application. According to the embodiments of the present invention, a mango sample image is obtained, and the mango sample image is preprocessed to obtain a preprocessed image, which specifically includes:
[0070] S201, Obtain a mango sample image and perform grayscale processing on the mango sample image;
[0071] S202, perform image enhancement on the grayscale-processed mango sample image based on the image augmentation technology to obtain an enhanced image;
[0072] S203, denoise the mango sample image based on the non-local means filtering method, eliminate the noise features, and remove the environmental noise in the mango sample image;
[0073] S204, perform binarization processing on the mango sample image, segment the target features, and obtain a preprocessed image.
[0074] It should be noted that the common image preprocessing methods include: grayscale conversion, binarization, image enhancement, image denoising, image augmentation, and edge detection, etc. According to the measurement requirements of the mango's body shape, first perform grayscale conversion on the original color image; then use image enhancement to highlight the target features; then denoise the image to remove the environmental noise in the image; then perform binarization on the image to segment the target features; finally, use the edge detection operator to extract the contour feature curve of the mango.
[0075] Please refer to Figure 3 , Figure 3 is a flowchart of an enhanced image acquisition method for a mango sorting method based on machine vision in some embodiments of the present application. According to the embodiments of the present invention, perform image enhancement on the grayscale-processed mango sample image based on the image augmentation technology to obtain an enhanced image, which specifically includes:
[0076] S301, obtain the brightness feature of the mango sample image, and analyze the contrast of the image pixel points based on the brightness feature;
[0077] S302, compare the contrast with the set contrast threshold to obtain a contrast difference;
[0078] S303, generate enhancement parameters based on the contrast difference;
[0079] S304, perform brightness and grayscale enhancement on the mango sample image based on the enhancement parameters to obtain an enhanced image.
[0080] It should be noted that contrast enhancement is to enhance the differences between different objects and regions in the image, making the dark parts in the image darker and the bright parts brighter, so as to achieve the purpose of highlighting the visual effect and recognizability. In order to obtain a clear contour of the mango's body shape and prevent shadows from being generated during the image shooting process from affecting the later image processing effect, rectangular fill lights are arranged around the shooting platform, and a fill light is configured directly above the mango to form a shadowless shooting environment, and the camera is set up in a vertical downward shooting posture to collect the images of the mango samples.
[0081] According to the embodiments of the present invention, perform edge detection on the preprocessed image based on the edge detection algorithm to obtain the mango edge information, which specifically includes:
[0082] Construct a Gaussian filtering function and smooth the preprocessed image based on the Gaussian filtering function;
[0083] Use the finite difference of the first-order partial derivative to calculate the gradient magnitude and direction;
[0084] Perform non-maximum suppression on the gradient magnitude to obtain a suppression result, and determine whether the suppression result meets the set condition information;
[0085] If the set condition information is met, use the double-threshold algorithm to detect and connect edge features;
[0086] If the set condition information is not met, re-search for the maximum value of the gradient magnitude.
[0087] According to the embodiments of the present invention, based on the mango edge information, analyze the cross-sectional size, shape regularity ratio, and area ratio of the mango cross-section, specifically including:
[0088] Obtain the mango edge information, obtain the mango sample area based on the mango edge information, perform a sectioning process on the mango sample area to obtain the largest cross-section;
[0089] Calculate the mango cross-sectional size based on the largest cross-section;
[0090] Extract multiple vertices on the periphery of the mango based on the mango edge information, and establish a rectangular frame based on the multiple vertices;
[0091] Calculate the mango cross-sectional area based on the mango cross-sectional size, calculate the ratio according to the mango cross-sectional area and the area of the rectangular frame to obtain the area ratio;
[0092] Analyze the mango shape regularity ratio based on the mango cross-sectional size and the area ratio.
[0093] It should be noted that the grading standards for different fruits should comprehensively consider factors such as the volume, color, shape, and weight of the fruits. According to the planting experience of fruit farmers and the business experience of fruit vendors, the excellent grades of different fruits are also related to their shapes. For example, the larger and deeper the navel of an apple, the sweeter the apple, and oranges have similar characteristics. Generally speaking, the shape of a special-grade mango is mostly "olive-shaped", and its outer curve tends to the golden ratio. According to a large number of test results, the shape regularity of mangoes can be measured by two indicators: the aspect ratio and the area ratio. That is, the closer the ratio of the longitudinal length to the transverse width of the mango is to the golden ratio (0.618), the higher the grade of the mango; the higher the ratio of the area enclosed by the mango contour to the area of its bounding box, the better the grade of the mango.
[0094] Furthermore, for mangoes, the first grading basis for the same variety is volume. Generally, the larger the volume, the higher the grade and the higher the selling price. Since mangoes have an ellipsoidal structure and a relatively regular overall shape, the maximum cross-section of the fruit can be used as the calculation standard instead of volume, which is the outer contour of the mango in the overhead image.
[0095] According to an embodiment of the present invention, mangoes are graded to obtain a grading result, which specifically includes:
[0096] Set multiple mango grade evaluation index intervals based on evaluation rules;
[0097] The mango evaluation index values were analyzed based on the mango cross-sectional dimensions, shape regularity ratio and area proportion;
[0098] Analyze the mango grade evaluation index interval where the mango evaluation index value is located to obtain analysis information;
[0099] The mango grade is generated based on the analysis information and the grading result is obtained.
[0100] It should be noted that 100 mangoes of the same variety purchased from different markets were uniformly collected under the same lighting environment and double-sided images were taken, with a total of 200 images collected. Mangoes are divided into four grades, namely A+, A-, B, and C, and their grading evaluation index values are D They are: 0.95-1.00, 0.90-0.95, 0.80-0.90, 0.00-0.80 respectively. Automatic grading calculation is performed according to the proposed visual recognition method. The algorithm has high robustness and reliable recognition results.
[0101] According to an embodiment of the present invention, the fruit color fullness calculation based on the color channel is also included, which is as follows:
[0102] When selecting fruits, in addition to individual size, people will also pay attention to the color of the peel. Generally, golden mangoes are sweeter than green mangoes. Peel color is an important indicator of fruit maturity. A color image is composed of three color channels: R, G, and B. Therefore, the image of ripe mangoes with excellent color can be used as a standard, and the maturity of mangoes can be measured by comparing the three-channel color values of the two images.
[0103] In a second aspect, an embodiment of the present application provides a mango sorting system based on machine vision, the system comprising: a memory and a processor, the memory comprising a program of a mango sorting method based on machine vision, and when the program of the mango sorting method based on machine vision is executed by the processor, the following steps are implemented:
[0104] Obtain a mango sample image, and preprocess the mango sample image to obtain a preprocessed image;
[0105] Perform edge detection on the preprocessed image based on an edge detection algorithm to obtain the edge information of the mango;
[0106] Analyze the cross-sectional size, shape regular ratio, and area occupancy ratio of the mango based on the mango edge information;
[0107] Analyze the cross-sectional size, shape regular ratio, and area occupancy ratio of the mango based on the evaluation rules, classify the mango grades, and obtain the classification results;
[0108] Classify and sort the mango samples based on the classification results.
[0109] It should be noted that the purpose of edge detection is to detect the edge information of an object in an image, that is, the contour of the object. The basic principle of edge detection is to find the positions where the pixel values change significantly in the image, and the object edges are generally also places where the pixel values change violently. Thus, the contour of the mango can be detected. Common edge detection algorithms include the Sobel operator, Canny operator, or Laplace operator. Using the mango size, weight, color, and shape detection method based on machine vision technology can effectively improve the accuracy of mango sorting.
[0110] According to an embodiment of the present invention, obtain a mango sample image, preprocess the mango sample image to obtain a preprocessed image, specifically including:
[0111] Obtain a mango sample image and perform grayscale processing on the mango sample image;
[0112] Perform image enhancement on the grayscale processed mango sample image based on image augmentation technology to obtain an enhanced image;
[0113] Perform denoising on the mango sample image using the non-local means filtering method, eliminate the noise features, and remove the environmental noise in the mango sample image;
[0114] Perform binarization processing on the mango sample image, segment the target features, and obtain a preprocessed image.
[0115] It should be noted that common image preprocessing methods include: grayscale processing, binarization, image enhancement, image denoising, image augmentation, and edge detection, etc. According to the body measurement requirements of the mango, first perform grayscale processing on the original color image; then use image enhancement to highlight the target features; then perform denoising on the image to remove the environmental noise in the image; then perform binarization on the image to segment the target features; finally, use the edge detection operator to extract the mango contour feature curve.
[0116] According to an embodiment of the present invention, perform image enhancement on the grayscale processed mango sample image based on image augmentation technology to obtain an enhanced image, specifically including:
[0117] Obtain the brightness features of the mango sample image, and analyze the contrast of the image pixels based on the brightness features;
[0118] Compare the contrast with the set contrast threshold to obtain the contrast difference;
[0119] Generate enhancement parameters based on the contrast difference;
[0120] Perform brightness and grayscale enhancement on the mango sample image based on the enhancement parameters to obtain an enhanced image.
[0121] It should be noted that contrast enhancement is to enhance the differences between different objects and regions in the image, making the dark parts in the image darker and the bright parts brighter, so as to achieve the purpose of highlighting the visual effect and recognizability. In order to obtain a clear contour of the mango shape and prevent shadows from being generated during the image shooting process from affecting the later image processing effect, rectangular fill lights are arranged around the shooting platform, and a fill light is configured directly above the mango to form a shadowless shooting environment, and the camera is set up in a vertical downward shooting posture to collect the images of the mango samples.
[0122] According to the embodiments of the present invention, perform edge detection on the preprocessed image based on the edge detection algorithm to obtain the mango edge information, specifically including:
[0123] Construct a Gaussian filter function, and perform smoothing processing on the preprocessed image based on the Gaussian filter function;
[0124] Use the finite difference of the first-order partial derivative to calculate the gradient magnitude and direction;
[0125] Perform non-maximum suppression on the gradient magnitude to obtain the suppression result, and determine whether the suppression result meets the set condition information;
[0126] If the set condition information is met, use the double-threshold algorithm to detect and connect the edge features;
[0127] If the set condition information is not met, re-search for the maximum value of the gradient magnitude.
[0128] According to the embodiments of the present invention, analyze the cross-sectional size, shape regular ratio, and area ratio of the mango based on the mango edge information, specifically including:
[0129] Obtain the mango edge information, obtain the mango sample area based on the mango edge information, perform sectioning processing on the mango sample area to obtain the largest cross-section;
[0130] Calculate the mango cross-sectional size based on the largest cross-section;
[0131] Extract multiple vertices on the periphery of the mango based on the mango edge information, and establish a rectangular frame based on the multiple vertices;
[0132] Calculate the cross-sectional area of a mango based on its cross-sectional dimensions, and calculate the ratio of the cross-sectional area of the mango to the area of the rectangular frame to obtain the area ratio.
[0133] Analyze the regular shape ratio of the mango based on the cross-sectional dimensions and area ratio of the mango.
[0134] It should be noted that the grading standards for different fruits should comprehensively consider factors such as the volume, color, shape, and weight of the fruits. According to the planting experience of fruit farmers and the business experience of fruit vendors, the excellent grades of different fruits are also related to their shapes. For example, the larger and deeper the navel of an apple, the sweeter the apple, and oranges have similar characteristics. Generally speaking, the shape of a special-grade mango is mostly "olive-shaped", and its outer contour curve tends to the golden ratio. According to a large number of test results, the regularity of the shape of a mango can be measured by two indicators: the aspect ratio and the area ratio. That is, the closer the ratio of the longitudinal length to the transverse width of the mango is to the golden ratio (0.618), the higher the grade of the mango; the higher the ratio of the area enclosed by the mango contour to the area of its bounding box, the better the grade of the mango.
[0135] Furthermore, for mangoes, the first basis for grading the same variety is volume. Generally, the larger the volume, the higher the grade and the higher the selling price. Since mangoes belong to an ellipsoidal structure and the overall shape is relatively regular, the maximum cross-section of the fruit body can be used to replace the volume as its calculation standard, which is the outer contour of the mango in the top-down image.
[0136] According to the embodiments of the present invention, grade the mangoes to obtain the grading results, specifically including:
[0137] Set multiple mango grade evaluation index intervals based on the evaluation rules;
[0138] Analyze the mango evaluation index values based on the cross-sectional dimensions, regular shape ratio, and area ratio of the mango;
[0139] Analyze the mango grade evaluation index interval where the mango evaluation index value is located to obtain the analysis information;
[0140] Generate the mango grade based on the analysis information to obtain the grading result.
[0141] It should be noted that 100 mangoes of the same variety purchased from different markets are collected for images under the same lighting environment, and double-sided image shooting is carried out, and a total of 200 test images are collected. The mangoes are divided into four grades, namely A+, A-, B, and C, and their grading evaluation index values D are respectively: 0.95 - 1.00, 0.90 - 0.95, 0.80 - 0.90, 0.00 - 0.80. According to the proposed visual recognition method for automatic grading calculation, the algorithm has high robustness and reliable recognition results.
[0142] According to an embodiment of the present invention, it further includes calculating the fruit color and luster fullness based on color channels, specifically as follows:
[0143] When selecting fruits, in addition to the individual size, people will pay attention to the color of the fruit skin. Generally, the sweetness of golden mangoes is better than that of those with a slightly green color. The fruit skin color is an important indicator to express the fruit maturity. A color image is composed of three color channels of R, G, and B. Therefore, the image of a mature mango with excellent color can be used as a standard, and the maturity of mangoes can be measured by comparing the three-channel color values of the two images.
[0144] The third aspect of the present invention provides a computer-readable storage medium, which includes a program for the mango sorting method based on machine vision. When the program for the mango sorting method based on machine vision is executed by a processor, the steps of the mango sorting method based on machine vision as described in any one of the above are implemented.
[0145] A mango sorting method, system and medium based on machine vision disclosed by the present invention obtain a mango sample image, preprocess the mango sample image to obtain a preprocessed image; perform edge detection on the preprocessed image based on an edge detection algorithm to obtain mango edge information; analyze the cross-sectional size, shape regularity ratio and area occupancy ratio of the mango based on the mango edge information; analyze the cross-sectional size, shape regularity ratio and area occupancy ratio of the mango based on an evaluation rule, classify the mango grades to obtain a classification result; perform classification and sorting on the mango samples based on the classification result; through optimizing the processing of the mango sample image, quantitatively calculate the fruit appearance from angles such as the fruit cross-sectional size, fruit color and luster fullness, and fruit shape regularity, etc., to achieve precise grading of the mango samples, so as to classify and sort the mangoes, and it is applicable to the grading detection of different varieties of mangoes.
[0146] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling or communication connection between the various components shown or discussed with each other can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0147] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units; they can be located in one place or distributed to multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0148] In addition, each functional unit in the embodiments of the present invention may all be integrated into one processing unit, or each unit may be separately taken as one unit alone, or two or more units may be integrated into one unit; the above-mentioned integrated unit may be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.
[0149] Those of ordinary skill in the art can understand that all or part of the steps for implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a readable storage medium. When the program is executed, it performs the steps including the above method embodiments; and the foregoing storage medium includes: removable storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other various media that can store program codes.
[0150] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present invention, in essence or the part that contributes to the prior art, may be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the various embodiments of the present invention. And the foregoing storage medium includes: removable storage devices, ROM, RAM, magnetic disks, optical disks, and other various media that can store program codes.
Claims
1. A mango sorting method based on machine vision, characterized in that: include: Acquire a mango sample image, and preprocess the mango sample image to obtain a preprocessed image; Perform edge detection on the preprocessed image based on the edge detection algorithm to obtain the edge information of the mango; Analyze the cross-sectional size, shape regularity ratio and area proportion of mangoes based on the edge information of mangoes; Based on the evaluation rules, the cross-sectional dimensions, shape regularity ratio and area proportion of mangoes are analyzed, and the mangoes are graded to obtain the grading results; The mango samples were graded and sorted based on the grading results.
2. The mango sorting method based on machine vision according to claim 1, characterized in that: Obtain a mango sample image, and preprocess the mango sample image to obtain a preprocessed image, specifically including: Obtain a mango sample image, and perform grayscale processing on the mango sample image; Based on the image enhancement technology, the mango sample image after grayscale processing is enhanced to obtain an enhanced image; Based on the non-local mean filtering method, the mango sample image is denoised, the noise features are removed, and the environmental noise in the mango sample image is eliminated; The mango sample image is binarized and the target features are segmented to obtain the preprocessed image.
3. The mango sorting method based on machine vision according to claim 2, characterized in that: Based on the image enhancement technology, the mango sample image after grayscale processing is enhanced to obtain an enhanced image, which specifically includes: Obtain the brightness features of the mango sample image, and analyze the contrast of the image pixels based on the brightness features; Compare the contrast with the set contrast threshold to obtain the contrast difference; generating enhancement parameters based on the contrast difference; The brightness and grayscale of the mango sample image are enhanced based on the enhancement parameters to obtain an enhanced image.
4. The mango sorting method based on machine vision according to claim 3, characterized in that: Based on the edge detection algorithm, edge detection is performed on the preprocessed image to obtain the edge information of the mango, including: Construct a Gaussian filter function, and perform smoothing on the preprocessed image based on the Gaussian filter function; The gradient amplitude and direction are calculated by using the first-order partial derivative finite difference method; Perform non-maximum suppression on the gradient amplitude to obtain the suppression result, and determine whether the suppression result meets the set condition information; If the set condition information is met, the dual threshold algorithm is used to detect and connect edge features; If the set condition information is not met, the maximum value of the gradient amplitude is searched again.
5. The mango sorting method based on machine vision according to claim 4, characterized in that: Based on the edge information of mangoes, the cross-sectional size, shape regularity ratio and area proportion of mangoes are analyzed, including: Obtaining mango edge information, obtaining a mango sample area based on the mango edge information, and performing section processing on the mango sample area to obtain a maximum cross section; Calculate the mango cross-sectional dimensions based on the largest cross section; Extract multiple vertices around the mango based on the edge information of the mango, and build a rectangular frame based on the multiple vertices; The cross-sectional area of the mango is calculated based on the cross-sectional dimensions of the mango, and the area ratio is calculated based on the ratio of the cross-sectional area of the mango to the area of the rectangular frame; Analyze the regular proportion of mango shape by comparing the cross-sectional dimensions and area ratio of mango.
6. The mango sorting method based on machine vision according to claim 5, characterized in that: Mangoes are graded and the grading results are obtained, including: Set multiple mango grade evaluation index intervals based on evaluation rules; The mango evaluation index values were analyzed based on the mango cross-sectional dimensions, shape regularity ratio and area proportion; Analyze the mango grade evaluation index interval where the mango evaluation index value is located to obtain analysis information; The mango grade is generated based on the analysis information and the grading result is obtained.
7. A mango sorting system based on machine vision, characterized in that: The system includes: a memory and a processor, wherein the memory includes a program of a mango sorting method based on machine vision, and when the program of the mango sorting method based on machine vision is executed by the processor, the following steps are implemented: Acquire a mango sample image, and preprocess the mango sample image to obtain a preprocessed image; Perform edge detection on the preprocessed image based on the edge detection algorithm to obtain the edge information of the mango; Analyze the cross-sectional size, shape regularity ratio and area proportion of mangoes based on the edge information of mangoes; Based on the evaluation rules, the cross-sectional dimensions, shape regularity ratio and area proportion of mangoes are analyzed, and the mangoes are graded to obtain the grading results; The mango samples were graded and sorted based on the grading results.
8. The mango sorting system based on machine vision according to claim 7, characterized in that: Obtain a mango sample image, and preprocess the mango sample image to obtain a preprocessed image, specifically including: Obtain a mango sample image, and perform grayscale processing on the mango sample image; Based on the image enhancement technology, the mango sample image after grayscale processing is enhanced to obtain an enhanced image; Based on the non-local mean filtering method, the mango sample image is denoised, the noise features are removed, and the environmental noise in the mango sample image is eliminated; The mango sample image is binarized and the target features are segmented to obtain the preprocessed image.
9. The mango sorting system based on machine vision according to claim 8, characterized in that: Based on the image enhancement technology, the mango sample image after grayscale processing is enhanced to obtain an enhanced image, which specifically includes: Obtain the brightness features of the mango sample image, and analyze the contrast of the image pixels based on the brightness features; Compare the contrast with the set contrast threshold to obtain the contrast difference; generating enhancement parameters based on the contrast difference; The brightness and grayscale of the mango sample image are enhanced based on the enhancement parameters to obtain an enhanced image.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a mango sorting method program based on machine vision. When the mango sorting method program based on machine vision is executed by a processor, the steps of the mango sorting method based on machine vision as claimed in any one of claims 1 to 6 are implemented.