Machine vision selection method of water chestnuts based on spatial geometry and colorimetry features
Through the machine vision selection method of water chestnut based on spatial geometric and chromatic characteristics, the problem of low accuracy in the classification of water chestnuts in the prior art is solved, efficient and accurate water chestnuts are achieved, and detection efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202210836332.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-15
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-07-15
AI Technical Summary
When existing machine vision detection technology is used for selection of water chestnuts, the classification accuracy is low and it is difficult to effectively replace manual screening, mainly due to the complex appearance and obvious color characteristics of water chestnuts.
The machine vision selection method of the water chestnut based on spatial geometric and chromatic characteristics is adopted. Through image acquisition, visual processing, geometric features and chromatic feature extraction, corresponding discriminant functions and feature libraries are established to achieve accurate classification of the water chestnut types.
It effectively improves the accuracy and efficiency of water chestnut selection, and can accurately identify different types of water chestnuts, which are highly operable, interactive and portable.
Smart Images

Figure CN115171100B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of machine vision, and in particular to a method for selecting water chestnuts by machine vision based on spatial geometry and chromaticity features. Background Art
[0002] At present, with the rapid development of computer technology, machine vision detection technology has been well developed. Among them, the use of machine vision in the field of grain appearance quality detection has excellent development prospects. Compared with manual detection technology, machine vision has great advantages in crop and crop seed surface detection and seed grading, namely high detection accuracy, fast speed and large data volume. Therefore, machine vision detection methods can also be used for water chestnut seed selection.
[0003] The existing machine vision inspection technology will cause the following problems when used in the selection of water chestnuts:
[0004] 1) Water chestnuts are different from other agricultural products. They have multiple long corners, a rough surface, and a more complex appearance. The existing machine vision detection method will result in low classification accuracy.
[0005] 2) In order to improve the classification accuracy of water chestnut machine vision, existing machine vision will introduce other feature elements to ensure the accuracy of detection, such as color, area, spatial relationship, etc. For different objects, different features need to be introduced to ensure the accuracy of classification;
[0006] The existence of the above problems restricts the screening of water chestnut species by machine vision, and cannot replace manual screening with a higher accuracy. Since there is little research on water chestnuts, the present invention analyzes and improves the same type of machine vision inventions.
[0007] In 2022, Yang Zeqing et al. proposed a method and device for comprehensive fruit quality grading based on machine vision and X-rays (application publication number: CN114354637A). This method collects the appearance images of the fruits to be graded, uses the appearance grading network as the first classifier, annotates the images as the second classifier, and uses the decision-level fusion method based on the third classifier of artificial features to achieve the classification of the grades of the fruits. The disadvantage is that the specific proportion of the decision-level fusion method has not been determined. In addition, the use of convolutional neural networks requires a long training time and training set, which is time-consuming.
[0008] In 2022, Zhang Wei and others proposed a computer vision-based non-destructive detection and grading method for Hericium erinaceus (authorization announcement number: CN107564000B). The invention proposed to extract the characteristic parameters of Hericium erinaceus and establish a discriminant function of eccentricity and circularity to achieve non-destructive detection and grading of Hericium erinaceus. The disadvantage is that this method considers the appearance characteristics in the spatial direction, which may lead to low grading accuracy.
[0009] To sum up: To achieve accurate classification and screening of water chestnuts, it is necessary to analyze the appearance characteristics of water chestnuts and introduce other characteristic elements to help improve the accuracy of classification. Summary of the invention
[0010] The purpose of the present invention is to overcome the defects of the prior art and provide a method for selecting water chestnuts by machine vision based on spatial geometry and colorimetry characteristics, which can effectively improve the accuracy and efficiency of water chestnut selection.
[0011] The object of the present invention is achieved by: a method for selecting water chestnuts by machine vision based on spatial geometry and chromaticity features, comprising the following steps:
[0012] Step 1) collecting water chestnut images and dividing them into two groups: training and testing;
[0013] Step 2) visual processing of water chestnut images based on a water chestnut visual selection system;
[0014] Step 3) Based on the geometric features and colorimetric feature parameters of the water chestnut, a corresponding discriminant function is established, and the results are statistically analyzed to establish a geometric and colorimetric feature library;
[0015] Step 4) Obtain the features of the water chestnut to be detected and compare them with the corresponding feature library to determine its type.
[0016] Furthermore, the step 2) specifically includes:
[0017] By reading the water chestnut image, the water chestnut image is input into the visual seed selection system so as to perform visual processing on the image later;
[0018] By graying the water chestnut image, the graying method of color image is used to reduce the subsequent calculation amount while retaining the image information, and the graying weighted gray value suitable for the water chestnut image is obtained;
[0019] The collected water chestnut image is grayed using the weighted average graying algorithm, that is:
[0020] I=0.21R+0.41G+0.38B (1)
[0021] Wherein, I is the processed grayscale image, R is the red component in the color image RGB, G is the green component in the color image RGB, and B is the blue component in the color image RGB;
[0022] The median filter is used to protect the edge information of the corners. The classic method of smoothing noise is adopted. The filter scale of 4×4 is used to sort the grayscale of all pixels in the area from small to large, and then the middle value is taken as the new value of the central pixel, thereby eliminating isolated noise points.
[0023] Binarization and threshold segmentation are used to separate impurities and angular target graphics using image threshold segmentation technology. The factors of the lighting device are fixed and the global threshold segmentation principle is adopted, namely:
[0024]
[0025] Where g(x,y) is the segmented image, f(x,y) is the original image, and T is the threshold parameter. The threshold parameter T is selected as 50, so that the target pixel value within the grayscale range is set to 255, and the pixel value outside the range is set to 0, thus forming a binary image.
[0026] The operation of erosion followed by dilation is used, and grayscale morphological processing is performed in combination with smaller structural elements; the appearance of noise and holes is suppressed without changing the shape characteristics of water chestnut seeds;
[0027] Through contour extraction, when the grayscale of the target area and the background area in the image is certain, the steps of searching the water chestnut curve, curve tracing, curve connection and contour selection are used to extract the water chestnut target contour and obtain the geometric size information of the water chestnut seed, providing a corresponding method for creating a geometric feature library.
[0028] Color extraction is used to use the principle that the RGB color values collected are different due to the different skin colors of water chestnuts. The color distribution of the three components of R, G, and B is expressed through the color histogram. The chromaticity value of the water chestnut is expressed by calculating the average value of the three RGB channels, that is:
[0029]
[0030] Among them, Q is the chromaticity value of the object's corner, l R is the chromaticity value of the red channel, l G is the chromaticity value of the green channel, l B is the chromaticity value of the blue channel.
[0031] Furthermore, the step 3) specifically includes: establishing a morphological feature library of the geometric shapes of the major axis, minor axis, roundness, center area and axis ratio of the water chestnut and establishing a dimensional feature value library of the water chestnut, and establishing a spatial geometric discriminant function of the water chestnut;
[0032] The geometric feature library of water chestnuts was established, i.e. the morphological features of water chestnuts, i.e., the major axis (H), minor axis (W), roundness (C), and central area (A) were selected;
[0033] The roundness C is the degree to which the boundary of the central area of the water chestnut, excluding the long and short corners, is close to a circle, that is:
[0034]
[0035] Among them, A is the area of the central area, and L is the perimeter of the contour of the central area;
[0036] In addition, according to the obtained major axis (H) and minor axis (W), the axial ratio E of the water chestnut is calculated, that is:
[0037]
[0038] By using statistics to establish the spatial geometric discriminant function of water chestnuts, we can analyze the three spatial geometric features of roundness (C), axis ratio (E) and center area (A), namely:
[0039] G=2.6C+1.9E+2.2A+B (6)
[0040] Among them, G is the discriminant function value, and B is a constant;
[0041] By using the above calculation method, the range of different discriminant function values G can be set to obtain the category of water chestnuts;
[0042] The chromaticity feature library of water chestnuts was established by calculating the color values of the three R, G, and B channels of the color image of the water chestnut epidermis to determine the chromaticity features of the water chestnuts. Through calculation, the chromaticity feature value interval of intact water chestnuts was defined as [125,132], and the chromaticity feature value interval of peeled and damaged water chestnuts was defined as [135,140]. The chromaticity feature library of water chestnuts was established based on the chromaticity mean Q of RGB, which served as the basis for visual identification of water chestnuts for selection.
[0043] The present invention adopts the above technical scheme, and compared with the prior art, the beneficial effects are as follows: first, for the complex multi-water chestnut shape features, a geometric feature library of water chestnuts is established, such as water chestnut length, roundness, major axis, minor axis, area, axis ratio and other features, and a corresponding spatial geometric discriminant function is established, and the spatial geometric features of different types of water chestnuts are divided into corresponding intervals. The water chestnut to be detected is compared with its interval to obtain the water chestnut type;
[0044] Second, because water chestnuts have obvious color features, on the basis of extracting spatial geometric features, the chromaticity features of water chestnuts are extracted at the same time, and a corresponding chromaticity feature library is established to divide different chromaticity feature intervals, which can be compared with the water chestnuts to be detected;
[0045] Combining the dual discrimination of spatial geometric features and colorimetric features can effectively improve the accuracy and efficiency of water chestnut classification. This method is highly operational, interactive and portable. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is the overall flow chart of the present invention.
[0047] Figure 2 It is a flow chart of the image processing part of the present invention. DETAILED DESCRIPTION
[0048] like Figure 1 The method for selecting water chestnuts by machine vision based on spatial geometry and colorimetric features includes the following steps:
[0049] Step 1) collecting water chestnut images and dividing them into two groups: training and testing;
[0050] Use CCD industrial camera to collect images of water chestnuts, where the light source needs to be fixed in position to ensure smooth image processing;
[0051] All the collected water chestnut images are divided into training sample images and water chestnut images to be tested in a ratio of 3:7, and the training sample images are input into the computer for image processing.
[0052] Step 2) visual processing of water chestnut images based on the water chestnut visual selection system; Figure 2 As shown, the visual selection system is used to perform visual processing on the water chestnut image, including: water chestnut image reading, water chestnut image graying, median filtering, binarization and threshold segmentation, morphological processing, contour extraction and color extraction. Through a series of methods, the geometric information and color information of the water chestnut can be best retained, and the establishment of the geometric feature library and the colorimetric feature library can be guaranteed with high accuracy.
[0053] By reading the water chestnut image, the water chestnut image is input into the visual seed selection system so as to perform visual processing on the image later;
[0054] By graying the water chestnut image, the graying method of color image is used to reduce the subsequent calculation amount while retaining the image information, and the graying weighted gray value suitable for the water chestnut image is obtained;
[0055] The collected water chestnut image is grayed using the weighted average graying algorithm, that is:
[0056] I=0.21R+0.41G+0.38B (1)
[0057] Among them, I is the processed grayscale image, R is the red component in the color image RGB, G is the green component in the color image RGB, and B is the blue component in the color image RGB; the image processed by the weighted grayscale method can make the grayscale value of the water chestnut and the grayscale value of the background more clearly distinguished, which is conducive to subsequent image segmentation.
[0058] The median filter is used to protect the edge information of the corners. The classic method of smoothing noise is adopted. The filter scale of 4×4 is used to sort the grayscale of all pixels in the area from small to large, and then the middle value is taken as the new value of the central pixel, thereby eliminating isolated noise points.
[0059] Binarization and threshold segmentation are used to avoid the influence of fine particles such as soil blocks on the classification accuracy during the machine seed selection process;
[0060] Binarization and threshold segmentation are used to separate impurities and angular target graphics using image threshold segmentation technology. The factors of the lighting device are fixed and the global threshold segmentation principle is adopted, namely:
[0061]
[0062] Among them, g(x,y) is the segmented image, f(x,y) is the original image, and T is the threshold parameter; the threshold parameter T is selected as 50, so that the target pixel value in the grayscale range is set to 255 (white), and the pixel value outside the range is set to 0 (black), thereby forming a binary image; this method has high accuracy, and the algorithm is simpler and easier to transplant than automatic threshold segmentation.
[0063] Morphological processing can realize accurate and rapid image recognition, remove irrelevant elements in the target area, and maintain the basic characteristics of the image; the present invention adopts the operation of corrosion followed by expansion, and combines smaller structural elements for grayscale morphological processing; suppresses the appearance of noise and holes without changing the shape characteristics of water chestnut seeds;
[0064] Through contour extraction, when the grayscale of the target area and the background area in the image is certain, the steps of searching the water chestnut curve, curve tracing, curve connection and contour selection are used to extract the water chestnut target contour, and obtain the geometric size information of the major and minor axes, circumference, etc. of the water chestnut seeds, providing a corresponding method for creating a geometric feature library;
[0065] Color extraction is used to use the principle that the RGB color values collected are different due to the different skin colors of water chestnuts. The color distribution of the three components of R, G, and B is expressed through the color histogram. The chromaticity value of the water chestnut is expressed by calculating the average value of the three RGB channels, that is:
[0066]
[0067] Among them, Q is the chromaticity value of the object's corner, l R is the chromaticity value of the red channel, l G is the chromaticity value of the green channel, l B is the chromaticity value of the blue channel.
[0068] Step 3) Based on the geometric features and colorimetric feature parameters of the water chestnut, a corresponding discriminant function is established, and the results are statistically analyzed to establish a geometric and colorimetric feature library;
[0069] Extract the geometric and colorimetric characteristic parameters of water chestnuts, establish the corresponding discriminant function, and use the statistical results to establish a spatial geometric and colorimetric characteristic library, including the establishment of a morphological characteristic library of geometric shapes such as the major axis, minor axis, roundness, center area and axis ratio of water chestnuts, and the establishment of a colorimetric characteristic value library of water chestnuts;
[0070] The geometric feature library of water chestnuts was established, i.e. the morphological features of water chestnuts, i.e., the major axis (H), minor axis (W), roundness (C), and central area (A) were selected;
[0071] The roundness C is the degree to which the boundary of the central area of the water chestnut, excluding the long and short corners, is close to a circle, that is:
[0072]
[0073] Among them, A is the area of the central area, and L is the perimeter of the contour of the central area;
[0074] In addition, according to the obtained major axis (H) and minor axis (W), the axial ratio E of the water chestnut is calculated, that is:
[0075]
[0076] By using statistics to establish the spatial geometric discriminant function of water chestnuts, we can analyze the three spatial geometric features of roundness (C), axis ratio (E) and center area (A), namely:
[0077] G=2.6C+1.9E+2.2A+B (6)
[0078] Among them, G is the discriminant function value, and B is a constant;
[0079] By using the above calculation method, the range of different discriminant function values G can be set to obtain the category of water chestnuts;
[0080] The chromaticity feature library of water chestnuts was established by calculating the color values of the three R, G, and B channels of the color image of the water chestnut epidermis to determine the chromaticity features of the water chestnuts. Through calculation, the chromaticity feature value interval of intact water chestnuts was defined as [125,132], and the chromaticity feature value interval of peeled and damaged water chestnuts was defined as [135,140]. The chromaticity feature library of water chestnuts was established based on the chromaticity mean Q of RGB, which served as the basis for visual identification of water chestnuts for selection.
[0081] Step 4) obtaining the features of the water chestnut to be detected and comparing them with the corresponding feature library to determine its type;
[0082] Since different water chestnuts have different spatial geometric features and colorimetric features, the image of the water chestnut to be detected is input into the computer, and the spatial geometric features and colorimetric features of the water chestnut to be detected are extracted. According to steps 2) and 3), it is judged whether it conforms to the spatial geometric discriminant function, and the colorimetric features are used to assist in classification. When the spatial geometric features and the colorimetric features meet the set values at the same time, the type of water chestnut can be obtained.
[0083] The present invention extracts the feature values of the spatial shape and color of the water chestnut, that is, the spatial geometric features and the colorimetric features, finds the corresponding discriminant function, and establishes the corresponding feature value library. When detection is needed, the water chestnut is subjected to image acquisition, visual processing and other operations to extract its corresponding features, and the features are input into the obtained discriminant function to find the corresponding water chestnut type, thereby realizing the screening of water chestnut species, thereby effectively improving the accuracy and efficiency of water chestnut selection.
[0084] The present invention is not limited to the above-mentioned embodiments. On the basis of the technical solution disclosed in the present invention, technicians in this field can make some substitutions and deformations to some technical features therein according to the disclosed technical content without creative labor, and these substitutions and deformations are all within the protection scope of the present invention.
Claims
1. A method for selecting water chestnuts by machine vision based on spatial geometry and colorimetric features, characterized in that: The following steps are involved: Step 1) collecting water chestnut images and dividing them into two groups: training and testing; Step 2) visual processing of water chestnut images based on a water chestnut visual selection system; Step 3) Based on the geometric features and colorimetric characteristic parameters of the water chestnut, a corresponding discriminant function is established, and the results are statistically analyzed to establish a geometric and colorimetric characteristic library; Step 4) obtaining the features of the water chestnut to be detected and comparing them with the corresponding feature library to determine its type; The step 2) specifically includes: By reading the water chestnut image, the water chestnut image is input into the visual seed selection system so as to perform visual processing on the image later; By graying the water chestnut image, a method of graying a color image while retaining image information and reducing the amount of subsequent calculations is used to obtain a graying weighted gray value suitable for the water chestnut image; The collected water chestnut image is grayed using the weighted average graying algorithm, that is: I=0.21R+0.41G+0.38B (1) Wherein, I is the processed grayscale image, R is the red component in the color image RGB, G is the green component in the color image RGB, and B is the blue component in the color image RGB; The median filter is used to protect the edge information of the corners. The classic method of smoothing noise is adopted. The filter scale of 4×4 is used to sort the grayscale of all pixels in the neighborhood from small to large, and then the median value is taken as the new value of the central pixel, thereby eliminating isolated noise points. Binarization and threshold segmentation are used to separate impurities and angular target graphics using image threshold segmentation technology. The factors of the lighting device are fixed and the global threshold segmentation principle is adopted, namely: Where g(x,y) is the segmented image, f(x,y) is the original image, and T is the threshold parameter. The threshold parameter T is selected as 50, so that the target pixel value within the grayscale range is set to 255, and the pixel value outside the range is set to 0, thus forming a binary image. The operation of erosion followed by dilation is used, and grayscale morphological processing is performed in combination with smaller structural elements; the appearance of noise and holes is suppressed without changing the shape characteristics of water chestnut seeds; Through contour extraction, when the grayscale of the target area and the background area in the image is certain, the steps of searching the water chestnut curve, curve tracing, curve connection and contour selection are used to extract the water chestnut target contour and obtain the geometric size information of the water chestnut seed, providing a corresponding method for creating a geometric feature library. Color extraction is used to use the principle that the RGB color values collected are different due to the different skin colors of water chestnuts. The color distribution of the three components of R, G, and B is expressed through the color histogram. The chromaticity value of the water chestnut is expressed by calculating the average value of the three RGB channels, that is: Among them, Q is the chromaticity value of the object's corner, l R is the chromaticity value of the red channel, l G is the chromaticity value of the green channel, l B is the chromaticity value of the blue channel; The step 3) specifically includes: establishing a morphological feature library of the geometric shapes of the major axis, minor axis, roundness, center area and axis ratio of the water chestnut and establishing a dimensional feature value library of the water chestnut, and establishing a spatial geometric discriminant function of the water chestnut; The geometric feature library of water chestnuts is established, that is, the morphological features of water chestnuts, i.e., the major axis H, minor axis W, roundness C, and central area A are selected; The roundness C is the degree to which the boundary of the central area of the water chestnut, excluding the long and short corners, is close to a circle, that is: Among them, A is the area of the central area, and L is the perimeter of the contour of the central area; In addition, according to the obtained major axis H and minor axis W, the axial ratio E of the water chestnut is calculated, that is: By using statistics to establish the spatial geometric discriminant function of water chestnuts, the three spatial geometric features of roundness C, axis ratio E and center area A are as follows: G=2.6C+1.9E+2.2A+B (6) Among them, G is the discriminant function value, and B is a constant; The chromaticity feature library of water chestnut is established. The color values of the three R, G, and B channels of the color image of the water chestnut skin are calculated to determine the chromaticity features of the water chestnut. Through calculation, the chromaticity feature value interval of intact water chestnut is defined as [125,132], and the chromaticity feature value interval of peeled and damaged water chestnut is defined as [135,140]. The chromaticity feature library of water chestnut is established according to the chromaticity mean Q of RGB, which serves as the basis for visual identification of water chestnut selection.
Citation Information
Patent Citations
Non-destructive testing and grading method for Hericium erinaceus based on computer vision
CN107564000B
Fruit quality comprehensive grading method and device based on machine vision and X rays
CN114354637A
Cultivation method of water chestnuts
CN109863955A
Shellfish external morphological parameter measurement method based on image processing combination technology
CN111695477A