Grain classification and identification method and system based on image analysis

By combining the grayscale histogram and the gradient change rate, local characteristic parameters of grain particles are extracted and spectral-texture joint feature matrix is ​​constructed, the problem of single feature dimensions and lack of dynamic correction mechanisms in the existing technology is solved, and high-precision identification of grains in complex industrial environments is achieved.

CN119992229AInactive Publication Date: 2025-05-13SHANDONG BUSINESS INST +1
View PDF 0 Cites 9 Cited by

Patent Information

Application Number
CN202510465225.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-05-13
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing technology has a single feature dimension and a lack of dynamic correction mechanism in grain classification recognition, which leads to a decrease in recognition accuracy in complex industrial environments, and it is impossible to effectively distinguish grain species with similar appearance but different compositions.

Method used

By combining the grayscale histogram and the gradient change rate, the local characteristic parameters of grain particles are extracted, and the spectral-texture joint feature matrix is ​​constructed through weighted feature vectors and spectral feature points sets to realize the multi-dimensional feature characterization of grain.

Benefits of technology

It enhances the capture ability of complex surface features, suppresses environmental interference, improves the recognition accuracy of grains with similar appearance but different compositions, and improves anti-interference and recognition accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119992229A_ABST
    Figure CN119992229A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of machine learning, in particular to a grain classification and recognition method and system based on image analysis, and the method comprises the following steps: obtaining grain particle image data, calculating a gray histogram and a gradient change rate, calling a gray co-occurrence matrix to extract grain particle texture density, and scanning a sliding window to obtain local feature parameters of grain particles. According to the method, through combined analysis of a gray level histogram and a gradient change rate, dynamic extraction of particle textures through a sliding window, enhancement of complex surface feature capture, normalization of contrast and direction consistency parameters, construction of weighted feature vectors, dynamic correction of variance contribution degree and suppression of environmental interference, and fusion of near-infrared and short-wave infrared reflectivity changes, the near-infrared and short-wave infrared reflectance change is improved. And quantifying the mean value and peak-to-valley ratio of spectrum difference values, matching visible light characteristics to verify multi-dimensional constraints, constructing a spectrum-texture matrix by local reflectivity rate and gradient change rate, and synchronously evaluating global similarity and spatial distribution difference by adopting Euclidean distance and local offset double-layer matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine learning, and in particular to a grain classification and recognition method and system based on image analysis. Background Art

[0002] The field of machine learning technology includes methods that use computer algorithms to learn patterns from data and make decisions or predictions. The core content of this field includes different learning paradigms such as supervised learning, unsupervised learning, and reinforcement learning, each of which is modeled based on different training data characteristics. Supervised learning trains classification or regression models by annotating data sets, unsupervised learning is used to discover data structures and patterns, and reinforcement learning adjusts decision strategies based on environmental feedback. Machine learning technology is widely used in computer vision, natural language processing, recommendation systems and other fields. Computer vision refers to the use of computers to analyze and understand image or video data to achieve functions such as classification, object detection, and image segmentation. The development of this field involves key links such as feature extraction, model training, and optimization methods, which continuously promotes algorithm optimization and computing power improvement, thereby enhancing the recognition accuracy and generalization ability of the model.

[0003] Among them, the grain classification and identification method refers to a processing method for classifying grain types based on computer vision and pattern recognition technology. This method mainly covers technical links such as image acquisition, feature extraction, classification modeling and decision output. Image acquisition uses optical imaging equipment to obtain grain quality data, feature extraction uses parameters such as color, shape, texture as the basis for classification, and classification modeling usually uses convolutional neural networks to perform pattern matching and classification of grain types. The decision output gives a specific classification label based on the model calculation results to guide subsequent grain screening or quality inspection.

[0004] Traditional methods rely on manually annotated static visual feature sets, which are sensitive to reflections or impurities, resulting in blurred classification boundaries. Although convolutional neural networks extract high-order texture features, they do not introduce spectral reflectance data and cannot distinguish between grains with similar appearance but different ingredients. Fixed parameter feature extraction models are difficult to adapt to different particle sizes or surface morphologies, resulting in the loss of local texture details. Supervised learning relies on a large amount of annotated data, but has weak capabilities for fusing multi-source heterogeneous features, and is unable to establish a collaborative discrimination model for spectrum and texture. The single global similarity calculation in the decision-making stage ignores the impact of feature offsets in local damaged or contaminated areas. The existing technology has a single feature dimension and lacks a dynamic correction mechanism. In complex industrial environments, it needs to rely on data enhancement to maintain basic performance. Summary of the invention

[0005] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a grain classification and recognition method and system based on image analysis.

[0006] In order to achieve the above object, the present invention adopts the following technical solution: a method for grain classification and recognition based on image analysis, comprising the following steps: S1: Obtain grain particle image data, calculate grayscale histogram and gradient change rate, call grayscale co-occurrence matrix to extract grain particle texture density, and scan with sliding window to obtain local feature parameters of grain particles; S2: Based on the local characteristic parameters of the grain particles, the contrast, directional consistency, and roughness are calculated and normalized, and the variance contribution is called to calculate the weighted characteristic vector of the grain particles; S3: Obtain the spectral reflectance data of grain particles, calculate the changes in the local reflectance of near-infrared and short-wave infrared, call the normalized spectral difference to analyze the mean, standard deviation and peak-to-valley ratio, screen the key spectral features of grain particles, call the visible light data to determine the matching stability, and obtain the spectral feature point set of grain particles; S4: Based on the weighted feature vector of the grain particle and the spectral feature point set of the grain particle, the local reflectance rate is calculated, the spectral response of the grain particle texture information is analyzed by calling the local gradient change rate, and a spectrum-texture joint feature matrix is ​​established; S5: Based on the spectrum-texture joint feature matrix, a grain classification feature library is constructed, the Euclidean distance between the test sample and the database sample is calculated, the local feature judgment offset is called, and the grain particle classification matching value is obtained.

[0007] As a further scheme of the present invention, the local feature parameters of the grain particles include grayscale histogram, gradient change rate, grayscale co-occurrence matrix texture density, and sliding window local features; the weighted feature vector of the grain particles includes contrast, directional consistency, roughness, and variance contribution; the spectral feature point set of the grain particles includes near-infrared local reflectivity change, short-wave infrared local reflectivity change, normalized spectral difference analysis mean, normalized spectral difference analysis standard deviation, normalized spectral difference analysis peak-to-valley ratio, and visible light data matching stability; the spectral-texture joint feature matrix includes local reflectivity rate, local gradient change rate spectral response, and grain particle texture information spectral response; the grain classification feature library includes Euclidean distance, local feature judgment offset, and grain particle classification matching value.

