Intelligent agricultural product sorting method based on physical feature iterative optimization and related device
By extracting the physical characteristics of Chinese medicinal materials and complex agricultural products through multispectral imaging and optimization algorithms, the problems of high misjudgment rate, lack of interpretability and internal quality quantification in existing technologies have been solved. A high-precision and interpretable sorting method and system has been realized, which can adapt to the rapid production change of different batches of agricultural products.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GANGZHENG (HAINAN) TECHNOLOGY CO LTD
- Filing Date
- 2026-01-13
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies for sorting Chinese medicinal materials and complex agricultural products suffer from problems such as high misjudgment rate, lack of interpretability, inability to quantify internal quality, and poor adaptability. In particular, it is difficult to achieve high-precision sorting under morphological interference.
A physical feature-based iterative optimization method is adopted. Surface reflection images and near-infrared transmission images are acquired through multispectral imaging to extract physical features such as maturity, color, oiliness, morphological integrity, and internal structure. The optimal decision threshold is found iteratively using optimization algorithms, and sorting is performed in combination with encoder signals and delay compensation mechanisms.
It achieves high-precision sorting under complex conditions, provides interpretable sorting results, facilitates quality traceability, improves sorting accuracy and equipment uptime, and meets the needs of rapid production changeover.
Smart Images

