Fresh corn grading method based on visual inspection
Through visual detection technology, combined with image acquisition, edge detection and HSV color space model, multi-dimensional comprehensive evaluation and automatic grading of fresh corn are achieved, solving the problems of insufficient accuracy and poor real-time performance in the existing technology, and improving the accuracy and consistency of grading.
Patent Information
- Application Number
- CN202411947530.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-01
AI Technical Summary
The prior art has problems of insufficient accuracy and poor real-time performance in the comprehensive grading of ear length, ear shape, color and filament color of fresh corn.
Using a visual detection method, through image acquisition, edge detection, HSV color space model analysis and other steps, the ear length, ear shape, color and filament color of fresh corn are comprehensively evaluated to achieve automated grading.
It improves the accuracy and consistency of fresh corn grading, reduces manual intervention, and achieves efficient and accurate automatic grading.
Smart Images

Figure CN119738405A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of visual detection, and in particular to a fresh corn grading method based on visual detection. Background Art
[0002] As one of the most important food crops in the world, the quality of fresh corn directly affects market competitiveness and consumer satisfaction. Traditional fresh corn grading mainly relies on manual visual evaluation, and is classified according to appearance characteristics such as ear length, ear shape, color and filament color. However, manual grading has shortcomings such as low efficiency, strong subjectivity and poor repeatability.
[0003] In recent years, the application of machine vision in agricultural product grading has gradually increased, but the existing technology still has the problems of insufficient accuracy and poor real-time performance in the comprehensive grading of ear length, ear shape, color and filament color. Therefore, in order to solve the above problems, it is necessary to design an efficient, accurate and stable automatic grading method for fresh corn. Summary of the invention
[0004] The present invention provides a fresh corn grading method based on visual detection, which can overcome the problems of insufficient accuracy and poor real-time performance in the prior art in the comprehensive grading of ear length, ear shape, color and filament color.
[0005] A fresh corn grading method based on visual detection according to the present invention comprises the following steps:
[0006] Step 1, obtaining an appearance image of fresh corn for image acquisition;
[0007] Step 2: Obtain the outline of the corn by edge detection, and draw the minimum circumscribed rectangle according to the outline to obtain the ear length;
[0008] Step 3: judging whether the ear shape is full and consistent by the outline area of the corn and the area of the minimum circumscribed rectangle;
[0009] Step 4, analyzing the appearance color of fresh corn using the HSV color space model;
[0010] Step 5: Determine the color of the filaments using the HSV color space model;
[0011] Step 6: Comprehensively score and grade the results through steps 2, 3, 4 and 5.
[0012] Preferably, in step 1, the image is acquired by taking pictures with an industrial camera.
[0013] Preferably, in step 2, the Canny edge detection algorithm is used to obtain the outline of the fresh corn, and the length of the minimum circumscribed rectangle is used as the length of the corn ear; the scoring standard is defined by the obtained ear length to prepare for subsequent grading.
[0014] Preferably, in step 3, the contour of fresh corn obtained by the Canny edge detection algorithm is statistically analyzed, wherein the maximum contour area is used as the contour area of fresh corn, and the ratio of the maximum contour area to the area of the minimum circumscribed rectangle is used as the fullness, and the higher the fullness, the better the ear shape. The scoring criteria are defined by the obtained fullness to prepare for subsequent grading.
[0015] Preferably, in step 4, the HSV color space model is used to analyze the appearance color of the fresh corn, and a scoring standard is defined based on the green or slightly yellow characteristics of the appearance color of the fresh corn to prepare for subsequent grading.
[0016] Preferably, in step 5, the HSV color space model is used to determine the color of the filaments, and the scoring criteria are defined according to the range standard of dark brown to prepare for subsequent grading.
[0017] Preferably, in step 6, a comprehensive score is performed based on the ear length score in step 2, the fullness score in step 3, the color score in step 4, and the filament color score in step 5, and the scores are summarized for grading.
[0018] The beneficial effects of the present invention are as follows:
[0019] The present invention combines multiple dimensions of fresh corn (ear length, ear shape, color and filament color) for comprehensive analysis and grading, avoiding the one-sidedness of a single feature, while having a high degree of automation and reducing manual intervention. Relying on visual detection, image processing is performed to automatically achieve feature extraction, evaluation and grading, avoiding misjudgment caused by lack of experience, visual fatigue or subjective bias in manual grading, and improving the consistency of grading. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flow chart of a fresh corn grading method based on visual detection in an embodiment;
[0021] Figure 2 It is a color analysis diagram of the HSV color space in the embodiment;
[0022] Figure 3 Schematic diagram of filament color feature extraction in the embodiment. DETAILED DESCRIPTION
[0023] In order to further understand the content of the present invention, the present invention is described in detail in conjunction with the accompanying drawings and embodiments. It should be understood that the embodiments are only for explaining the present invention and are not intended to limit it.
[0024] Example
[0025] like Figure 1 As shown, this embodiment provides a fresh corn grading method based on visual detection, which includes the following steps:
[0026] Step 1: Image acquisition is performed by using a high-definition industrial camera to obtain an appearance image of fresh corn.
[0027] Image acquisition is a very important part. It is necessary to ensure that the image of fresh corn is complete and clear, and the distortion is small after enlargement. In this regard, we must first pay attention to the lighting conditions. We must ensure uniform lighting and try to shoot under indoor controllable light sources. We must also avoid light spots and shadows. We must adjust the position of the light source to minimize the impact of shadows. Secondly, we must pay attention to the background selection. We must increase the contrast between the target and the background and reduce interference. We can choose a solid color background to form a high contrast with the corn color background. Then there is the camera selection. Use a high-resolution camera, at least 1080p, to ensure that the details are clear enough. Finally, the shooting angle and distance. In order to capture the comprehensive ear shape features, try to ensure that the camera is perpendicular to the corn ear as much as possible to avoid angle distortion. At the same time, keep the distance between the camera and the corn ear consistent to reduce the size ratio error. This can ensure that the subsequent image extraction and processing are as unaffected as possible.
[0028] Step 2: Obtain the outline of the corn through edge detection, and draw the minimum circumscribed rectangle based on the outline to obtain the ear length.
[0029] To extract the outline of corn through edge detection algorithm, we need to pay attention to the complete process from image acquisition to edge extraction to avoid target loss or incomplete outline due to improper processing. After completing step 1 of fresh corn image acquisition, we enter the image preprocessing stage. First, the input fresh corn color image is converted into a grayscale image to simplify the processing process; secondly, the corn image may contain noise (such as dust and spots), which needs to be denoised to highlight the outline, and Gaussian denoising is used to smooth the image. Through these processes, the quality of the image can be guaranteed to be intact.
[0030] Further entering the edge detection stage, the edge detection algorithm is used to extract the outline of fresh corn. First, the Canny parameters are adjusted. Since the effect of edge detection is sensitive to the threshold, it needs to be adjusted according to the image features. The low threshold (control edge starting point) is defined in the range of 50-100, and the high threshold (control edge connection) is defined in the range of 150-200. Further, edge connection and refinement are performed, mainly by performing dilation operations to expand the edges and fill the broken edges. Next, the contour extraction stage is performed, and contour screening is performed. After the contour is extracted, the main targets with larger areas are screened out. Finally, the bounding rectangle is calculated, and the minimum bounding rectangle is obtained according to the contour. At the same time, the length and width of the bounding rectangle are obtained to ensure that the rectangular frame covers the complete target. Therefore, according to the length of the minimum bounding rectangle, the ear length of the fresh corn is obtained, and the output is the pixel value.
[0031] When the pixel value of the fresh corn ear length is obtained, a scoring standard is defined: if the ear length is greater than 300 pixels, the score is 3; if the ear length is between 200 and 300 (including 200 and 300), the score is 2; the rest are scored as 1.
[0032] Step 3: Determine whether the ear shape is full and consistent based on the corn outline area and the minimum circumscribed rectangle area.
[0033] After extracting the corn outline by edge detection algorithm in step 2, the outline area is counted, and the maximum outline area is taken as the fresh corn outline area. Secondly, after obtaining the minimum circumscribed rectangle in step 2, the area of the minimum circumscribed rectangle is obtained by the length and width of the circumscribed rectangle, and then the fullness is calculated. The fullness is defined as the ratio of the fresh corn outline area to its minimum circumscribed matrix area. The higher the fullness, the fuller and more consistent the ear shape.
[0034] After obtaining the value of fullness, the fullness is used to measure the ear shape, and a scoring standard is defined for it: if the fullness is greater than 0.85, the score is 3; if the fullness is between 0.70-0.85 (including 0.70 and 0.85), the score is 2; the rest are scored as 1.
[0035] Step 4: Analyze the appearance color of fresh corn using the HSV color space model.
[0036] First, the input fresh corn color image is converted to the HSV color space, and the color analysis of the HSV color space is performed. The results can be referred to Figure 2, further, extract the average hue value of the image. According to the standards of cyan and slightly yellow, in HSV, cyan and slightly yellow are natural tones, which will produce a certain deviation under lighting and photography conditions. Therefore, the actual hue of cyan does not fully conform to the standard definition of pure cyan (H=90) or pure green (H=60), and the actual hue of slightly yellow does not fully conform to the standard definition of pure yellow (H=30). Therefore, it is necessary to appropriately expand the range, set the hue value range of cyan to between 35-85, and set the hue value range of slightly yellow to between 20-35. This can more accurately cover the hue changes of cyan and slightly yellow appearance under natural light, and can better adapt to changes. While covering the actual color gamut distribution of cyan and slightly yellow, it can improve the tolerance for errors in detection, avoid detection failures due to too strict hue boundaries, and better fit the tolerance of color detection in agricultural products. Therefore, it is possible to determine whether the color of the fresh corn appearance is cyan or slightly yellow.
[0037] Furthermore, based on the defined ranges of these two standards, the scoring criteria are defined: if the Hue value is between 35 and 85 (including 35 and 85), the score is 3; if the Hue value is between 20 and 35 (including 20 and excluding 35), the score is 2; and the rest of the Hue value range is scored as 1.
[0038] Step 5: Determine the color of the filaments using the HSV color space model.
[0039] First, the filaments are usually located at the top area of the corn ear. The position of the filaments is determined by setting the image ratio area. The height of the corn image is divided into several parts. The extraction ratio is determined according to the divided parts. In this embodiment, the top 20% area of the fresh corn image is extracted as the filament area. The average color value (BGR) of the input fresh corn color image is first calculated, and then further converted to the HSV color space to extract the filament color features. The results can be referred to Figure 3 . The average hue value is calculated. According to the standard that the filaments wither to dark brown, in HSV, dark brown is a dark tone close to red and orange, and the hue is close to 0 or slightly offset. Therefore, the hue value range of dark brown is set between 0-20, which mainly corresponds to the transition zone from red to orange. At the same time, these colors will show dark brown characteristics under low brightness and high saturation. Therefore, it is also necessary to define saturation greater than 100 and brightness less than 100. Setting this range can effectively avoid misjudging light red, orange and other colors as dark brown, and can more accurately identify dark brown filaments, improve the error tolerance in detection, and ensure detection stability. Therefore, it can be determined whether the filaments are dark brown if they are withered.
[0040] Furthermore, based on the definition range of dark brown, the scoring criteria are defined: if the Hue value is between 0 and 20 (excluding 0 and 20), and the saturation is greater than 100 and the brightness is less than 100, the score is 3; if the green component in the average color value of the image is greater than the blue component, yellow is the main color, and the score is 2; the rest are gray or abnormal, and the score is 1.
[0041] Step 6: Comprehensively score and grade the results through steps 2, 3, 4 and 5.
[0042] The total score is summarized through the ear length score in step 2, the fullness score in step 3, the color score in step 4, and the filament color score in step 5. The total score = ear length score + fullness score + color score + filament color score. If the total score is greater than or equal to 10, it is a first-level ear; if the total score is between 7-10 (including 7 and excluding 10), it is a second-level ear; the rest are third-level ears.
[0043] In summary, this embodiment targets the multi-dimensional characteristic requirements of fresh corn grading and demonstrates a grading method based on visual inspection. It automatically realizes feature extraction, evaluation and grading by analyzing the length and shape of the fresh corn cobs, as well as the appearance color and filament color of the fresh corn. It has good automation effect and saves manpower. It can be efficiently applied in agricultural sorting and grading to provide support for intelligent agricultural production.
[0044] The present invention and its embodiments are described schematically above, and the description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. Therefore, if a person skilled in the art is inspired by it and designs a structural method and an embodiment similar to the technical solution without creativity without departing from the purpose of the invention, they shall all fall within the protection scope of the present invention.
Claims
1. A fresh corn grading method based on visual inspection, characterized in that: The following steps are involved: Step 1, obtaining an appearance image of fresh corn for image acquisition; Step 2: Obtain the outline of the corn by edge detection, and draw the minimum circumscribed rectangle according to the outline to obtain the ear length; Step 3, judging whether the ear shape is full and consistent by the outline area of the corn and the area of the minimum circumscribed rectangle; Step 4, analyzing the appearance color of fresh corn using the HSV color space model; Step 5: Determine the color of the filaments using the HSV color space model; Step 6: Comprehensively score and grade the results through steps 2, 3, 4 and 5.
2. The fresh corn grading method based on visual detection according to claim 1, characterized in that: In step 1, the image is acquired by taking pictures with an industrial camera.
3. The fresh corn grading method based on visual detection according to claim 2, characterized in that: In step 2, the Canny edge detection algorithm is used to obtain the outline of the fresh corn, and the length of the minimum circumscribed rectangle is used as the length of the corn ear. The scoring standard is defined based on the obtained ear length to prepare for subsequent grading.
4. The fresh corn grading method based on visual detection according to claim 3 is characterized in that: In step 3, the contour of fresh corn is obtained by the Canny edge detection algorithm, and the contour area is calculated. The maximum contour area is taken as the contour area of fresh corn, and the ratio of the maximum contour area to the area of the minimum circumscribed rectangle is taken as the fullness. The higher the fullness, the better the ear shape. The scoring standard is defined by the obtained fullness to prepare for the subsequent grading.
5. The fresh corn grading method based on visual detection according to claim 4, characterized in that: In step 4, the HSV color space model is used to analyze the appearance color of fresh corn. According to the green or slightly yellow characteristics of the appearance color of fresh corn, a scoring standard is defined to prepare for subsequent grading.
6. The fresh corn grading method based on visual detection according to claim 5, characterized in that: In step 5, the HSV color space model is used to determine the color of the filaments, and the scoring criteria are defined according to the range standard of dark brown to prepare for subsequent grading.
7. The fresh corn grading method based on visual detection according to claim 6, characterized in that: In step 6, a comprehensive score is performed based on the ear length score in step 2, the fullness score in step 3, the color score in step 4, and the filament color score in step 5, and the scores are summarized for grading.