[0008] As a further solution of the present invention, the step of obtaining the local characteristic parameters of the grain particles is specifically as follows: S101: obtaining grain particle image data, performing grayscale transformation on the image, calculating grayscale values ​​pixel by pixel, constructing a histogram according to the grayscale values ​​of multiple pixels, counting the number of differentiated grayscale pixels, performing normalization, and generating a grayscale histogram; S102: Based on the grayscale histogram, calculate the difference of grayscale values ​​of adjacent pixels, traverse the image area to count the mean of the difference, calculate the overall change trend after normalization, and generate the grayscale gradient change rate; S103: calling the gray gradient change rate, constructing a sliding window to scan the local area of ​​grain particles, calculating the gray co-occurrence matrix of the pixels in the window, and performing operations on the contrast, uniformity, and entropy value, using the formula: ; Obtain the texture density parameters of the local area by operation, calculate the density parameter distribution in all windows, and generate the local characteristic parameters of grain particles; in, Represents the local characteristic parameters of grain particles, Represents the first The gray value of a pixel, Represents the window The grayscale contrast of each pixel is Represents the window The gray level entropy value of each pixel is Represents the number of rows and columns of pixels in the window, Represents the total number of pixels in the window.

[0009] As a further solution of the present invention, the step of obtaining the weighted feature vector of the grain particles is specifically as follows: S201: Based on the local characteristic parameters of the grain particles, the contrast, directional consistency and roughness are calculated to obtain the contrast value, directional consistency measurement value and roughness coefficient of the grain particles, and at the same time, multiple characteristic values ​​are adjusted to the same numerical range to construct a normalized characteristic parameter set; S202: calling the normalized feature parameter set, calculating the weights of multiple features based on variance contribution, and calculating the product of multiple feature values ​​and weights, and performing weighted summation, using the formula: ; The weighted characteristic value of grain particles is calculated; in, represents the weighted eigenvalue of grain particles, Represents the first in the normalized feature parameter set eigenvalues, The variance contribution is calculated as feature weights, Represents the individual value of a certain category of features in the normalized feature parameter set, represents the mean of the category feature, The number of individuals representing the class characteristics, is the weight adjustment coefficient, which is used to balance the feature contribution; S203: calling the weighted eigenvalues ​​of the grain particles, constructing an eigenvector matrix, characterizing the core feature data of the grain particles according to the calculated eigenvalues, and establishing a weighted eigenvector of the grain particles.

[0010] As a further solution of the present invention, the step of acquiring the grain particle spectral feature point set is specifically as follows: S301: Acquire spectral reflectance data of grain particles, extract local reflectance changes of near infrared and short-wave infrared spectra, calculate normalized spectral differences of multiple bands, calculate the mean, standard deviation and peak-to-valley ratio of the normalized spectral differences, and obtain normalized spectral difference characteristic parameters; S302: Based on the normalized spectral difference characteristic parameters, perform partition calculation on the multi-spectral band, screen the key spectral region, extract the stability parameter of the spectral feature, and establish the spectral variation coefficient according to the reflectivity change and standard deviation of the multiple regions, using the formula: ; Obtain the spectrum variation coefficient of the multi-spectral region by calculation, select the band range with higher spectrum stability, and obtain the stable spectrum region parameters; in, represents the spectral variation coefficient, Representative The normalized spectral reflectance of each band, Represents the mean of the normalized spectral reflectance of all bands, represents the standard deviation of the spectral reflectance, represents the total number of spectral bands, Represents the maximum value of the normalized spectral reflectance of all bands; S303: calling the stable spectral region parameters, matching the visible light band data, calculating the correlation between the multi-band spectral changes and the visible light data, screening the spectral features with higher matching stability, and obtaining the grain particle spectral feature point set.

[0011] As a further solution of the present invention, the step of obtaining the spectrum-texture joint feature matrix is ​​specifically as follows: S401: calculating the local reflectivity rate of multiple grain particles at differentiated wavelengths based on the weighted feature vector of the grain particles and the spectral feature point set of the grain particles, performing numerical normalization processing on the local reflectivity rate of each grain particle, and generating a normalized local reflectivity rate; S402: calling the normalized local reflectivity rate, calculating the local gradient change rate of multiple grain particles in the target band, analyzing the gradient change trend of the grain particles, and obtaining the gradient change rate matrix of the multiple grain particles by a wavelength dimension difference calculation method; S403: Based on the gradient change rate matrix, the texture information spectral response of the grain particles is calculated using the formula: ; The spectrum-texture composite features of multiple grain particles are obtained by operation, and matrix mapping is performed to establish a spectrum-texture joint feature matrix; in, represents the spectral-texture composite feature, Representative The normalized local reflectivity rate of each grain particle, Representative The local gradient change rate of each grain particle, Represents the number of grain samples.

[0012] As a further solution of the present invention, the step of obtaining the grain particle classification matching value is specifically as follows: S501: constructing a classification feature library of grain samples based on the spectrum-texture joint feature matrix, calculating a feature vector of each grain sample, and storing the feature vector in a database to obtain a grain classification feature storage matrix; S502: calling the food classification feature storage matrix, calculating the Euclidean distance between the test sample and the database sample, setting the threshold standard between adjacent samples, and comparing them to screen samples that meet the classification requirements, using the formula: ; Calculate the offset distance correction value, make offset judgment, and obtain the offset calculation benchmark; in, Represents the offset distance correction value, represents the eigenvalue of the test sample, represents the characteristic value of the database sample, is the feature dimension, represents the local eigenvalue of the test sample, represents the local eigenvalue of the database sample, is the number of local features; S503: Calling the offset calculation benchmark, calculating the classification matching value of the test sample, and comprehensively considering the distance and feature difference of the matching samples in the database to calculate the classification matching value of the grain particles.

[0013] The method further comprises: S6: Based on the grain particle classification matching value, a classification decision is executed to classify the grain particles into corresponding categories, and the grain particles are automatically stored or labeled.

[0014] A grain classification and recognition system based on image analysis, the grain classification and recognition system based on image analysis is used to execute the grain classification and recognition method based on image analysis, the system comprises: The image feature extraction module obtains grain particle image data, calculates the image grayscale histogram, calls the grayscale co-occurrence matrix to calculate the image texture density, calculates the particle edge features based on the gradient change rate, and uses sliding window scanning to obtain local feature parameters, including texture contrast, directional consistency, and particle roughness, to construct grain particle image feature parameters; The local feature calculation module calculates the contrast, directional consistency and roughness of multiple local features based on the grain particle image feature parameter set, normalizes the feature data, and calculates the weighted feature vector of the grain particle by calling the variance contribution to obtain the weighted feature vector of the grain particle; The spectral feature screening module obtains the spectral reflectance data of grain particles, calculates the local reflectance changes in the near-infrared and short-wave infrared regions, screens the key spectral features of grain particles based on the normalized spectral difference analysis mean, standard deviation and peak-to-valley ratio, calls the visible light reflectance data to calculate the matching stability, and obtains the spectral feature point set of grain particles; The feature matrix construction module calculates the local reflectance rate based on the weighted feature vector of the grain particles and the spectral feature point set of the grain particles, calls the local gradient change rate to calculate the spectral response of the grain particle texture information, and constructs a spectrum-texture joint feature matrix; The classification matching calculation module constructs a grain classification feature library based on the spectrum-texture joint feature matrix, calculates the Euclidean distance between the test sample and the database sample, calls the local feature judgment offset, and obtains the grain particle classification matching value; The intelligent classification decision and adaptive optimization module executes classification decision based on the classification matching value of the grain particles, classifies the grain particles into corresponding categories, and automatically stores or labels them.