Figure CN121945451A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of agricultural product sorting technology, and in particular to an intelligent sorting method and related apparatus for agricultural products based on iterative optimization of physical characteristics. Background Technology
[0002] As non-standard biological products, the post-harvest grading of Chinese medicinal herbs (such as angelica, dried tangerine peel, and astragalus) and agricultural products like tobacco is a crucial link between primary and advanced processing. For a long time, this step has relied primarily on manual sensory evaluation (visual inspection and tactile examination) and sorting based on qualitative descriptions in national standards (such as high oil content, heavy weight, and pure color). However, manual sorting suffers from problems such as high subjectivity, low efficiency, difficulty in recruiting workers, and inconsistent application of standards.
[0003] With the development of industry, automated sorting technology based on machine vision has been gradually applied to this field. At present, the mainstream technical routes are mainly divided into two categories: (1) Traditional machine vision technology: based on simple 2D projected shape and RGB color threshold for judgment. For example, the size is calculated by statistically analyzing the pixel area, or the agricultural products with different colors are removed by setting a color range. (2) Deep learning technology: adopts an end-to-end convolutional neural network (CNN) model, which is trained by a large number of labeled images and directly outputs the grading results.
[0004] While existing technologies have achieved success in the inspection of rigid objects such as industrial parts, the following significant shortcomings still exist in the sorting of Chinese medicinal materials and complex agricultural products: (1) High misjudgment rate due to morphological interference: After drying and mechanical unpacking, Chinese medicinal herbs and freshly roasted tobacco leaves often exhibit severe natural curling, wrinkling, folding, and even twisting into rope-like shapes. When processing such agricultural products, traditional 2D vision algorithms are prone to misidentifying the dark shadow areas (high contrast) caused by wrinkling as mold, black spots, or impurities by simple color thresholding algorithms. At the same time, curling significantly reduces the projected area of agricultural products on two-dimensional images, rendering size measurements based on projected area completely ineffective and failing to accurately reflect the integrity of the agricultural products.
[0005] (2) Black-box models lack interpretability and stability: Mainstream end-to-end deep learning models operate on a black-box mechanism, directly mapping images to results without intermediate physical logic support. When sorting errors occur (such as downgrading high-grade agricultural products), no specific physical basis can be provided (e.g., whether it's due to color deviation or rough texture), making quality traceability difficult. Furthermore, deep learning models are highly dependent on training data, and are prone to overfitting when faced with the varied forms of non-standard agricultural products. The robustness and stability of these systems struggle to meet the stringent requirements of continuous industrial production.
[0006] (3) Lack of effective means to quantify internal quality: Agricultural product grading standards often include indicators that go beyond the surface, such as oiliness, density / thickness, and structural looseness. Relying solely on RGB surface imaging technology cannot penetrate the surface of agricultural products to obtain internal information. For example, it cannot distinguish inferior medicinal materials that look similar but are hollow or lack density, nor can it accurately convert the tactile perception of oiliness into a visual quantitative indicator, resulting in sorting accuracy remaining at the primary level of appearance screening.
[0007] (4) Long production changeover and debugging cycle, poor adaptability: Agricultural products have highly non-standard attributes, with significant differences in characteristics (color, size, moisture content) between products from different origins, years, and even batches. If traditional algorithms are used, engineers need to be on-site for weeks, manually adjusting dozens of threshold parameters repeatedly based on experience, which is extremely inefficient and makes it difficult to find the globally optimal solution. If deep learning is used, massive amounts of data often need to be collected again for new batches of agricultural products, and the data needs to be labeled and trained for a long time, which cannot meet the production line's needs for rapid production changeover and immediate response. Summary of the Invention
[0008] The purpose of this invention is to overcome the problems of the prior art and to provide an intelligent sorting method and related device for agricultural products based on iterative optimization of physical features.
[0009] The objective of this invention is achieved through the following technical solution: an intelligent sorting method for agricultural products based on iterative optimization of physical features, comprising the following steps: Collect surface reflectance and near-infrared transmission images of agricultural products to be sorted; The surface reflection image is represented as the product of the illumination component and the reflection component, and the low-frequency illumination component, which represents macroscopic shadows, is suppressed, while the high-frequency reflection component, which represents surface texture details, is enhanced. Physical feature vectors are extracted from surface reflection images and near-infrared transmission images. The physical features include at least one of maturity and color, oiliness and texture, morphological integrity and damage, identity and internal structure. Based on the pre-collected sample images and their corresponding grade labels, physical feature vectors of all sample images are extracted to construct a feature matrix. Using an optimization algorithm, with the comprehensive performance of the sorting results as the optimization objective, an iterative search is performed on the feature matrix to obtain a set of optimal physical feature decision threshold parameters that optimize the objective. Based on the optimal combination of physical feature decision threshold parameters, feature extraction and decision are performed on real-time acquired agricultural product images, and the execution mechanism is controlled to complete the sorting action based on encoder signals and delay compensation mechanisms.
[0010] In one example, the acquisition of surface reflectance images and near-infrared transmission images of the agricultural products to be sorted includes: The surface reflection images of the agricultural products to be sorted are collected in conjunction with a diffuse dome light source located above the conveyor belt. Near-infrared transmission images of agricultural products to be sorted are collected using a linear infrared light source located below the gap in the conveyor belt. Two image acquisition devices are synchronously triggered based on the same encoder signal, enabling pixel-level spatial registration of the surface reflection image and the near-infrared transmission image.
[0011] In one example, representing the surface reflection image as a product of an illumination component and a reflection component, and suppressing the low-frequency illumination component representing macroscopic shadows while enhancing the high-frequency reflection component representing surface texture details, includes: The pixel values of the surface reflection image are logarithmically transformed to obtain the logarithmic domain image; The logarithmic image is subjected to Fourier transform to obtain the frequency domain image, and the frequency domain image is subjected to Gaussian high-pass filtering to obtain the filtered frequency domain data. The frequency domain data is processed by inverse Fourier transform and exponential transform to obtain the preprocessed surface reflection image.
[0012] In one example, the extraction of physical feature vectors from the surface reflection image and the near-infrared transmission image includes: The surface reflection image is converted to the LAB color space, and the pixel variance of its red-green and yellow-blue channels is calculated to quantify maturity and color index; and / or, Calculate the gray-level co-occurrence matrix of the surface reflection image, and extract the energy and contrast values of the gray-level co-occurrence matrix to quantify the oiliness and texture indicators; and / or, Calculate the solidity of agricultural product outlines in surface reflection images. Solidity is the ratio of outline area to outline convex hull area, used to quantify morphological integrity and damage indices; and / or, The mean and variance of optical density in near-infrared transmission images are calculated to quantify identity and internal structure indicators.
[0013] In one example, the optimization algorithm, with the overall performance of the sorting results as the optimization objective, iteratively searches on the feature matrix to obtain a set of optimal physical feature decision threshold parameters that maximize the optimization objective, including: A genetic algorithm is used for optimization. The optimal combination of physical feature decision threshold parameters is encoded into individuals in the genetic algorithm, and a fitness function is defined as the optimization objective. The fitness function is a weighted sum of sorting accuracy and false rejection rate.
[0014] In one example, controlling the actuator to complete the sorting action based on the encoder signal and delay compensation mechanism includes: Establish a virtual queue that is synchronously mapped to the physical location of the conveyor belt; When an agricultural product is determined to be defective, the corresponding rejection flag is written to the corresponding position in the virtual queue according to the current encoder value. As the conveyor belt runs and the encoder count increases, the position of the rejection flag is moved synchronously in the virtual queue. Based on the encoder value corresponding to the real-time logical position of the rejection flag in the virtual queue, the fixed distance from the imaging position to the actuator, the mechanical delay time of the actuator, and the real-time speed of the conveyor belt, the compensated trigger encoder value is calculated. When the real-time encoder value reaches the trigger encoder value, the actuator is triggered to take action.
[0015] It should be further noted that the technical features corresponding to the above examples can be combined or replaced to form new technical solutions.
[0016] The present invention also includes a computer program product comprising a computer program that, when executed by a processor, implements the steps of the intelligent sorting method for agricultural products based on iterative optimization of physical features formed by any or a combination of the above examples.
[0017] The present invention also includes a storage medium storing computer instructions, which, when executed, perform the steps of the intelligent sorting method for agricultural products based on iterative optimization of physical features formed by any or more of the above examples.
[0018] This invention also includes an intelligent sorting system for agricultural products based on iterative optimization of physical features, the system comprising: The multispectral imaging module is used to acquire surface reflection images and near-infrared transmission images of agricultural products to be sorted; The agricultural product conveying module is used to transport agricultural products, allowing them to pass sequentially through the imaging station of the multispectral imaging module. The processing and control module, connected to the multispectral imaging module, is used to: represent the surface reflection image as the product of the illumination component and the reflection component, suppress the low-frequency illumination component representing macroscopic shadows, and enhance the high-frequency reflection component representing surface texture details; extract physical feature vectors from the surface reflection image and near-infrared transmission image, where physical features include at least one of maturity and color, oiliness and texture, morphological integrity and damage, identity and internal structure; based on pre-acquired sample images and their corresponding grade labels, extract the physical feature vectors of all sample images to construct a feature matrix; use an optimization algorithm to iteratively search the feature matrix with the comprehensive performance of the sorting results as the optimization objective, to obtain a set of optimal physical feature decision threshold parameter combinations that optimize the objective; perform feature extraction and decision-making on the real-time acquired agricultural product images according to the optimal physical feature decision threshold parameter combinations, and control the actuator to complete the sorting action according to the encoder signal and delay compensation mechanism; The pneumatic actuator module is connected to the real-time processing and control module and is used to execute sorting actions according to the sorting control commands from the processing and control module.
[0019] In one example, the multispectral imaging module includes a main camera, an auxiliary camera, a diffuse dome light source, and a linear infrared light source; The main camera, in conjunction with a diffuse dome light source positioned above the conveyor belt, captures surface reflection images of the agricultural products to be sorted. The auxiliary camera, in conjunction with a linear infrared light source positioned below the gap in the conveyor belt, acquires near-infrared transmission images of the agricultural products to be sorted.
[0020] In one example, the pneumatic actuator module includes multiple high-frequency solenoid valves and nozzles arranged along the conveyor belt. The high-frequency solenoid valves switch on and off according to the sorting control command of the processing and control module, and the nozzles spray air to complete the sorting action.
[0021] It should be further noted that the technical features corresponding to the above system examples can be combined or replaced to form new technical solutions.
[0022] Compared with the prior art, the beneficial effects of the present invention are: 1. In one example, by separating the illumination component (shadow) and reflection component (texture) of the surface reflection image, the interference of dark shadows caused by wrinkling is suppressed in a targeted manner, preventing them from being misjudged as black spots or mold. This achieves high sorting accuracy under complex morphological interference, significantly reduces the false rejection rate of irregularly shaped agricultural products, ensures stability when processing highly non-standard agricultural products, and improves the yield and finished product yield. By extracting the physical feature vector of the image, the interpretability of the sorting results is realized, facilitating quality traceability. A composite imaging optical path design of visible light reflection and near-infrared transmission is adopted. Based on near-infrared transmission images, the internal quality of agricultural products can be accurately quantified, realizing a leap from appearance sorting to deep-dimensional quality sorting, significantly improving the homogenization level of the final product, and achieving non-destructive testing of the internal quality of agricultural products. By constructing a feature matrix and using optimization algorithms for iterative optimization, the optimal physical feature judgment threshold parameters suitable for the current new batch of agricultural products can be quickly and automatically searched, greatly reducing the reliance on highly skilled commissioning engineers, realizing rapid production changeover and flexible manufacturing of the production line, and greatly improving the equipment utilization rate.
[0023] 2. In one example, the use of a high color rendering index LED diffuse dome light source can maximize the illumination of the concave parts of the wrinkled agricultural products and reduce shadow occlusion; the use of a high-intensity linear infrared light source facilitates the acquisition of high-quality near-infrared transmission images; the synchronous triggering of the two image acquisition devices can ensure that each row of surface reflection images and the Jin Hongwei transmission image are strictly aligned in physical position (pixel-level registration), which facilitates subsequent multispectral data fusion.
[0024] 3. In one example, homomorphic filtering is used to separate the illumination component and the reflection component, and Gaussian high-pass filtering is used to eliminate the black shadows caused by wrinkling. Similarly, the texture features of real defects such as mold and black spots are enhanced to provide clean data for subsequent processing.
[0025] 4. In one example, a feature system with clear physical meaning was constructed, including LAB color difference variance, texture energy of gray-level co-occurrence matrix, and near-infrared transmitted light density. This ensures that the grading results of each agricultural product have accurate data support (for example, an agricultural product is downgraded because "texture energy < 0.15" means insufficient oil content), which greatly facilitates quality control and process traceability and meets the requirements of industrial production for transparency of quality data.
[0026] 5. In one example, a virtual shift register technology based on encoder pulse counting was used, and a trigger compensation algorithm incorporating mechanical delay and real-time belt speed variables was introduced to achieve millimeter-level tracking accuracy. Even during belt speed instability or acceleration / deceleration, the air valve can accurately hit the center of gravity of the agricultural products, effectively preventing the mis-rejection of good products or the omission of defective products, and ensuring the sorting purity under high-throughput production. Attached Figure Description
[0027] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. The accompanying drawings are provided to provide a further understanding of the present application and constitute a part of the present application. The same reference numerals are used in these drawings to denote the same or similar parts. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application.
[0028] Figure 1 This is a flowchart illustrating a method provided as an example of the present invention. Detailed Implementation
[0029] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0030] Furthermore, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0031] In one example, such as Figure 1 As shown, an intelligent sorting method for agricultural products based on iterative optimization of physical features is proposed. This method includes the following steps: S1: Collect surface reflection images and near-infrared transmission images of the agricultural products to be sorted.
[0032] In step S1, when the agricultural products pass through the imaging area with the conveyor belt, RGB surface reflection images and NIR transmission images of the agricultural products to be sorted are collected. This breaks through the limitation of traditional single RGB surface imaging technology that cannot perceive the internal properties of agricultural products, and solves the problem that the products may appear normal to the naked eye but have a loose internal structure, insufficient thickness, or hidden mold.
[0033] S2: Represent the surface reflection image as the product of the illumination component and the reflection component, and suppress the low-frequency illumination component that represents macroscopic shadows, while enhancing the high-frequency reflection component that represents surface texture details.
[0034] In step S2, because the Chinese medicinal materials are severely curled and shrunken due to dehydration and drying, high-contrast shadow areas appear on the image. Traditional algorithms are prone to misjudging these as discoloration or mold. To solve this problem, the surface reflection image is preprocessed, specifically by suppressing the low-frequency illumination component that represents macroscopic shadows, thereby eliminating uneven illumination (high-contrast interference), effectively removing the black shadows caused by shrinkage, and preserving material details.
[0035] S3: Extract physical feature vectors from surface reflection images and near-infrared transmission images. Physical features include at least one of maturity and color, oiliness and texture, morphological integrity and damage, identity and internal structure.
[0036] In step S3, the end-to-end black-box model is abandoned, and an interpretable physical feature vector with one or more dimensions is constructed based on industry standards. This physical feature vector is used to quantify the sensory and physical quality indicators of agricultural products. By extracting the physical feature vector, the problems of subjective abstraction and difficulty in quantification of traditional manual grading standards (such as sufficient oil content and heavy body weight) are solved, as well as the difficulties in interpreting the sorting results of deep learning models and in locating the causes of errors are addressed.
[0037] S4: Based on the pre-collected sample images and the corresponding grade labels of the sample images, extract the physical feature vectors of all sample images and then construct a feature matrix; using an optimization algorithm, with the comprehensive performance of the sorting results as the optimization objective, iteratively search on the feature matrix to obtain a set of optimal physical feature decision threshold parameter combinations that make the optimization objective optimal.
[0038] In step S4, the optimal judgment threshold (optimal physical feature judgment threshold) for each feature is difficult to determine manually for different batches of agricultural products. This step constructs a feature matrix and uses an optimization algorithm for iterative optimization, which can obtain the optimal physical feature judgment threshold parameters that are suitable for the current new batch of agricultural products in a very short time. This solves the industry problem that agricultural products have large fluctuations in characteristics due to differences in place of origin, season, and batch, and that traditional algorithms require manual on-site debugging for several weeks and deep learning requires retraining the model for a long time.
[0039] S5: Based on the optimal combination of physical feature judgment threshold parameters, feature extraction and judgment are performed on the real-time acquired agricultural product images, and the actuator is controlled to complete the sorting action according to the encoder signal and delay compensation mechanism.
[0040] In this step, the use of virtual shift registers and speed compensation ensures accurate rejection in high-speed sorting, solving the problem of large rejection position deviation and low hit rate caused by the simple time control method in high-speed (e.g., 3m / s) conveying environments where the speed may fluctuate.
[0041] In one example, surface reflectance images and near-infrared transmission images of the agricultural products to be sorted are acquired, including: The surface reflection images of the agricultural products to be sorted are collected using a diffuse dome light source positioned above the conveyor belt. ; Near-infrared transmission images of agricultural products to be sorted are acquired using a linear infrared light source positioned below the gap in the conveyor belt. ; Because the two image acquisition devices have a fixed deviation, delay matching is performed based on encoder counts to determine the pixel coordinates of the surface reflection image. Pixel coordinates of near-infrared transmission map By corresponding to the same physical coordinate point, pixel-level registration is achieved. At this point, the coordinates of each pixel in the two images are... It corresponds to a unique physical location on the transmission belt.
[0042] In one example, the surface reflection image is represented as the product of the illumination component and the reflection component, and the low-frequency illumination component, which represents macroscopic shadows, is suppressed while the high-frequency reflection component, which represents surface texture details, is enhanced, including: S21: Perform a logarithmic transformation on the pixel values of the surface reflection image to obtain a logarithmic domain image.
[0043] The physical model for the anti-wrinkle preprocessing of the surface reflection image in step S2 is as follows: Based on the principles of optical imaging, the acquired surface reflection image It can be represented as the irradiation component. With reflection component The product of: ; in, Represents the distribution of light intensity (low frequency, corresponding to macroscopic shadows and wrinkled dark areas); Represents the reflectivity of an object's surface (high frequency, corresponding to the realistic texture details of agricultural products).
[0044] At this point, step S21, the logarithmic transformation, converts the multiplicative relationship into an additive relationship for linear filtering. The calculation expression is as follows: ; in, Represents a logarithmic field image.
[0045] S22: Perform Fourier transform on the logarithmic domain image to obtain the frequency domain image. A Gaussian high-pass filter is used. The frequency domain image is filtered to obtain the filtered frequency domain data. : ; The filter transfer function is set as follows: in, The cutoff frequency; This represents a constant term. It sets the low-frequency irradiation component. To attenuate low frequencies (eliminate shadows); set high-frequency reflection components. To enhance high frequencies (highlight texture).
[0046] S23: Perform inverse Fourier transform and exponential transform on the frequency domain data to obtain the surface reflection image after preprocessing, i.e., removing shadows. .
[0047] This example uses anti-wrinkle pretreatment to smooth out macroscopic light and dark differences caused by curling, while retaining high-frequency features such as mold spots and black spots on the surface, thereby avoiding the misjudgment of shadows as impurities.
[0048] In one example, physical feature vectors are extracted from surface reflection images and near-infrared transmission images. The preferred features extracted are maturity and color indices, oiliness and texture indices, morphological integrity and damage indices, and the mean and variance of optical density. The specific feature vector extraction method is as follows: (1) Convert the surface reflection image to the LAB color space and calculate the pixel variance of its red-green channel and yellow-blue channel to quantify maturity and color index; High-quality, mature agricultural products (such as grade B01) have a uniform color distribution (extremely low variance), while unripe (greenish) or inferior agricultural products have mottled colors (high variance). Therefore, this application converts the surface reflection image to the CIELAB color space and calculates only within the mask area. Channel (red-green) and Pixel variance of the channel (yellow-blue) and The quantification formula is: in, This indicator represents maturity and color, and is not sensitive to changes in the absolute value of light intensity, focusing instead on the uniformity of color. For the image in the CIELAB color space Pixel value variance of the channel Weighting coefficients; For the image in the CIELAB color space Pixel value variance of the channel Weighting coefficients; The value represents variance. The smaller the value, the higher the color consistency (such as the golden yellow of high-quality tangerine peel), indicating good maturity. A large variance value represents a messy color (not green and yellow at the same time), indicating that it is not ripe or has deteriorated. Indicates the number of agricultural product samples; Indicates the first Each pixel channel value; This represents the average pixel value.
[0049] (2) Calculate the gray-level co-occurrence matrix of the surface reflection image, and extract the energy value and contrast value of the gray-level co-occurrence matrix to quantify the oiliness and texture index; Oily medicinal materials have dense surface cells, resulting in a delicate and uniform texture; scorched medicinal materials have a rough surface. Therefore, this application uses gray-scale co-occurrence matrix (GLCM) to quantify this microscopic tactile feature.
[0050] Specifically, the GLCM matrix of the image is calculated, and two key scalars are extracted: a) Energy: , Indicates the position of the gray-level co-occurrence matrix. The normalized value. Energy value. It reflects the uniformity of the texture. Herbs with sufficient oil content have dense cells on the surface, fine texture, and high energy value; scorched herbs have rough surfaces and low energy value.
[0051] b) Contrast ratio: Contrast The higher you go, the deeper the ravines become (rough / scorched).
[0052] Furthermore, based on rotation invariance, the calculation The GLCM features in four directions are averaged to accommodate the random posture of agricultural products on the conveyor belt.
[0053] (3) Calculate the solidity of the agricultural product outline in the surface reflection image. The solidity is the ratio of the outline area to the outline convex hull area, in order to quantify the morphological integrity and damage index. Simple area measurement cannot distinguish between natural curling and physical damage. This application introduces solidity to quantify morphological integrity and damage.
[0054] Specifically, the Sklansky algorithm is used to calculate the convex hull of the agricultural product contour, and then the contour area is calculated. Area of the convex hull The ratio is used to calculate the solidity. : For natural curling, although the projected area is reduced, the contour depression is less, and the difference between the convex hull area and the contour area is not significant, that is, the Solidity value remains high (usually >0.90); for physical defects / insect damage, there are deep depressions at the edges, which leads to a significant decrease in the Solidity value (e.g., <0.85).
[0055] The convex hull solidity operator can accurately distinguish between natural curling (few contour depressions, high solidity) and physical defects (deep contour depressions, low solidity), overcoming the complete failure of traditional area measurement methods when dealing with curled agricultural products. By setting a solidity threshold, it can distinguish between natural shapes and physical defects, thereby accurately identifying defective products without mistakenly damaging good curled products.
[0056] (4) Calculate the mean and variance of optical density in near-infrared transmission images to quantify identity and internal structure indicators.
[0057] Identity refers to a physical quality indicator characterizing the thickness and density of agricultural products, which is quantified by calculating the average optical density of near-infrared transmission images. Utilizing the Beer-Lambert Law, near-infrared light has strong penetrating power, and the intensity of transmitted light decreases exponentially with the density of the material.
[0058] Specifically, the optical density (OD) is calculated pixel by pixel: in, Background light intensity (average value of unobstructed area); This represents the intensity of transmitted light. Mean OD corresponds to body / thickness; a higher mean OD indicates that more infrared light is absorbed, suggesting that the agricultural product is thicker or has a higher internal density (heavier body); Var OD corresponds to structure; a large variance indicates that the internal structure is loose or uneven in thickness.
[0059] In one example, an optimization algorithm is used to iteratively search the feature matrix, with the overall performance of the sorting results as the optimization objective, to obtain a set of optimal physical feature decision threshold parameter combinations that maximize the optimization objective. These combinations include: A genetic algorithm is used for optimization. The optimal combination of physical feature decision threshold parameters is encoded into individuals in the genetic algorithm, and a fitness function is defined as the optimization objective. The fitness function is a weighted sum of sorting accuracy and false rejection rate.
[0060] Specifically, a small number (e.g., 50-100) of typical good and defective product sample images are collected, and all the aforementioned physical features of each sample are automatically extracted to construct a... 3D feature matrix ( For the sample size, (As a feature dimension), and accompanied by manually labeled ground truth values. The set of discrimination thresholds for all features is defined as an individual (chromosome). , These are thresholds for maturity and color, oiliness and texture, morphological integrity and damage, and identity and internal structure. Further, a fitness function is constructed: in, Indicates accuracy; Indicates the false rejection rate; , These are the weighting coefficients for accuracy and false rejection rate, respectively. Fitness function. The goal is to find the parameter combination with the highest accuracy and the lowest false rejection rate. In computer memory, logical operations based on genetic algorithms are performed on the feature matrix (only the numerical matrix is processed without reprocessing the image), performing selection, crossover, and mutation operations to generate new individuals. After multiple iterations (taking about 1-2 hours), simulating tens of thousands of sorting operations, the system finally converges and outputs the globally optimal threshold parameter formula, that is, the best combination of physical feature decision threshold parameters.
[0061] Preferably, the above-mentioned matrix-based iterative optimization is implemented through offline processing.
[0062] In one example, the actuator is controlled to complete the sorting action based on encoder signals and a delay compensation mechanism, including: S51: Establish a virtual queue that is synchronously mapped to the physical location of the conveyor belt.
[0063] In step S51, a FIFO queue is established in memory. Each storage unit of the FIFO queue corresponds to a small physical distance on the belt (e.g., 1mm, corresponding to the encoder). (One pulse).
[0064] S52: When an agricultural product is determined to be defective, the corresponding rejection flag is written to the corresponding position in the virtual queue according to the current encoder value. As the conveyor belt runs and the encoder count increases, the position of the rejection flag is moved synchronously in the virtual queue.
[0065] In step S52, when an agricultural product is determined to be defective, the defective product ID is written to the queue position corresponding to the current encoder count value. As the belt runs, the encoder count increases, and the ID is synchronously shifted in the virtual queue, so that the logical position of the rejection mark in the queue corresponds to the estimated physical position of the agricultural product on the conveyor belt in real time.
[0066] S53: Calculate the compensated trigger encoder value based on the encoder value corresponding to the real-time logical position of the rejection flag in the virtual queue, the fixed distance from the imaging position to the actuator, the mechanical delay time of the actuator, and the real-time speed of the conveyor belt.
[0067] In step S53, the number of pulses required for triggering is first calculated: ; in, This indicates the number of pulses required to trigger the signal, i.e., the total number of encoder pulses that ultimately need to be emitted when the trigger signal is actually sent. This represents the current pulse count, the total pulse count recorded by the encoder at the moment when the agricultural product is photographed and sorted. This indicates a fixed distance from the imaging position to the actuator; The compensation amount is expressed as follows: Due to the mechanical opening delay of the actuator and the potential fluctuation in the conveyor belt speed, it must be triggered in advance. The expression for calculating the number of pulses required to trigger in advance to compensate for the system delay is: in, This indicates the mechanical delay time of the actuator, such as the mechanical response time of a pneumatic valve (a constant, approximately 10ms). It indicates the real-time speed of the conveyor belt (calculated in real time by the encoder frequency, solving the problem of speed fluctuation). This indicates the pulse resolution.
[0068] S54: When the real-time encoder value reaches the trigger encoder value, the actuator is triggered. If the actuator is a solenoid valve, the solenoid valve is immediately driven to open, and compressed air is sprayed out. The agricultural product is blown away from the center of the nozzle at the moment it reaches the center of the nozzle, accurately hitting the center of gravity of the agricultural product.
[0069] Combining the above examples, a preferred embodiment of the present invention is obtained, the method comprising the following steps: S10: Image Acquisition and Registration: The diffuse reflection dome light source located above the conveyor belt is used to acquire surface reflection images of the agricultural products to be sorted, while the linear infrared light source located below the gap of the conveyor belt is used to acquire near-infrared transmission images of the agricultural products to be sorted; the two image acquisition devices are synchronously triggered according to the same encoder signal to perform pixel-level spatial registration between the surface reflection image and the near-infrared transmission image.
[0070] S20: Anti-wrinkle preprocessing: Represents the surface reflection image as the product of the illumination component and the reflection component, and suppresses the low-frequency illumination component that represents macroscopic shadows, while enhancing the high-frequency reflection component that represents surface texture details. S30: White box physical feature extraction: Extract physical feature vectors from surface reflection images and near-infrared transmission images. Physical features include maturity and color, oiliness and texture, morphological integrity and damage, identity and internal structure. S40: Matrix-based iterative optimization: Based on the pre-collected sample images and the corresponding grade labels of the sample images, extract the physical feature vectors of all sample images and then construct a feature matrix; using a genetic algorithm, with the comprehensive performance of the sorting results as the optimization objective, iteratively search on the feature matrix to obtain a set of optimal physical feature decision threshold parameter combinations that make the optimization objective optimal. S50: Online sorting and control: Based on the optimal combination of physical feature judgment threshold parameters, it extracts and judges features from real-time acquired agricultural product images, and controls the actuator to complete the sorting action based on encoder signals and delay compensation mechanisms.
[0071] This invention provides an intelligent sorting method for Chinese medicinal materials based on physical feature quantification and matrix iterative optimization, which has the following technical advantages: (1) Addressing the issues of shadow interference and size distortion under complex morphology: Existing technologies cause shadow misjudgment and area measurement failure due to the curling and wrinkling of agricultural products. This invention effectively eliminates shadow interference caused by macroscopic morphology by introducing homomorphic filtering anti-wrinkling algorithm and convex hull geometric analysis (ConvexHull), and accurately distinguishes between natural curling and physical damage by using solidity characteristics, thereby improving the robustness of sorting.
[0072] (2) Solve the problem of unexplainable sorting logic and difficulty in detecting internal quality: Black box AI models cannot explain the grading basis and can only detect surface defects. This invention adopts a white box physical feature quantification route to transform qualitative industry standards into explicit mathematical operators (such as using GLCM to quantify "oily feel" and using NIR transmitted light density to quantify "identity / density"), thereby realizing full traceability of grading logic and accurate insight into internal quality.
[0073] (3) Solve the problem of difficulty and long cycle of production change and debugging of multiple batches of non-standard agricultural products: Traditional manual parameter adjustment is slow and deep learning retraining cycle is long. This invention introduces a matrix iterative optimization processing method. The high-dimensional feature matrix is automatically optimized by offline genetic algorithm. It can automatically generate the best parameter formula for the current batch of agricultural products in a very short time (such as 1-2 hours) using small samples, so as to realize the rapid implementation and rapid iteration in the industrial field.
[0074] The present invention also includes an intelligent sorting system for agricultural products based on iterative optimization of physical features. The system is used to execute the sorting method formed by any one or more of the above examples. The system includes a multispectral imaging module, an agricultural product conveying module, a processing and control module, and a pneumatic execution module, which are connected in sequence.
[0075] The multispectral imaging module is used to acquire surface reflection and near-infrared transmission images of the agricultural products to be sorted. Preferably, the multispectral imaging module adopts a reflection-transmission composite optical path design to simultaneously acquire surface texture and internal structure information of the agricultural products. Specifically, the multispectral imaging module includes a main camera, an auxiliary camera, a diffuse dome light source, and a linear infrared light source. The main camera is positioned above the conveyor belt and uses a 4K / 8K color line scan camera (LineScanCamera), coupled with a high color rendering index LED diffuse dome light source, which can maximize the illumination of the concave areas of the wrinkled agricultural products and reduce shadow occlusion. The auxiliary camera is positioned below the gap in the conveyor belt and uses a monochrome line scan camera sensitive to the near-infrared band (NIR, 850nm-940nm). The matching light source is a high-intensity linear infrared light source installed below the belt gap. The light penetrates upward through the agricultural products and is received by the auxiliary camera. Furthermore, the main and auxiliary cameras are hardware-triggered by the same encoder signal to ensure that each row of RGB surface reflection images and NIR transmission images are strictly aligned in physical position (pixel-level registration), facilitating subsequent multispectral data fusion.
[0076] The agricultural product conveying module is used to transport agricultural products, allowing them to pass sequentially through the imaging station of the multispectral imaging module. Specifically, the agricultural product conveying module includes a high-speed conveyor belt (running speed v≈3m / s) and an incremental rotary encoder. The encoder is coaxially mounted on the belt drive pulley and is used to output pulse signals reflecting the real-time displacement of the belt.
[0077] The processing and control module connects to the camera via CameraLink or CoaXPress interface, and is responsible for image acquisition, algorithm processing, and control command transmission. This module can be a real-time processing industrial control computer, used for: representing surface reflection images as the product of illumination and reflection components, suppressing low-frequency illumination components representing macroscopic shadows, and enhancing high-frequency reflection components representing surface texture details; extracting physical feature vectors from surface reflection and near-infrared transmission images, where physical features include at least one of maturity and color, oiliness and texture, morphological integrity and damage, and identity and internal structure; extracting physical feature vectors from all sample images based on pre-acquired sample images and their corresponding grade labels to construct a feature matrix; using an optimization algorithm, with the comprehensive performance of the sorting results as the optimization objective, iteratively searching the feature matrix to obtain a set of optimal physical feature decision threshold parameters that best achieve the optimization objective; and performing feature extraction and decision-making on real-time acquired agricultural product images based on the optimal physical feature decision threshold parameter set, and controlling the actuator to complete the sorting action based on encoder signals and a delay compensation mechanism.
[0078] Preferably, the processing and control module includes an offline optimization unit and an online execution unit. The offline optimization unit extracts physical feature vectors from all sample images based on pre-acquired sample images and their corresponding grade labels, thereby constructing a feature matrix. It then uses an optimization algorithm to iteratively search the feature matrix, aiming at the overall performance of the sorting results, to obtain a set of optimal physical feature decision threshold parameters that maximize the optimization objective. The online execution unit performs feature extraction and decision-making on real-time acquired agricultural product images based on the optimal physical feature decision threshold parameter set, and controls the execution mechanism to complete the sorting action based on encoder signals and a delay compensation mechanism. This invention adopts a two-layer closed-loop architecture of offline AI optimization + online deterministic execution. The online operation layer deploys lightweight, interpretable physical / optical operators, independent of high-performance GPUs; the offline configuration layer utilizes computing power to automatically search for the optimal parameter combination through a matrix iterative algorithm, solving the problem of difficult debugging of non-standard products.
[0079] The pneumatic actuator module is used to perform sorting actions according to the sorting control commands from the processing and control module. Specifically, the pneumatic actuator module includes multiple high-frequency solenoid valves and nozzles arranged along the conveyor belt (belt). The high-frequency solenoid valves and nozzles are installed at the end of the conveyor belt. The high-frequency solenoid valves open and close according to the sorting control commands from the processing and control module, and the nozzles eject airflow to complete the sorting action. Optionally, the high-frequency solenoid valves receive rejection signals from the processing and control module (industrial computer) via an I / O board, and use high-pressure airflow to blow defective products away from the normal trajectory.
[0080] The system of this invention utilizes homomorphic filtering in the processing and control module to solve morphological interference, white-box physical feature quantization in the processing and control module to achieve interpretable quality detection, and matrix iterative optimization in the processing and control module to achieve rapid parameter adaptation. Thus, it constitutes a complete intelligent sorting system suitable for complex agricultural products, transforming the complex agricultural product sorting problem into a physical feature extraction and mathematical optimization problem, and combined with precise hardware control, achieving high-precision and high-stability automated sorting.
[0081] The present invention also provides a computer program product, comprising a computer program that, when executed by a processor, implements the steps of the intelligent sorting method for agricultural products based on iterative optimization of physical features, formed by any or a combination of the above examples. The processor may be a single-core or multi-core central processing unit or a specific integrated circuit, or one or more integrated circuits configured to implement the present invention.
[0082] The present invention also provides a storage medium having the same inventive concept as the intelligent sorting method for agricultural products based on iterative optimization of physical features formed by any or more of the above examples, wherein computer instructions are stored thereon, and the computer instructions execute the steps of the intelligent sorting method for agricultural products based on iterative optimization of physical features formed by any or more of the above examples when they are run.
[0083] Based on this understanding, the technical solution of this embodiment, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0084] The above detailed embodiments are a description of the present invention. It should not be considered that the specific embodiments of the present invention are limited to these descriptions. For those skilled in the art, several simple deductions and substitutions can be made without departing from the concept of the present invention, and all of these should be considered to fall within the protection scope of the present invention.
Claims
1. A method for intelligent sorting of agricultural products based on iterative optimization of physical features, characterized in that, Includes the following steps: Collect surface reflectance and near-infrared transmission images of agricultural products to be sorted; The surface reflection image is represented as the product of the illumination component and the reflection component, and the low-frequency illumination component, which represents macroscopic shadows, is suppressed, while the high-frequency reflection component, which represents surface texture details, is enhanced. Physical feature vectors are extracted from surface reflection images and near-infrared transmission images. The physical features include at least one of maturity and color, oiliness and texture, morphological integrity and damage, identity and internal structure. Based on the pre-collected sample images and their corresponding grade labels, physical feature vectors of all sample images are extracted to construct a feature matrix. Using an optimization algorithm, with the comprehensive performance of the sorting results as the optimization objective, an iterative search is performed on the feature matrix to obtain a set of optimal physical feature decision threshold parameters that optimize the objective. Based on the optimal combination of physical feature decision threshold parameters, feature extraction and decision are performed on real-time acquired agricultural product images, and the execution mechanism is controlled to complete the sorting action based on encoder signals and delay compensation mechanisms.
2. The intelligent sorting method for agricultural products based on iterative optimization of physical features according to claim 1, characterized in that, The acquisition of surface reflectance images and near-infrared transmission images of the agricultural products to be sorted includes: The surface reflection images of the agricultural products to be sorted are collected in conjunction with a diffuse dome light source located above the conveyor belt. Near-infrared transmission images of agricultural products to be sorted are collected using a linear infrared light source located below the gap in the conveyor belt. Two image acquisition devices are synchronously triggered based on the same encoder signal, enabling pixel-level spatial registration of the surface reflection image and the near-infrared transmission image.
3. The intelligent sorting method for agricultural products based on iterative optimization of physical features according to claim 1, characterized in that, The method of representing the surface reflection image as the product of the illumination component and the reflection component, and suppressing the low-frequency illumination component representing macroscopic shadows while enhancing the high-frequency reflection component representing surface texture details, includes: The pixel values of the surface reflection image are logarithmically transformed to obtain the logarithmic domain image; The logarithmic image is subjected to Fourier transform to obtain the frequency domain image, and the frequency domain image is subjected to Gaussian high-pass filtering to obtain the filtered frequency domain data. The frequency domain data is processed by inverse Fourier transform and exponential transform to obtain the preprocessed surface reflection image.
4. The intelligent sorting method for agricultural products based on iterative optimization of physical features according to claim 1, characterized in that, The extraction of physical feature vectors from surface reflection images and near-infrared transmission images includes: The surface reflection image is converted to the LAB color space, and the pixel variance of its red-green and yellow-blue channels is calculated to quantify maturity and color index; and / or, Calculate the gray-level co-occurrence matrix of the surface reflection image, and extract the energy and contrast values of the gray-level co-occurrence matrix to quantify the oiliness and texture indicators; and / or, Calculate the solidity of agricultural product outlines in surface reflection images. Solidity is the ratio of outline area to outline convex hull area, used to quantify morphological integrity and damage indices; and / or, The mean and variance of optical density in near-infrared transmission images are calculated to quantify identity and internal structure indicators.
5. The intelligent sorting method for agricultural products based on iterative optimization of physical features according to claim 1, characterized in that, The optimization algorithm, with the comprehensive performance of the sorting results as the optimization objective, iteratively searches the feature matrix to obtain a set of optimal physical feature decision threshold parameter combinations that maximize the optimization objective, including: A genetic algorithm is used for optimization. The optimal combination of physical feature decision threshold parameters is encoded into individuals in the genetic algorithm, and a fitness function is defined as the optimization objective. The fitness function is a weighted sum of sorting accuracy and false rejection rate.
6. The intelligent sorting method for agricultural products based on iterative optimization of physical features according to claim 1, characterized in that, The step of controlling the actuator to complete the sorting action based on encoder signals and a delay compensation mechanism includes: Establish a virtual queue that is synchronously mapped to the physical location of the conveyor belt; When an agricultural product is determined to be defective, the corresponding rejection flag is written to the corresponding position in the virtual queue according to the current encoder value. As the conveyor belt runs and the encoder count increases, the position of the rejection flag is moved synchronously in the virtual queue. Based on the encoder value corresponding to the real-time logical position of the rejection flag in the virtual queue, the fixed distance from the imaging position to the actuator, the mechanical delay time of the actuator, and the real-time speed of the conveyor belt, the compensated trigger encoder value is calculated. When the real-time encoder value reaches the trigger encoder value, the actuator is triggered to take action.
7. An intelligent sorting system for agricultural products based on iterative optimization of physical features, characterized in that, include: The multispectral imaging module is used to acquire surface reflection images and near-infrared transmission images of agricultural products to be sorted; The agricultural product conveying module is used to transport agricultural products, allowing them to pass sequentially through the imaging station of the multispectral imaging module. The processing and control module, connected to the multispectral imaging module, is used to: represent the surface reflection image as the product of the illumination component and the reflection component, suppress the low-frequency illumination component representing macroscopic shadows, and enhance the high-frequency reflection component representing surface texture details; extract physical feature vectors from the surface reflection image and the near-infrared transmission image, wherein the physical features include at least one of maturity and color, oiliness and texture, morphological integrity and damage, identity and internal structure; based on pre-acquired sample images and the corresponding grade labels of the sample images, extract the physical feature vectors of all sample images and then construct a feature matrix; and use an optimization algorithm to iteratively search on the feature matrix with the comprehensive performance of the sorting results as the optimization objective, to obtain a set of optimal physical feature decision threshold parameter combinations that optimize the objective. Based on the optimal combination of physical feature decision threshold parameters, feature extraction and decision are performed on real-time acquired agricultural product images, and the actuator is controlled to complete the sorting action based on encoder signals and delay compensation mechanism. The pneumatic actuator module is connected to the real-time processing and control module and is used to execute sorting actions according to the sorting control commands from the processing and control module.
8. The intelligent sorting system for agricultural products based on iterative optimization of physical features according to claim 7, characterized in that, The multispectral imaging module includes a main camera, an auxiliary camera, a diffuse dome light source, and a linear infrared light source; The main camera, in conjunction with a diffuse dome light source positioned above the conveyor belt, captures surface reflection images of the agricultural products to be sorted. The auxiliary camera, in conjunction with a linear infrared light source positioned below the gap in the conveyor belt, acquires near-infrared transmission images of the agricultural products to be sorted.
9. The intelligent sorting system for agricultural products based on iterative optimization of physical features according to claim 7, characterized in that, The pneumatic actuator module includes multiple high-frequency solenoid valves and nozzles arranged along the conveyor belt. The high-frequency solenoid valves switch on and off according to the sorting control command of the processing and control module, and the airflow is ejected through the nozzles to complete the sorting action.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the intelligent sorting method for agricultural products based on iterative optimization of physical features as described in any one of claims 1-6.