[0015] Compared with the prior art, the advantages and positive effects of the present invention are: In the present invention, the grayscale histogram and the gradient change rate are jointly analyzed, and the particle microtexture is dynamically extracted in combination with the sliding window to enhance the ability to capture complex surface features. The variance contribution is dynamically corrected when the normalized contrast and directional consistency parameters are constructed into weighted feature vectors to suppress the influence of environmental interference on feature stability. The near-infrared and short-wave infrared reflectivity change data are integrated to quantify the spectral difference mean and peak-to-valley ratio, establish a basis for distinguishing the physical properties of material composition differences, and form a multi-dimensional constraint with the visible light feature matching verification. The local reflectivity rate and the gradient change rate are associated to construct a spectral-texture joint feature matrix to achieve nonlinear complementarity of heterogeneous data and expand the feature representation dimension. The Euclidean distance and local offset double-layer matching mechanism is adopted to simultaneously evaluate the global similarity and spatial distribution differences, and improve the anti-interference ability to local feature mutations. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a schematic diagram of the workflow of the present invention; Figure 2 It is a flow chart of the steps of obtaining the local characteristic parameters of grain particles of the present invention; Figure 3 A flow chart of the steps for obtaining the weighted feature vector of grain particles of the present invention; Figure 4 The flowchart of the steps of obtaining the spectral feature point set of grain particles of the present invention; Figure 5 Flow chart of the steps of obtaining the spectrum-texture joint feature matrix of the present invention; Figure 6 This is a flow chart of the steps for obtaining the grain particle classification matching value of the present invention. DETAILED DESCRIPTION

[0017] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0018] In the description of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, in the description of the present invention, "multiple" means two or more, unless otherwise clearly and specifically defined.

[0019] Embodiment 1: See also Figure 1 The present invention provides a technical solution: a method for grain classification and recognition based on image analysis, comprising the following steps: S1: Obtain grain particle image data, calculate grayscale histogram and gradient change rate, call grayscale co-occurrence matrix to extract grain particle texture density, and scan with sliding window to obtain local feature parameters of grain particles; S2: Based on the local characteristic parameters of grain particles, the contrast, directional consistency, and roughness are calculated and normalized, and the variance contribution is called to calculate the weighted feature vector of grain particles; S3: Obtain the spectral reflectance data of grain particles, calculate the changes in the local reflectance of near-infrared and short-wave infrared, call the normalized spectral difference to analyze the mean, standard deviation and peak-to-valley ratio, screen the key spectral features of grain particles, call the visible light data to determine the matching stability, and obtain the spectral feature point set of grain particles; S4: Based on the weighted feature vector of grain particles and the spectral feature point set of grain particles, the local reflectance rate is calculated, the local gradient change rate is called to analyze the spectral response of the grain particle texture information, and the spectrum-texture joint feature matrix is ​​established; S5: Based on the spectrum-texture joint feature matrix, a grain classification feature library is constructed, the Euclidean distance between the test sample and the database sample is calculated, the local feature judgment offset is called, and the grain particle classification matching value is obtained.

[0020] The local feature parameters of grain particles include grayscale histogram, gradient change rate, grayscale co-occurrence matrix texture density, and sliding window local features. The weighted feature vectors of grain particles include contrast, directional consistency, roughness, and variance contribution. The spectral feature point set of grain particles includes near-infrared local reflectivity change, short-wave infrared local reflectivity change, normalized spectral difference analysis mean, normalized spectral difference analysis standard deviation, normalized spectral difference analysis peak-to-valley ratio, and visible light data matching stability. The spectral-texture joint feature matrix includes local reflectivity rate, local gradient change rate spectral response, and grain particle texture information spectral response. The grain classification feature library includes Euclidean distance, local feature judgment offset, and grain particle classification matching value.

[0021] See also Figure 2 , the specific steps for obtaining the local characteristic parameters of grain particles are: S101: obtaining grain particle image data, performing grayscale transformation on the image, calculating grayscale values ​​pixel by pixel, constructing a histogram according to the grayscale values ​​of multiple pixels, counting the number of differentiated grayscale pixels, performing normalization, and generating a grayscale histogram; First, use a high-resolution industrial camera to capture images and ensure uniform lighting to reduce shadow interference. For the original image, select the 8-bit grayscale format (0-255) and use the RGB value conversion formula of the pixel point: ; Calculate the gray value of each pixel and store it pixel by pixel to form a gray matrix. For all pixels in the matrix, count the frequency of occurrence of each gray value in order to establish a gray histogram. Set the number of gray levels to 256. The steps for constructing the gray histogram are as follows: initialize an array of length 256, each index position corresponds to a gray value of 0-255, and each time a pixel is traversed, its gray value is read, and the counter of the index position corresponding to the value is increased by 1. After the statistics are completed, all counts are normalized, that is, the number of pixels at each gray level is divided by the total number of pixels to ensure the comparability of images of different sizes. Assuming that the image size is 1920×1080 and the total number of pixels is 2073600, the pixel with a gray value of 120 appears 62000 times, and the normalized calculation is: ; As shown in Table 1, the sample grayscale histogram data lists some key statistical values: Table 1 Grayscale histogram normalization data table:

[0022] As shown in Table 1, the normalized grayscale histogram can be used for subsequent calculations. The result shows that the grayscale values ​​of the image are mainly concentrated in the range of 100-150, indicating that the surface features of the grain particles account for a large proportion in this range, indicating that the color of the particles is relatively uniform, which provides a data basis for subsequent texture feature extraction.

[0023] S102: Based on the grayscale histogram, calculate the difference of the grayscale values ​​of adjacent pixels, traverse the image area to count the average of the difference, calculate the overall change trend after normalization, and generate the grayscale gradient change rate; First, the image matrix is ​​traversed, and the grayscale difference between each pixel and its right pixel, bottom pixel, and lower right diagonal pixel is calculated. For example, if the pixel point The gray value is , right pixel The gray value is , then the horizontal gradient is calculated as follows: ; Similarly, the vertical gradient and diagonal gradient are calculated as follows: ; ; The above gradient values ​​are calculated by traversing the entire image, and the mean of all gradient values ​​is counted to measure the overall grayscale change trend. For example, if the selected area is Window, there are 100 pixels in the area, and the horizontal gradient mean, vertical gradient mean and diagonal gradient mean obtained after gradient calculation are: ; After normalization calculation, it is convenient for subsequent feature extraction as follows: ; At this time, the overall grayscale gradient change rate is: ; The results show that the grayscale gradient change rate of the grain particles is low, indicating that the particle surface is smooth and the color transition is relatively uniform, which is helpful for the subsequent texture feature extraction.

[0024] S103: Call the grayscale gradient change rate, build a sliding window to scan the local area of ​​grain particles, calculate the grayscale co-occurrence matrix of the pixels in the window, and perform operations on contrast, uniformity, and entropy using the formula: ; Obtain the texture density parameters of the local area by operation, calculate the density parameter distribution in all windows, and generate the local characteristic parameters of grain particles; in, Represents the local characteristic parameters of grain particles, Represents the first The gray value of a pixel, Represents the window The grayscale contrast of each pixel is Represents the window The gray level entropy value of each pixel is Represents the number of rows and columns of pixels in the window, Represents the total number of pixels in the window.

[0025] Based on the calculated grayscale gradient change rate, a sliding window is constructed to scan the local area of ​​the grain particles, and the window size is set to (i.e. each window contains 25 pixels). In each window, a gray-level co-occurrence matrix (GLCM) is constructed to calculate the contrast, uniformity, and entropy of all pixels in the window. The calculation method is as follows: Contrast calculation: ; After calculation, we get ; Entropy calculation: ; After calculation, the entropy value is obtained ; Finally, through the formula: ; Substituting the values: ; ; The results show that the local characteristic parameters of grain particles At around 48.51, this value reflects that the particle has a high texture density, which means that its surface texture is rich and there may be a concave-convex structure. This result can be used for particle quality classification or surface defect detection, and provide a reliable basis for subsequent image feature analysis.

[0026] See also Figure 3 , the specific steps for obtaining the weighted feature vector of grain particles are: S201: Based on the local characteristic parameters of the grain particles, the contrast, directional consistency and roughness are calculated to obtain the contrast value, directional consistency measurement value and roughness coefficient of the grain particles, and at the same time, multiple characteristic values ​​are adjusted to the same numerical range to construct a normalized characteristic parameter set; First, we need to extract three key features, namely contrast, directional consistency and roughness. In order to calculate the contrast, we need to obtain the grayscale distribution of the grain particle image. By calculating the grayscale difference between different pixels, we can quantify its contrast level. Assuming that the pixel grayscale value of a grain sample area is , when calculating contrast, the variance can be calculated by the gray level difference of adjacent pixels. Assuming the calculated standard deviation is 10.5, this value is the measurement index of grain particle contrast. Directional consistency is calculated by calculating the gradient direction distribution of the grain particle edge. The Sobel operator is used to extract the edge gradient information. Suppose the gradient direction of a pixel is , after calculating its standard deviation, if the result is 12.7, it can be used to measure the consistency of direction. If the standard deviation is small, it means that the direction tends to be consistent. The roughness parameter needs to be calculated based on the surface texture characteristics. The root mean square roughness (RMS) can be used for determination, that is, to calculate the root mean square value of the surface height of the grain particles. Suppose the surface height of a sample is mm, then its RMS value is calculated as ,in is the average height, and the calculated RMS value is 0.03 mm, which can be used as a measurement parameter for the surface roughness of grain particles. In order to make the numerical range of different features consistent, the feature values ​​need to be normalized. Assume that the original values ​​of contrast, directional consistency and roughness are , the minimum-maximum normalization method can be used to convert the data to The interval is calculated as , assuming the contrast range is , the direction consistency range is , the roughness range is , then the normalized feature parameter set is calculated as ,After the normalized feature parameter set is constructed, it can be used for subsequent calculations. ,This result shows that the characteristics of grain particles have been converted into a dimensionless ,uniform standard form, which can be used for feature comparison and subsequent ,analysis calculation between different particles.

[0027] S202: Call the normalized feature parameter set, calculate the weights of multiple features based on the variance contribution, and calculate the product of multiple feature values ​​and weights, and perform weighted summation, using the formula: ; The weighted characteristic value of grain particles is calculated; in, represents the weighted eigenvalue of grain particles, Represents the first in the normalized feature parameter set eigenvalues, The variance contribution is calculated as feature weights, Represents the individual value of a certain category of features in the normalized feature parameter set, represents the mean of the category feature, The number of individuals representing the class characteristics, is the weight adjustment coefficient, which is used to balance the feature contribution; It is necessary to determine the weight of each feature. The weight calculation uses the variance contribution, that is, calculate the ratio of the variance of each feature value to the total variance. Suppose the sample data in the normalized feature parameter set is as shown in the following table: Table 2 Normalized characteristic parameter data table:

[0028] The designed variances are , then the weight calculation method is The weights are calculated as , then calculate the product of multiple eigenvalues ​​and weights and perform weighted summation. The calculation formula is: ; set up , for the characteristic value of a grain particle ,calculate: ; The results show that the weighted eigenvalues ​​of grain particles have been calculated, which are normalized and weighted according to the importance of different features and used to construct the eigenvector matrix, reflecting the overall characteristics of the grain particles in the selected feature space, which can be further used for pattern recognition or quality assessment.

[0029] S203: calling the weighted eigenvalues ​​of grain particles, constructing an eigenvector matrix, characterizing the core characteristic data of grain particles according to the calculated eigenvalues, and establishing a weighted eigenvector of grain particles.

[0030] It is necessary to construct an eigenvector matrix, where each column of the matrix represents the weighted eigenvalue of different samples. Suppose the weighted eigenvalue of the grain particle sample is as follows: ; Construct the eigenvector matrix: ; The results show that the eigenvector matrix has been successfully constructed, which represents the core characteristic data of grain particles and can be used for further analysis, such as clustering, classification or quality evaluation. By comparing the weighted eigenvalues ​​of different samples, automatic classification or grading decisions of grain particles can be achieved, enabling it to play a role in practical applications.

[0031] See also Figure 4, the specific steps for obtaining the grain particle spectral feature point set are: S301: Acquire spectral reflectance data of grain particles, extract local reflectance changes of near infrared and short-wave infrared spectra, calculate normalized spectral differences of multiple bands, calculate the mean, standard deviation and peak-to-valley ratio of the normalized spectral differences, and obtain normalized spectral difference characteristic parameters; First, it is necessary to measure the reflectivity of the grain surface under a fixed light source through spectral measurement equipment (such as near-infrared spectrometer), record its reflection intensity in the near-infrared and short-wave infrared ranges, and perform normalization processing on the data of different bands to enhance the comparability of spectral data of different grains. The normalization method adopts the maximum and minimum normalization method, and the calculation formula is: ; in, Represents the original spectral reflectance of a certain band, and are the minimum and maximum reflectance values ​​of all samples in the band, respectively, to ensure that all spectral reflectance values ​​are normalized to the [0,1] interval. The normalized data is stored in a matrix form, where each column represents the normalized spectral data of a specific band, and each row represents all band data of a single sample. Next, the normalized spectral difference of multiple bands is calculated, and the normalized spectral reflectance of adjacent bands is used for difference calculation, that is: ; This process is used to extract the changes in the local reflectance of grain particles in different bands, and then perform statistical analysis on the calculated normalized spectral difference to calculate its mean, standard deviation and peak-to-valley ratio. The mean is calculated as follows: ; The standard deviation is used to measure the fluctuation of spectral reflectance changes, and the calculation formula is: ; The peak-to-valley ratio is used to measure the fluctuation of spectral reflectance in different bands and is defined as the ratio of the maximum spectral reflectance to the minimum spectral reflectance: ; In practical applications, the calculation can be performed using the spectral data of different types of grain varieties. For example, 100 wheat samples are randomly selected, and the normalized spectral reflectances measured at the 4 bands of 950nm, 1000nm, 1050nm, and 1100nm are [0.85, 0.88, 0.83, 0.79] respectively. The normalized spectral difference is calculated as follows: ; The mean is: ; The standard deviation is calculated as: ; The peak-to-valley ratio is calculated as: ; Finally, the normalized spectral difference characteristic parameters of grain particles were obtained, with a mean of -0.02, a standard deviation of 0.035, and a peak-to-valley ratio of 1.11.

[0032] S302: Based on the normalized spectral difference characteristic parameters, the multi-spectral bands are partitioned and calculated, the key spectral regions are screened, the stability parameters of the spectral characteristics are extracted, and the spectral variation coefficient is established according to the reflectance changes and standard deviations of the multiple regions, using the formula: ; Obtain the spectrum variation coefficient of the multi-spectral region by calculation, select the band range with higher spectrum stability, and obtain the stable spectrum region parameters; in, represents the spectral variation coefficient, Representative The normalized spectral reflectance of each band, Represents the mean of the normalized spectral reflectance of all bands, represents the standard deviation of the spectral reflectance, represents the total number of spectral bands, Represents the maximum value of the normalized spectral reflectance of all bands; First, the multi-spectral band is divided into multiple intervals. The area to which the spectral data belongs is determined according to the band range. The boundary values ​​of different intervals are set, such as 900nm-1000nm, 1000nm-1100nm, 1100nm-1200nm, etc. The mean and standard deviation of the normalized spectral difference are calculated for each interval. The band area is screened according to the mean distribution, and the spectral variation coefficient is calculated. The calculation is as follows: ; in, For the The normalized spectral reflectance of each band, is the average normalized spectral reflectance of all bands, is the standard deviation of spectral reflectance, is the total number of spectral bands, is the maximum normalized spectral reflectance in all bands. Assuming that the normalized spectral reflectances of the bands 900nm, 1000nm, 1100nm, and 1200nm are [0.82, 0.85, 0.80, 0.78] respectively, the calculation is as follows: ; ; ; ; ; Final spectral variation coefficient , which is used to screen the wavelength range with higher spectral stability and obtain the parameters of stable spectral region.

[0033] S303: calling stable spectral region parameters, matching visible light band data, calculating the correlation between multi-band spectral changes and visible light data, screening spectral features with higher matching stability, and obtaining a spectral feature point set of grain particles.

[0034] First, we need to select the spectral reflectance data of grain particles in the visible light range (400nm-700nm), compare it with the spectral reflectance in the stable spectral region, and calculate the correlation between the two. The correlation calculation uses the Pearson correlation coefficient, and the calculation formula is as follows: ; in, represents the spectral reflectance data in the stable spectral region, Represents the spectral reflectance data of the visible light band, and They are and When calculating the correlation, we need to ensure that the number of data points is the same. Therefore, we first interpolate the two sets of data to unify the sampling points, using the linear interpolation method: ; in, represents the interpolated wavelength point, and are the starting and ending wavelengths of the data before interpolation, and are the spectral reflectance values ​​of the corresponding wavelengths, so as to obtain the matching data of the stable spectral region and the visible light data at the same wavelength, and then calculate the matching stability, which is defined as the ratio of the spectral correlation coefficient to the standard deviation: ; in, Represents the standard deviation of the spectral reflectance in the visible light band. The higher the matching stability of the spectral features, the better the To verify the calculation process, assume that the normalized spectral reflectance of a grain sample in the near infrared and short-wave infrared stable spectral regions (900nm, 1000nm, 1100nm, 1200nm) is [0.85, 0.88, 0.83, 0.79], and the normalized spectral reflectance in the visible light band (450nm, 550nm, 650nm) is [0.62, 0.68, 0.75]. The calculation steps are as follows: Calculate the mean: ; ; Calculate the standard deviation: ; ; Calculate the correlation coefficient : ; Calculate matching stability : ; For all spectral feature points, calculate the corresponding matching stability , set the stability threshold, e.g. As a criterion for high matching stability, the spectral feature points that meet the conditions are screened, and finally the spectral feature point set of the grain particles is obtained.

[0035] See also Figure 5 , the specific steps for obtaining the spectrum-texture joint feature matrix are: S401: calculating the local reflectivity rate of multiple grain particles at differentiated wavelengths based on the weighted feature vector of the grain particles and the spectral feature point set of the grain particles, performing numerical normalization processing on the local reflectivity rate of each grain particle, and generating a normalized local reflectivity rate; First, the local reflectivity rate of multiple grain particles at different wavelengths needs to be calculated. The specific method is as follows: a group of grain samples is set, and the reflectivity measurement value of each sample at different wavelengths is recorded as ,in Indicates the grain number, Indicates the wavelength number, for each grain particle , calculate its local reflectivity rate It is necessary to perform differential calculation based on the spectral feature point set of grain particles. Specifically, The reflectivity difference is calculated and divided by the interval between the two wavelengths, so that the calculation formula for the local reflectivity rate is: ; in is the wavelength, Represents the local reflectivity rate. In order to ensure the comparability of reflectivity rates between different grain samples, Perform numerical normalization, and the normalization adopts the maximum and minimum normalization method, that is: ; Assuming that the reflectance of a grain particle at 700nm, 710nm and 720nm is 0.45, 0.47 and 0.49 respectively, the local reflectance rate is calculated as: ; ; After normalization, assuming that the maximum and minimum values ​​range between 0.001 and 0.003, then: ; ; In this way, the normalized local reflectivity rate of all grain particles is calculated to obtain the normalized local reflectivity rate matrix .

[0036] S402: calling the normalized local reflectivity rate, calculating the local gradient change rate of multiple grain particles in the target band, analyzing the gradient change trend of the grain particles, and obtaining the gradient change rate matrix of the multiple grain particles by using the wavelength dimension difference calculation method; It is necessary to calculate the local gradient change rate of grain particles in the target band. The calculation of the gradient change rate is based on the normalized reflectivity rate difference between adjacent grain particles, that is: ; in, Represents the local gradient change rate of grain particles. If the normalized local reflectivity rate matrix of a grain particle is: ; The gradient change rate matrix is ​​calculated as follows: ; ; ; For the gradient change rate matrix of different wavelengths, the wavelength dimension difference calculation method can be used, that is, the gradient change of grain particles under different wavelengths is calculated, and the gradient change rate matrix corresponding to all wavelengths is recorded. .

[0037] S403: Based on the gradient change rate matrix, the spectral response of the texture information of the grain particles is calculated using the formula: ; The spectrum-texture composite features of multiple grain particles are obtained by operation, and matrix mapping is performed to establish a spectrum-texture joint feature matrix; in, represents the spectral-texture composite feature, Representative The normalized local reflectivity rate of each grain particle, Representative The local gradient change rate of each grain particle, represents the number of grain samples; formula: ; in, Represents the number of grain samples, Represents the spectral-texture composite feature, and the calculation process is as follows: Assume that the normalized local reflectance rate of a grain particle is: ; And the gradient change rate matrix is: ; The spectral-texture composite feature of each grain particle is calculated as follows: ; Finally, the spectral-texture composite features of multiple grain particles are matrix mapped to establish the spectral-texture joint feature matrix .

[0038] Table 3 Example of spectrum-texture composite feature calculation:

[0039] As shown in Table 3, the calculation results of the spectral-textural composite features of different grain particles are mapped into the matrix to form the spectral-texture joint feature matrix.

[0040] The results show that by calculating and normalizing the local reflectance rate and gradient change rate of grain particles, the spectral-texture joint feature matrix of grain particles can be obtained, so that the spectral characteristics and texture information of different grain varieties at different wavelengths can be comprehensively characterized, providing a quantitative analysis basis for grain classification or quality assessment.

[0041] See also Figure 6 ,The specific steps for obtaining the grain particle classification matching value are as follows: S501: constructing a classification feature library of grain samples based on the spectrum-texture joint feature matrix, calculating a feature vector of each grain sample, and storing it in a database to obtain a grain classification feature storage matrix; First, it is necessary to extract the spectral characteristics and texture characteristics of different grain varieties. To obtain the spectral characteristics, a visible light, near-infrared or short-wave infrared spectrometer can be used to scan the grain sample, obtain the spectral reflectance of different bands, and record the spectral values ​​corresponding to each band. For example, the band range is set to 400nm~1000nm, and the reflectance data is recorded every 10nm. The spectral characteristics of each grain sample can be expressed as a vector ,in is the number of bands, usually , that is, 60 spectral channels. On the other hand, for texture features, image processing algorithms such as gray-level co-occurrence matrix (GLCM) can be used to calculate the uniformity, contrast, directionality and other features of the grain surface. For example, the texture features in four directions of 0°, 45°, 90° and 135° are selected, and the energy, contrast, entropy and other parameters are calculated in each direction. The texture features can be expressed as ,in is the number of features, usually , and then concatenate the spectral feature vector with the texture feature vector to form a spectrum-texture joint feature matrix That is, each grain sample corresponds to a feature vector and is stored in the database. During the database storage process, in order to facilitate subsequent calculations, standardization can be used to normalize the feature values ​​according to the mean. For example, if the mean of a spectral feature is 0.35 and the standard deviation is 0.05, then the feature standardization value is Similarly, all features are standardized, and finally a grain classification feature storage matrix is ​​constructed. The matrix size is ,in is the total number of samples.

[0042] S502: Call the grain classification feature storage matrix, calculate the Euclidean distance between the test sample and the database sample, set the threshold standard between adjacent samples, and compare them to screen samples that meet the classification requirements. The formula is: ; Calculate the offset distance correction value, make offset judgment, and obtain the offset calculation benchmark; in, Represents the offset distance correction value, represents the eigenvalue of the test sample, represents the characteristic value of the database sample, is the feature dimension, represents the local eigenvalue of the test sample, represents the local eigenvalue of the database sample, is the number of local features; First, call the grain classification feature storage matrix to extract the standardized feature vectors of all samples from the database , let the feature vector of the test sample be , then calculate the Euclidean distance between the test sample and each database sample, the calculation formula is: ; in and Respectively represent the test sample and database sample in The characteristic value of the spectral channel, and Represent the first After calculating the distance, we need to set the threshold between adjacent samples. The threshold is usually determined based on the distribution characteristics of the training data. We can use the mean double standard deviation method. For example, we set the mean distance of all training samples to , the standard deviation is , then the threshold is set to , filter to meet Calculate the offset distance correction value of the filtered sample , the specific formula is as follows: ; For example, for a test sample, if the sum of squares of its spectral feature differences is 0.0125 and the average difference of its texture features is 0.025, then calculate : ; This result indicates that the offset correction value of this sample is less than the screening threshold Therefore, it can be considered that the spectral-texture characteristics of the test sample are relatively close to some samples in the database, meet the screening requirements, and can be used to further calculate the classification matching value.

[0043] S503: Call the offset calculation benchmark, calculate the classification matching value of the test sample, and comprehensively calculate the distance and feature difference of the matching samples in the database to obtain the classification matching value of the grain particles.

[0044] It is necessary to comprehensively match the distance and feature difference of samples in the database and set the matching weight , usually different weights are set for spectral features and texture features, for example , , calculate the matching value : ; in and are the Euclidean distances of spectral and texture features, respectively, is the maximum matching distance in the database, for example, , , , then calculate: ; ; The result shows that the matching value of the test sample is 0.58, indicating that it has a certain similarity with the best matching sample in the database. Although it is not a complete match, it can still be considered that the sample is relatively close to a certain type of grain variety in the database and can be used for grain classification after further screening.

[0045] Table 4 Example of grain sample characteristics:

[0046] As shown in Table 4, the grain sample feature matrix contains 60 spectral band values ​​and 12 texture feature values. The spectral features and texture features of each sample are standardized and used for classification matching calculation. The feature data will be used for subsequent Euclidean distance calculation and matching value evaluation to determine the grain variety category of the test sample.

[0047] The method further comprises: S6: Based on the classification matching values ​​of the grain particles, a classification decision is executed, the grain particles are classified into corresponding categories, and they are automatically stored or labeled.

[0048] Based on the classification matching value of grain particles, it is first necessary to collect multiple parameter information of grain particles, including particle size, shape, color, density, moisture content, surface smoothness, etc., obtain the length, width, and height data of grain particles through high-precision sensors, and calculate their volume. Use a high-resolution camera to capture images of grain particles, and perform color extraction and analysis on the images. After measuring the weight of the particles, the density is calculated. At the same time, the moisture content of grain particles is measured using near-infrared spectroscopy, and the smoothness of particles is detected using a surface reflection measurement device. All collected data need to be normalized so that their values ​​are mapped to the same numerical range for subsequent matching. After normalization, the classification matching value of each grain particle is calculated. The matching value is calculated based on the weighted sum of various parameters. Different weights are set. For example, the weights of grain size, color characteristics, density, moisture content, and surface smoothness are set to 0.3, 0.25, 0.2, 0.15, and 0.1, respectively. The contribution of each characteristic value to the final matching value is calculated proportionally. The basis for setting the weight is the influence of each parameter on grain quality and classification accuracy. The weight of grain size is set to 0.3 because it directly affects the processing performance and market demand of grain. For example, if corn grains are too small, it will affect the flour yield, while if they are too large, they will affect the flour yield. The weight of color feature is set to 0.25, because grain varieties are usually distinguished by color, such as wheat can be divided into red wheat and white wheat according to color, and color abnormalities may mean mildew or impurities mixed in. The weight of density is set to 0.2, which determines the stacking state of grain during storage. Low density may mean empty shells or insect infestation, and high density may contain more impurities or moisture. The weight of water content is set to 0.15, because too high water content can easily cause grain mildew, and too low water content will affect the storage period and taste. The weight of surface smoothness is set to 0.1, which is mainly used to reflect the processing of grain. Process and quality, such as the surface of rice is too rough, which may mean a high proportion of broken rice. After obtaining the matching value, it is compared with the set classification threshold. For example, when the matching value is greater than 0.8, it is judged as Class A grain particles. When the matching value is between 0.6 and 0.8, it is judged as Class B grain particles. When the matching value is between 0.4 and 0.6, it is judged as Class C grain particles. When the matching value is less than 0.4, it is judged as Class D grain particles. According to the classification results, the automatic control mechanical device performs corresponding operations to transport the grain particles to the corresponding storage area, or mark them in the database to store their classification information to ensure subsequent query and call.

[0049] A grain classification and recognition system based on image analysis, the grain classification and recognition system based on image analysis is used to execute the grain classification and recognition method based on image analysis, the system comprises: The image feature extraction module obtains grain particle image data, calculates the image grayscale histogram, calls the grayscale co-occurrence matrix to calculate the image texture density, calculates the particle edge features based on the gradient change rate, and uses sliding window scanning to obtain local feature parameters, including texture contrast, directional consistency, and particle roughness, to construct grain particle image feature parameters; The local feature calculation module calculates the contrast, directional consistency and roughness of multiple local features based on the grain particle image feature parameter set, normalizes the feature data, and uses the variance contribution to calculate the weighted feature vector of the grain particle to obtain the weighted feature vector of the grain particle; The spectral feature screening module obtains the spectral reflectance data of grain particles, calculates the local reflectance changes in the near-infrared and short-wave infrared regions, screens the key spectral features of grain particles based on the normalized spectral difference analysis mean, standard deviation and peak-to-valley ratio, calls the visible light reflectance data to calculate the matching stability, and obtains the spectral feature point set of grain particles; The feature matrix construction module calculates the local reflectance rate based on the weighted feature vector of grain particles and the spectral feature point set of grain particles, calls the local gradient change rate to calculate the spectral response of the grain particle texture information, and constructs the spectrum-texture joint feature matrix; The classification matching calculation module builds a grain classification feature library based on the spectrum-texture joint feature matrix, calculates the Euclidean distance between the test sample and the database sample, calls the local feature judgment offset, and obtains the grain particle classification matching value; The intelligent classification decision and adaptive optimization module executes classification decision based on the classification matching value of the grain particles, classifies the grain particles into corresponding categories, and automatically stores or labels them.

[0050] The above are only preferred embodiments of the present invention and are not intended to limit the present invention in other forms. Any technician familiar with the profession may use the technical contents disclosed above to change or modify them into equivalent embodiments with equivalent changes and apply them to other fields. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. A grain classification and recognition method based on image analysis, characterized in that: The following steps are involved: S1: Obtain grain particle image data, calculate grayscale histogram and gradient change rate, call grayscale co-occurrence matrix to extract grain particle texture density, and scan with sliding window to obtain local feature parameters of grain particles; S2: Based on the local characteristic parameters of the grain particles, the contrast, directional consistency, and roughness are calculated and normalized, and the variance contribution is called to calculate the weighted characteristic vector of the grain particles; S3: Obtain the spectral reflectance data of grain particles, calculate the changes in the local reflectance of near-infrared and short-wave infrared, call the normalized spectral difference to analyze the mean, standard deviation and peak-to-valley ratio, screen the key spectral features of grain particles, call the visible light data to determine the matching stability, and obtain the spectral feature point set of grain particles; S4: Based on the weighted feature vector of the grain particle and the spectral feature point set of the grain particle, the local reflectance rate is calculated, the spectral response of the grain particle texture information is analyzed by calling the local gradient change rate, and a spectrum-texture joint feature matrix is ​​established; S5: Based on the spectrum-texture joint feature matrix, a grain classification feature library is constructed, the Euclidean distance between the test sample and the database sample is calculated, the local feature judgment offset is called, and the grain particle classification matching value is obtained.

2. The method for grain classification and identification based on image analysis according to claim 1, characterized in that: The local feature parameters of the grain particles include grayscale histogram, gradient change rate, grayscale co-occurrence matrix texture density, and sliding window local features. The weighted feature vector of the grain particles includes contrast, directional consistency, roughness, and variance contribution. The spectral feature point set of the grain particles includes near-infrared local reflectivity change, short-wave infrared local reflectivity change, normalized spectral difference analysis mean, normalized spectral difference analysis standard deviation, normalized spectral difference analysis peak-to-valley ratio, and visible light data matching stability. The spectrum-texture joint feature matrix includes local reflectivity rate, local gradient change rate spectral response, and grain particle texture information spectral response. The grain classification feature library includes Euclidean distance, local feature judgment offset, and grain particle classification matching value.

3. The method for grain classification and identification based on image analysis according to claim 2 is characterized in that: The steps for obtaining the local characteristic parameters of the grain particles are specifically as follows: S101: obtaining grain particle image data, performing grayscale transformation on the image, calculating grayscale values ​​pixel by pixel, constructing a histogram according to the grayscale values ​​of multiple pixels, counting the number of differentiated grayscale pixels, performing normalization, and generating a grayscale histogram; S102: Based on the grayscale histogram, calculate the difference of grayscale values ​​of adjacent pixels, traverse the image area to count the mean of the difference, calculate the overall change trend after normalization, and generate the grayscale gradient change rate; S103: calling the gray gradient change rate, constructing a sliding window to scan the local area of ​​grain particles, calculating the gray co-occurrence matrix of the pixels in the window, and performing operations on the contrast, uniformity, and entropy value, using the formula: ; Obtain the texture density parameters of the local area by operation, calculate the density parameter distribution in all windows, and generate the local characteristic parameters of grain particles; in, represents the local characteristic parameters of grain particles, Represents the first The gray value of a pixel, Represents the window The gray level contrast of each pixel is Represents the window The gray level entropy value of each pixel is Represents the number of rows and columns of pixels in the window, Represents the total number of pixels in the window.

4. The method for grain classification and identification based on image analysis according to claim 3 is characterized in that: The steps for obtaining the weighted feature vector of the grain particles are specifically as follows: S201: Based on the local characteristic parameters of the grain particles, the contrast, directional consistency and roughness are calculated to obtain the contrast value, directional consistency measurement value and roughness coefficient of the grain particles, and at the same time, multiple characteristic values ​​are adjusted to the same numerical range to construct a normalized characteristic parameter set; S202: calling the normalized feature parameter set, calculating the weights of multiple features based on variance contribution, and calculating the product of multiple feature values ​​and weights, and performing weighted summation, using the formula: ; The weighted characteristic value of grain particles is calculated; in, represents the weighted eigenvalue of grain particles, Represents the first in the normalized feature parameter set eigenvalues, The variance contribution is calculated as feature weights, Represents the individual value of a certain category of features in the normalized feature parameter set, represents the mean of the category feature, The number of individuals representing the class characteristics, is the weight adjustment coefficient, which is used to balance the feature contribution; S203: calling the weighted eigenvalues ​​of the grain particles, constructing an eigenvector matrix, characterizing the core feature data of the grain particles according to the calculated eigenvalues, and establishing a weighted eigenvector of the grain particles.

5. The method for grain classification and identification based on image analysis according to claim 4 is characterized in that: The steps for obtaining the grain particle spectral feature point set are specifically as follows: S301: Acquire spectral reflectance data of grain particles, extract local reflectance changes of near infrared and short-wave infrared spectra, calculate normalized spectral differences of multiple bands, calculate the mean, standard deviation and peak-to-valley ratio of the normalized spectral differences, and obtain normalized spectral difference characteristic parameters; S302: Based on the normalized spectral difference characteristic parameters, perform partition calculation on the multi-spectral band, screen the key spectral region, extract the stability parameter of the spectral feature, and establish the spectral variation coefficient according to the reflectivity change and standard deviation of the multiple regions, using the formula: ; Obtain the spectrum variation coefficient of the multi-spectral region by calculation, select the band range with higher spectrum stability, and obtain the stable spectrum region parameters; in, represents the spectral variation coefficient, Representative The normalized spectral reflectance of each band, Represents the mean of the normalized spectral reflectance of all bands, represents the standard deviation of the spectral reflectance, represents the total number of spectral bands, Represents the maximum value of the normalized spectral reflectance of all bands; S303: calling the stable spectral region parameters, matching the visible light band data, calculating the correlation between the multi-band spectral changes and the visible light data, screening the spectral features with higher matching stability, and obtaining the grain particle spectral feature point set.

6. The method for grain classification and identification based on image analysis according to claim 5 is characterized in that: The steps for obtaining the spectrum-texture joint feature matrix are specifically as follows: S401: calculating the local reflectivity rate of multiple grain particles at differentiated wavelengths based on the weighted feature vector of the grain particles and the spectral feature point set of the grain particles, performing numerical normalization processing on the local reflectivity rate of each grain particle, and generating a normalized local reflectivity rate; S402: calling the normalized local reflectivity rate, calculating the local gradient change rate of multiple grain particles in the target band, analyzing the gradient change trend of the grain particles, and obtaining the gradient change rate matrix of the multiple grain particles by a wavelength dimension difference calculation method; S403: Based on the gradient change rate matrix, the texture information spectral response of the grain particles is calculated using the formula: ; The spectrum-texture composite features of multiple grain particles are obtained by calculation, and matrix mapping is performed to establish a spectrum-texture joint feature matrix; in, represents the spectral-texture composite feature, Representative The normalized local reflectivity rate of each grain particle, Representative The local gradient change rate of each grain particle, Represents the number of grain samples.

7. The method for grain classification and identification based on image analysis according to claim 6 is characterized in that: The steps for obtaining the grain particle classification matching value are specifically as follows: S501: constructing a classification feature library of grain samples based on the spectrum-texture joint feature matrix, calculating a feature vector of each grain sample, and storing the feature vector in a database to obtain a grain classification feature storage matrix; S502: calling the food classification feature storage matrix, calculating the Euclidean distance between the test sample and the database sample, setting the threshold standard between adjacent samples, and comparing them to screen samples that meet the classification requirements, using the formula: ; Calculate the offset distance correction value, make offset judgment, and obtain the offset calculation benchmark; in, Represents the offset distance correction value, represents the eigenvalue of the test sample, represents the characteristic value of the database sample, is the feature dimension, represents the local eigenvalue of the test sample, represents the local eigenvalue of the database sample, is the number of local features; S503: Calling the offset calculation benchmark, calculating the classification matching value of the test sample, and comprehensively considering the distance and feature difference of the matching samples in the database to calculate the classification matching value of the grain particles.

8. The method for grain classification and identification based on image analysis according to claim 7 is characterized in that: The method further comprises: S6: Based on the grain particle classification matching value, a classification decision is executed to classify the grain particles into corresponding categories, and the grain particles are automatically stored or labeled.

9. A grain classification and recognition system based on image analysis, characterized in that: According to the method for grain classification and identification based on image analysis according to any one of claims 1 to 8, the system comprises: The image feature extraction module obtains grain particle image data, calculates the image grayscale histogram, calls the grayscale co-occurrence matrix to calculate the image texture density, calculates the particle edge features based on the gradient change rate, and uses sliding window scanning to obtain local feature parameters, including texture contrast, directional consistency, and particle roughness, to construct grain particle image feature parameters; The local feature calculation module calculates the contrast, directional consistency and roughness of multiple local features based on the grain particle image feature parameter set, normalizes the feature data, and calculates the weighted feature vector of the grain particle by calling the variance contribution to obtain the weighted feature vector of the grain particle; The spectral feature screening module obtains the spectral reflectance data of grain particles, calculates the local reflectance changes in the near-infrared and short-wave infrared regions, screens the key spectral features of grain particles based on the normalized spectral difference analysis mean, standard deviation and peak-to-valley ratio, calls the visible light reflectance data to calculate the matching stability, and obtains the spectral feature point set of grain particles; The feature matrix construction module calculates the local reflectance rate based on the weighted feature vector of the grain particles and the spectral feature point set of the grain particles, calls the local gradient change rate to calculate the spectral response of the grain particle texture information, and constructs a spectrum-texture joint feature matrix; The classification matching calculation module constructs a grain classification feature library based on the spectrum-texture joint feature matrix, calculates the Euclidean distance between the test sample and the database sample, calls the local feature judgment offset, and obtains the grain particle classification matching value; The intelligent classification decision and adaptive optimization module executes classification decision based on the classification matching value of the grain particles, classifies the grain particles into corresponding categories, and automatically stores or labels them.

Citation Information

Cited By

  • Pineapple quality grading method and system based on image processing and medium

    CN120490117A

  • Intraoperative risk assessment system based on multi-modal operation image fusion

    CN120510482A

  • Method and system for detecting impurities on surface of processed aluminum plate

    CN120747629A

  • Liquid medicine foreign matter detection method and system based on machine vision

    CN120877260A

  • Big data-based geographic surveying and mapping image classification processing system and method

    CN121259463A